diff --git a/QPUassembler/qpu_assembler.c b/QPUassembler/qpu_assembler.c index ea46ab1..9d272ad 100644 --- a/QPUassembler/qpu_assembler.c +++ b/QPUassembler/qpu_assembler.c @@ -1104,7 +1104,7 @@ void disassemble_qpu_asm(uint64_t instruction) #define GET_BITFIELD(num_bits, place) (((instruction) & ((uint64_t)num_bits << place)) >> place) qpu_sig_bits sig_bits = GET_BITFIELD(0xf, 60); - printf("%s ; ", qpu_sig_bits_str[sig_bits]); + printf("\"%s ; ", qpu_sig_bits_str[sig_bits]); unsigned is_sem = GET_BITFIELD(0x7f, 57) == 0x74; @@ -1460,7 +1460,7 @@ void disassemble_qpu_asm(uint64_t instruction) printf("(%s, %s) ; ", qpu_mux_str[mul_a], qpu_mux_str[mul_b]); } - printf("\n"); + printf("\"\n"); } unsigned get_num_instructions(char* ptr) diff --git a/driver/copy.c b/driver/copy.c index 4e18f48..23b126d 100644 --- a/driver/copy.c +++ b/driver/copy.c @@ -63,13 +63,13 @@ void createFullscreenQuad(VkDevice device, VkBuffer* fsqVertexBuffer, VkDeviceMe float vertices[] = { - -1, -1, 0, 1, - 1, -1, 1, 1, - 1, 1, 1, 0, + -1, 1, 0, 1, + 1, 1, 1, 1, + 1, -1, 1, 0, - 1, 1, 1, 0, - -1, 1, 0, 0, - -1, -1, 0, 1 + 1, -1, 1, 0, + -1, -1, 0, 0, + -1, 1, 0, 1 }; void* data; @@ -1040,8 +1040,8 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdCopyBufferToImage( float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(height) * 0.5f * 16.0f; - float Zs = 0.5f; + float viewportScaleY = 1.0f * (float)(height) * 0.5f * 16.0f; + float Zs = 1.0f; uint32_t vertConstants[4]; vertConstants[0] = *(uint32_t*)&Wcoeff; @@ -1203,8 +1203,8 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdBlitImage( float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(dstWidth) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(dstHeight) * 0.5f * 16.0f; - float Zs = 0.5f; + float viewportScaleY = 1.0f * (float)(dstHeight) * 0.5f * 16.0f; + float Zs = 1.0f; uint32_t vertConstants[4]; vertConstants[0] = *(uint32_t*)&Wcoeff; diff --git a/driver/draw.c b/driver/draw.c index 8a46fef..7034439 100644 --- a/driver/draw.c +++ b/driver/draw.c @@ -64,10 +64,10 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) vp.y, //bottom pixel coord vp.x); //left pixel coord - //TODO why flipped??? + //Vulkan conventions, Y flipped [1...-1] bottom->top //Clipper XY Scaling clFit(commandBuffer, &commandBuffer->binCl, V3D21_CLIPPER_XY_SCALING_length); - clInsertClipperXYScaling(&commandBuffer->binCl, (float)(vp.width) * 0.5f * 16.0f, -1.0f * (float)(vp.height) * 0.5f * 16.0f); + clInsertClipperXYScaling(&commandBuffer->binCl, (float)(vp.width) * 0.5f * 16.0f, 1.0f * (float)(vp.height) * 0.5f * 16.0f); //Viewport Offset clFit(commandBuffer, &commandBuffer->binCl, V3D21_VIEWPORT_OFFSET_length); @@ -99,14 +99,11 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) clFit(commandBuffer, &commandBuffer->binCl, V3D21_DEPTH_OFFSET_length); clInsertDepthOffset(&commandBuffer->binCl, cb->graphicsPipeline->depthBiasConstantFactor, cb->graphicsPipeline->depthBiasSlopeFactor); - //TODO how is this calculated? - //it's Zc to Zs scale and bias - //seems to go from -1.0 .. 1.0 to 0.0 .. 1.0 - //eg. x * 0.5 + 0.5 + //Vulkan conventions, we expect the resulting NDC space Z axis to be in range [0...1] close->far //cb->graphicsPipeline->minDepthBounds; //Clipper Z Scale and Offset clFit(commandBuffer, &commandBuffer->binCl, V3D21_CLIPPER_Z_SCALE_AND_OFFSET_length); - clInsertClipperZScaleOffset(&commandBuffer->binCl, 0.5f, 0.5f); + clInsertClipperZScaleOffset(&commandBuffer->binCl, 0.0f, 1.0f); cb->vertexBufferDirty = 0; cb->depthBoundsDirty = 0; diff --git a/test/ETC/ETC.cpp b/test/ETC/ETC.cpp index 86515e3..8585103 100644 --- a/test/ETC/ETC.cpp +++ b/test/ETC/ETC.cpp @@ -838,8 +838,8 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; uint32_t pushConstants[4]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1643,9 +1643,9 @@ void CreateVertexBuffer() float vertices[] = { - -1, -1, - 1, -1, - 0, 1 + -1, 1, + 1, 1, + 0, -1 }; void* data; diff --git a/test/HDR/HDR.cpp b/test/HDR/HDR.cpp index 3a9d176..5e73312 100644 --- a/test/HDR/HDR.cpp +++ b/test/HDR/HDR.cpp @@ -805,8 +805,8 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; uint32_t pushConstants[4]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1687,9 +1687,9 @@ void CreateVertexBuffer() float vertices[] = { - -1, -1, - 1, -1, - 0, 1 + -1, 1, + 1, 1, + 0, -1 }; void* data; diff --git a/test/MSAA/MSAA.cpp b/test/MSAA/MSAA.cpp index 892d752..b8ef69d 100644 --- a/test/MSAA/MSAA.cpp +++ b/test/MSAA/MSAA.cpp @@ -692,8 +692,8 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; uint32_t pushConstants[4]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1278,9 +1278,9 @@ void CreateVertexBuffer() float vertices[] = { - -1, -1, - 1, -1, - 0, 1 + -1, 1, + 1, 1, + 0, -1 }; void* data; diff --git a/test/blending/blending.cpp b/test/blending/blending.cpp index fddd306..00c3094 100644 --- a/test/blending/blending.cpp +++ b/test/blending/blending.cpp @@ -682,9 +682,9 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; - float Zo = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; + float Zo = 0.0f; uint32_t pushConstants[5]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1302,9 +1302,9 @@ void CreateVertexBuffer() float vertices[] = { - -1, -1, 0.2, - 1, -1, 0.2, - 0, 1, 0.2 + -1, 1, 0.2, + 1, 1, 0.2, + 0, -1, 0.2 }; void* data; @@ -1329,9 +1329,9 @@ void CreateVertexBuffer() float vertices[] = { - -0.5, -1, 0.5, - 1.5, -1, 0.5, - 0.5, 1, 0.5 + -0.5, 1, 0.5, + 1.5, 1, 0.5, + 0.5, -1, 0.5 }; void* data; diff --git a/test/cubemapping/cubemapping.cpp b/test/cubemapping/cubemapping.cpp index 7e99418..ca2c90e 100644 --- a/test/cubemapping/cubemapping.cpp +++ b/test/cubemapping/cubemapping.cpp @@ -756,9 +756,9 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; - float Zo = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; + float Zo = 0.0f; uint32_t pushConstants[5]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1597,53 +1597,53 @@ void CreateVertexBuffer() float vertices[] = { - -1, -1, -1, - 1, -1, -1, - -1, 1, -1, + -1, 1, 0, + 1, 1, 0, + -1, -1, 0, - -1, 1, -1, - 1, 1, -1, - 1, -1, -1, + -1, -1, 0, + 1, -1, 0, + 1, 1, 0, - 1, -1, -1, - 1, 1, -1, - 1, -1, 1, - - 1, -1, 1, - 1, 1, -1, + 1, 1, 0, + 1, -1, 0, 1, 1, 1, - 1, 1, 1, - 1, 1, -1, - -1, 1, -1, + 1, 1, 1, + 1, -1, 0, + 1, -1, 1, - -1, 1, -1, - 1, 1, 1, - -1, 1, 1, + 1, -1, 1, + 1, -1, 0, + -1, -1, 0, - -1, 1, 1, - -1, -1, -1, - -1, 1, -1, - - -1, -1, -1, - -1, 1, 1, + -1, -1, 0, + 1, -1, 1, -1, -1, 1, + -1, -1, 1, + -1, 1, 0, + -1, -1, 0, + + -1, 1, 0, + -1, -1, 1, -1, 1, 1, + + -1, -1, 1, + 1, -1, 1, 1, 1, 1, - 1, -1, 1, - 1, -1, 1, - -1, -1, 1, + 1, 1, 1, -1, 1, 1, - - -1, -1, -1, - 1, -1, -1, - 1, -1, 1, - - 1, -1, 1, -1, -1, 1, - -1, -1, -1, + + -1, 1, 0, + 1, 1, 0, + 1, 1, 1, + + 1, 1, 1, + -1, 1, 1, + -1, 1, 0, }; //transform our cube diff --git a/test/depthTest/depthTest.cpp b/test/depthTest/depthTest.cpp index a1ac2ec..c021966 100644 --- a/test/depthTest/depthTest.cpp +++ b/test/depthTest/depthTest.cpp @@ -807,9 +807,9 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; - float Zo = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; + float Zo = 0.0f; uint32_t pushConstants[5]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1415,9 +1415,9 @@ void CreateVertexBuffer() float vertices[] = { - -1, -1, 0.2, - 1, -1, 0.2, - 0, 1, 0.2 + -1, 1, 0.2, + 1, 1, 0.2, + 0, -1, 0.2 }; void* data; @@ -1442,9 +1442,9 @@ void CreateVertexBuffer() float vertices[] = { - -0.5, -1, 0.5, - 1.5, -1, 0.5, - 0.5, 1, 0.5 + -0.5, 1, 0.5, + 1.5, 1, 0.5, + 0.5, -1, 0.5 }; void* data; diff --git a/test/depthTex/depthTex.cpp b/test/depthTex/depthTex.cpp index fae5461..5c0634e 100644 --- a/test/depthTex/depthTex.cpp +++ b/test/depthTex/depthTex.cpp @@ -756,8 +756,8 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; uint32_t pushConstants[4]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1592,9 +1592,9 @@ void CreateVertexBuffer() float vertices[] = { - -1, -1, - 1, -1, - 0, 1 + -1, 1, + 1, 1, + 0, -1 }; void* data; diff --git a/test/indexedTriangle/indexedTriangle.cpp b/test/indexedTriangle/indexedTriangle.cpp index c075bc2..9a10138 100644 --- a/test/indexedTriangle/indexedTriangle.cpp +++ b/test/indexedTriangle/indexedTriangle.cpp @@ -692,8 +692,8 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; uint32_t pushConstants[4]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1240,9 +1240,9 @@ void CreateVertexBuffer() //-1, -1 //cw order - -1, -1, - 1, -1, - 0, 1 + -1, 1, + 1, 1, + 0, -1 }; void* data; diff --git a/test/mipmapping/mipmapping.cpp b/test/mipmapping/mipmapping.cpp index b39194c..9071e5f 100644 --- a/test/mipmapping/mipmapping.cpp +++ b/test/mipmapping/mipmapping.cpp @@ -757,9 +757,9 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; - float Zo = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; + float Zo = 0.0f; uint32_t pushConstants[5]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1707,69 +1707,69 @@ void CreateVertexBuffer() { //create triangle vertex buffer float vertices[] = { - -0.5, 1, -1, 0.0, 1.0, - 0.5, 1, -1, 1.0, 1.0, - -0.125, 0.25, 1, 0.0, 0.0, + -0.5, -1, 0, 0.0, 1.0, + 0.5, -1, 0, 1.0, 1.0, + -0.125, -0.25, 1, 0.0, 0.0, - -0.125, 0.25, 1, 0.0, 0.0, - 0.125, 0.25, 1, 1.0, 0.0, - 0.5, 1, -1, 1.0, 1.0, + -0.125, -0.25, 1, 0.0, 0.0, + 0.125, -0.25, 1, 1.0, 0.0, + 0.5, -1, 0, 1.0, 1.0, - 0.5, 1, -1, 1.0, 1.0, - 0.125, 0.25, 1, 1.0, 0.0, - 0.25, 0.125, 1, 0.0, 0.0, + 0.5, -1, 0, 1.0, 1.0, + 0.125, -0.25, 1, 1.0, 0.0, + 0.25, -0.125, 1, 0.0, 0.0, - 0.25, 0.125, 1, 0.0, 0.0, - 0.5, 1, -1, 1.0, 1.0, - 1, 0.5, -1, 0.0, 1.0, + 0.25, -0.125, 1, 0.0, 0.0, + 0.5, -1, 0, 1.0, 1.0, + 1, -0.5, 0, 0.0, 1.0, - 1, 0.5, -1, 0.0, 1.0, - 0.25, 0.125, 1, 0.0, 0.0, - 0.25, -0.125, 1, 1.0, 0.0, + 1, -0.5, 0, 0.0, 1.0, + 0.25, -0.125, 1, 0.0, 0.0, + 0.25, 0.125, 1, 1.0, 0.0, - 0.25, -0.125, 1, 1.0, 0.0, - 1, 0.5, -1, 0.0, 1.0, - 1, -0.5, -1, 1.0, 1.0, + 0.25, 0.125, 1, 1.0, 0.0, + 1, -0.5, 0, 0.0, 1.0, + 1, 0.5, 0, 1.0, 1.0, - 1, -0.5, -1, 1.0, 1.0, - 0.25, -0.125, 1, 1.0, 0.0, - 0.5, -1, -1, 0.0, 1.0, + 1, 0.5, 0, 1.0, 1.0, + 0.25, 0.125, 1, 1.0, 0.0, + 0.5, 1, 0, 0.0, 1.0, - 0.5, -1, -1, 0.0, 1.0, - 0.25, -0.125, 1, 1.0, 0.0, - 0.125, -0.25, 1, 0.0, 0.0, + 0.5, 1, 0, 0.0, 1.0, + 0.25, 0.125, 1, 1.0, 0.0, + 0.125, 0.25, 1, 0.0, 0.0, - 0.125, -0.25, 1, 0.0, 0.0, - 0.5, -1, -1, 0.0, 1.0, - -0.5, -1, -1, 1.0, 1.0, + 0.125, 0.25, 1, 0.0, 0.0, + 0.5, 1, 0, 0.0, 1.0, + -0.5, 1, 0, 1.0, 1.0, - -0.5, -1, -1, 1.0, 1.0, - 0.125, -0.25, 1, 0.0, 0.0, - -0.125, -0.25, 1, 1.0, 0.0, + -0.5, 1, 0, 1.0, 1.0, + 0.125, 0.25, 1, 0.0, 0.0, + -0.125, 0.25, 1, 1.0, 0.0, - -0.5, -1, -1, 1.0, 1.0, - -0.125, -0.25, 1, 1.0, 0.0, - -0.25, -0.125, 1, 0.0, 0.0, + -0.5, 1, 0, 1.0, 1.0, + -0.125, 0.25, 1, 1.0, 0.0, + -0.25, 0.125, 1, 0.0, 0.0, - -0.25, -0.125, 1, 0.0, 0.0, - -0.5, -1, -1, 1.0, 1.0, - -1, -0.5, -1, 0.0, 1.0, + -0.25, 0.125, 1, 0.0, 0.0, + -0.5, 1, 0, 1.0, 1.0, + -1, 0.5, 0, 0.0, 1.0, - -1, -0.5, -1, 0.0, 1.0, - -0.25, -0.125, 1, 0.0, 0.0, - -0.25, 0.125, 1, 1.0, 0.0, + -1, 0.5, 0, 0.0, 1.0, + -0.25, 0.125, 1, 0.0, 0.0, + -0.25, -0.125, 1, 1.0, 0.0, - -0.25, 0.125, 1, 1.0, 0.0, - -1, -0.5, -1, 0.0, 1.0, - -1, 0.5, -1, 1.0, 1.0, + -0.25, -0.125, 1, 1.0, 0.0, + -1, 0.5, 0, 0.0, 1.0, + -1, -0.5, 0, 1.0, 1.0, - -1, 0.5, -1, 1.0, 1.0, - -0.5, 1, -1, 0.0, 1.0, - -0.25, 0.125, 1, 1.0, 0.0, + -1, -0.5, 0, 1.0, 1.0, + -0.5, -1, 0, 0.0, 1.0, + -0.25, -0.125, 1, 1.0, 0.0, - -0.25, 0.125, 1, 1.0, 0.0, - -0.125, 0.25, 1, 0.0, 0.0, - -0.5, 1, -1, 0.0, 1.0, + -0.25, -0.125, 1, 1.0, 0.0, + -0.125, -0.25, 1, 0.0, 0.0, + -0.5, -1, 0, 0.0, 1.0, }; unsigned vboSize = sizeof(vertices); diff --git a/test/query/query.cpp b/test/query/query.cpp index 137be6c..4cce2ec 100644 --- a/test/query/query.cpp +++ b/test/query/query.cpp @@ -729,8 +729,8 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; uint32_t pushConstants[4]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1300,9 +1300,9 @@ void CreateVertexBuffer() float vertices[] = { - -1, -1, - 1, -1, - 0, 1 + -1, 1, + 1, 1, + 0, -1 }; void* data; diff --git a/test/stencilTest/stencilTest.cpp b/test/stencilTest/stencilTest.cpp index ab1430e..e9edc75 100644 --- a/test/stencilTest/stencilTest.cpp +++ b/test/stencilTest/stencilTest.cpp @@ -806,9 +806,9 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; - float Zo = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; + float Zo = 0.0f; uint32_t pushConstants[5]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1459,9 +1459,9 @@ void CreateVertexBuffer() float vertices[] = { - -1, -0.25, 0.2, - 0.75, -0.25, 0.2, - 0, 1, 0.2 + -1, 0.25, 0.2, + 0.75, 0.25, 0.2, + 0, -1, 0.2 }; void* data; @@ -1486,9 +1486,9 @@ void CreateVertexBuffer() float vertices[] = { - -0.5, -1, 0.5, - 1.5, -1, 0.5, - 0.5, 1, 0.5 + -0.5, 1, 0.5, + 1.5, 1, 0.5, + 0.5, -1, 0.5 }; void* data; diff --git a/test/texturing/texturing.cpp b/test/texturing/texturing.cpp index 92010bc..7f13e02 100644 --- a/test/texturing/texturing.cpp +++ b/test/texturing/texturing.cpp @@ -756,8 +756,8 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; uint32_t pushConstants[4]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1562,9 +1562,9 @@ void CreateVertexBuffer() float vertices[] = { - -1, -1, - 1, -1, - 0, 1 + -1, 1, + 1, 1, + 0, -1 }; void* data; diff --git a/test/triangle/triangle.cpp b/test/triangle/triangle.cpp index 2c0de2b..670e627 100644 --- a/test/triangle/triangle.cpp +++ b/test/triangle/triangle.cpp @@ -131,11 +131,55 @@ void run() { cleanup(); } -void setupVulkan() { +void setupVulkan() { createInstance(); findPhysicalDevice(); findQueueFamilies(); createLogicalDevice(); + + VkDescriptorPoolSize ps[2]; + ps[0].descriptorCount = 1; + ps[0].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; + ps[1].descriptorCount = 1; + ps[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + + VkDescriptorPoolCreateInfo ci = {}; + ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; + ci.maxSets = 2; + ci.poolSizeCount = 2; + ci.pPoolSizes = ps; + ci.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT; + + VkDescriptorPool dp; + vkCreateDescriptorPool(device, &ci, 0, &dp); + + VkDescriptorSet ds; + + VkDescriptorSetLayoutBinding bi = {}; + bi.binding = 0; + bi.descriptorCount = 1; + bi.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + bi.stageFlags = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; + + VkDescriptorSetLayoutCreateInfo dc = {}; + dc.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; + dc.bindingCount = 1; + dc.pBindings = &bi; + + VkDescriptorSetLayout sl; + vkCreateDescriptorSetLayout(device, &dc, 0, &sl); + + VkDescriptorSetAllocateInfo ai = {}; + ai.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; + ai.descriptorPool = dp; + ai.descriptorSetCount = 1; + ai.pSetLayouts = &sl; + vkAllocateDescriptorSets(device, &ai, &ds); + + vkFreeDescriptorSets(device, dp, 1, &ds); + vkDestroyDescriptorSetLayout(device, sl, 0); + vkDestroyDescriptorPool(device, dp, 0); + CreateShaders(); createWindowSurface(); checkSwapChainSupport(); @@ -744,8 +788,8 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; uint32_t pushConstants[4]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1285,9 +1329,9 @@ void CreateVertexBuffer() float vertices[] = { - -1, -1, - 1, -1, - 0, 1 + -1, 1, + 1, 1, + 0, -1 }; void* data; diff --git a/test/varyings/varyings.cpp b/test/varyings/varyings.cpp index 2b53da0..f3f4f1e 100644 --- a/test/varyings/varyings.cpp +++ b/test/varyings/varyings.cpp @@ -688,8 +688,8 @@ void recordCommandBuffers() float Wcoeff = 1.0f; //1.0f / Wc = 2.0 - Wcoeff float viewportScaleX = (float)(swapChainExtent.width) * 0.5f * 16.0f; - float viewportScaleY = -1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; - float Zs = 0.5f; + float viewportScaleY = 1.0f * (float)(swapChainExtent.height) * 0.5f * 16.0f; + float Zs = 1.0f; uint32_t pushConstants[4]; pushConstants[0] = *(uint32_t*)&Wcoeff; @@ -1302,9 +1302,9 @@ void CreateVertexBuffer() float vertices[] = { // verts texcoords - -1, -1, 0, 0, - 1, -1, 1, 0, - 0, 1, 0.5, 1 + -1, 1, 0, 0, + 1, 1, 1, 0, + 0, -1, 0.5, 1 }; void* data;