mirror of
https://github.com/Yours3lf/rpi-vk-driver.git
synced 2025-03-21 12:29:15 +01:00
updated NDC coordinate space to be right handed
x [0..1] y [1..-1] z [0..1]
This commit is contained in:
parent
13e7a67197
commit
68a9a4ee2c
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user