1
0
mirror of https://github.com/Yours3lf/rpi-vk-driver.git synced 2025-01-18 10:52:14 +01:00

fixed depth bias

This commit is contained in:
yours3lf 2020-05-13 23:35:59 +01:00
parent 4617c9b0b4
commit 84befd0ff4
3 changed files with 14 additions and 5 deletions

View File

@ -506,14 +506,20 @@ void clInsertRHTXBoundary(ControlList* cl,
*(uint16_t*)cl->nextFreeByte = moveBits(boundary, 16, 0); cl->nextFreeByte += 2;
}
uint32_t f32_to_f187(float f32)
{
uint32_t bits = *(uint32_t*)&f32;
return bits >> 16;
}
void clInsertDepthOffset(ControlList* cl,
uint32_t units, //float 187
uint32_t factor) //float 187
float units,
float factor)
{
assert(cl);
assert(cl->nextFreeByte);
*cl->nextFreeByte = V3D21_DEPTH_OFFSET_opcode; cl->nextFreeByte++;
*(uint32_t*)cl->nextFreeByte = moveBits(factor, 16, 0) | moveBits(units, 16, 16); cl->nextFreeByte += 4;
*(uint32_t*)cl->nextFreeByte = moveBits(f32_to_f187(factor), 16, 0) | moveBits(f32_to_f187(units), 16, 16); cl->nextFreeByte += 4;
}
void clInsertClipWindow(ControlList* cl,

View File

@ -137,8 +137,8 @@ void clInsertLineWidth(ControlList* cl,
void clInsertRHTXBoundary(ControlList* cl,
uint32_t boundary); //sint16
void clInsertDepthOffset(ControlList* cl,
uint32_t units, //float 187
uint32_t factor); //float 187
float units,
float factor);
void clInsertClipWindow(ControlList* cl,
uint32_t width, //uint16
uint32_t height, //uint16

View File

@ -1349,6 +1349,9 @@ void CreatePipeline()
rastCreateInfo.cullMode = VK_CULL_MODE_NONE;
rastCreateInfo.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
rastCreateInfo.lineWidth = 1.0f;
rastCreateInfo.depthBiasEnable = 1;
rastCreateInfo.depthBiasConstantFactor = -2.0f;
rastCreateInfo.depthBiasSlopeFactor = -1.0f;
VkPipelineMultisampleStateCreateInfo pipelineMSCreateInfo = {};
pipelineMSCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;