From 84befd0ff4cb15d336f7e8d61dcfaefb5484a172 Mon Sep 17 00:00:00 2001 From: yours3lf <0.tamas.marton@gmail.com> Date: Wed, 13 May 2020 23:35:59 +0100 Subject: [PATCH] fixed depth bias --- driver/ControlListUtil.c | 12 +++++++++--- driver/ControlListUtil.h | 4 ++-- test/clearTest/clearTest.cpp | 3 +++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/driver/ControlListUtil.c b/driver/ControlListUtil.c index 0642627..6eac62e 100644 --- a/driver/ControlListUtil.c +++ b/driver/ControlListUtil.c @@ -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, diff --git a/driver/ControlListUtil.h b/driver/ControlListUtil.h index db3c97c..07d8434 100644 --- a/driver/ControlListUtil.h +++ b/driver/ControlListUtil.h @@ -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 diff --git a/test/clearTest/clearTest.cpp b/test/clearTest/clearTest.cpp index 1ff935e..34b0cfd 100644 --- a/test/clearTest/clearTest.cpp +++ b/test/clearTest/clearTest.cpp @@ -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;