Fix vk_validation warnings

This commit is contained in:
Denis Pauk 2020-05-18 22:04:46 +03:00 committed by Yamagi
parent f6ae494637
commit 7eb075198e
12 changed files with 116 additions and 128 deletions

View file

@ -296,7 +296,7 @@ VkResult QVk_CreateUniformBuffer(VkDeviceSize size, qvkbuffer_t *dstBuffer, VkMe
void QVk_CreateVertexBuffer(const void *data, VkDeviceSize size, qvkbuffer_t *dstBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags);
void QVk_CreateIndexBuffer(const void *data, VkDeviceSize size, qvkbuffer_t *dstBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags);
qvkshader_t QVk_CreateShader(const uint32_t *shaderSrc, size_t shaderCodeSize, VkShaderStageFlagBits shaderStage);
void QVk_CreatePipeline(const VkDescriptorSetLayout *descriptorLayout, const uint32_t descLayoutCount, const VkPipelineVertexInputStateCreateInfo *vertexInputInfo, qvkpipeline_t *pipeline, const qvkrenderpass_t *renderpass, const qvkshader_t *shaders, uint32_t shaderCount, VkPushConstantRange *pcRange);
void QVk_CreatePipeline(const VkDescriptorSetLayout *descriptorLayout, const uint32_t descLayoutCount, const VkPipelineVertexInputStateCreateInfo *vertexInputInfo, qvkpipeline_t *pipeline, const qvkrenderpass_t *renderpass, const qvkshader_t *shaders, uint32_t shaderCount);
void QVk_DestroyPipeline(qvkpipeline_t *pipeline);
uint8_t* QVk_GetVertexBuffer(VkDeviceSize size, VkBuffer *dstBuffer, VkDeviceSize *dstOffset);
uint8_t* QVk_GetUniformBuffer(VkDeviceSize size, uint32_t *dstOffset, VkDescriptorSet *dstUboDescriptorSet);

View file

@ -1,51 +1,48 @@
// 8.13.3559
#pragma once
const uint32_t basic_frag_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000039,0x00000000,0x00020011,0x00000001,0x0006000b,
0x07230203,0x00010000,0x00080008,0x00000038,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0009000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x00000011,0x00000015,
0x0000001e,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,
0x00000004,0x6e69616d,0x00000000,0x00060005,0x00000009,0x67617266,0x746e656d,0x6f6c6f43,
0x00000072,0x00050005,0x0000000d,0x78655473,0x65727574,0x00000000,0x00050005,0x00000011,
0x43786574,0x64726f6f,0x00000000,0x00040005,0x00000015,0x6f6c6f63,0x00000072,0x00050005,
0x0000001e,0x65725461,0x6c6f6873,0x00000064,0x00060005,0x00000029,0x68737550,0x736e6f43,
0x746e6174,0x00000000,0x00060006,0x00000029,0x00000000,0x614d7076,0x78697274,0x00000000,
0x00050006,0x00000029,0x00000001,0x6d6d6167,0x00000061,0x00030005,0x0000002b,0x00006370,
0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,0x00000022,0x00000000,
0x00040047,0x0000000d,0x00000021,0x00000000,0x00040047,0x00000011,0x0000001e,0x00000000,
0x00040047,0x00000015,0x0000001e,0x00000001,0x00040047,0x0000001e,0x0000001e,0x00000002,
0x00040048,0x00000029,0x00000000,0x00000005,0x00050048,0x00000029,0x00000000,0x00000023,
0x00000000,0x00050048,0x00000029,0x00000000,0x00000007,0x00000010,0x00050048,0x00000029,
0x00000001,0x00000023,0x00000040,0x00030047,0x00000029,0x00000002,0x00020013,0x00000002,
0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,
0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,0x00000007,0x0004003b,0x00000008,
0x00000009,0x00000003,0x00090019,0x0000000a,0x00000006,0x00000001,0x00000000,0x00000000,
0x00000000,0x00000001,0x00000000,0x0003001b,0x0000000b,0x0000000a,0x00040020,0x0000000c,
0x00000000,0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000000,0x00040017,0x0000000f,
0x00000006,0x00000002,0x00040020,0x00000010,0x00000001,0x0000000f,0x0004003b,0x00000010,
0x00000011,0x00000001,0x00040020,0x00000014,0x00000001,0x00000007,0x0004003b,0x00000014,
0x00000015,0x00000001,0x00040015,0x00000018,0x00000020,0x00000000,0x0004002b,0x00000018,
0x00000019,0x00000003,0x00040020,0x0000001a,0x00000003,0x00000006,0x00040020,0x0000001d,
0x00000001,0x00000006,0x0004003b,0x0000001d,0x0000001e,0x00000001,0x00020014,0x00000020,
0x00040017,0x00000025,0x00000006,0x00000003,0x00040018,0x00000028,0x00000007,0x00000004,
0x0004001e,0x00000029,0x00000028,0x00000006,0x00040020,0x0000002a,0x00000009,0x00000029,
0x0004003b,0x0000002a,0x0000002b,0x00000009,0x00040015,0x0000002c,0x00000020,0x00000001,
0x0004002b,0x0000002c,0x0000002d,0x00000001,0x00040020,0x0000002e,0x00000009,0x00000006,
0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003d,
0x0000000b,0x0000000e,0x0000000d,0x0004003d,0x0000000f,0x00000012,0x00000011,0x00050057,
0x00000007,0x00000013,0x0000000e,0x00000012,0x0004003d,0x00000007,0x00000016,0x00000015,
0x00050085,0x00000007,0x00000017,0x00000013,0x00000016,0x0003003e,0x00000009,0x00000017,
0x00050041,0x0000001a,0x0000001b,0x00000009,0x00000019,0x0004003d,0x00000006,0x0000001c,
0x0000001b,0x0004003d,0x00000006,0x0000001f,0x0000001e,0x000500b8,0x00000020,0x00000021,
0x0000001c,0x0000001f,0x000300f7,0x00000023,0x00000000,0x000400fa,0x00000021,0x00000022,
0x00000023,0x000200f8,0x00000022,0x000100fc,0x000200f8,0x00000023,0x0004003d,0x00000007,
0x00000026,0x00000009,0x0008004f,0x00000025,0x00000027,0x00000026,0x00000026,0x00000000,
0x00000001,0x00000002,0x00050041,0x0000002e,0x0000002f,0x0000002b,0x0000002d,0x0004003d,
0x00000006,0x00000030,0x0000002f,0x00060050,0x00000025,0x00000031,0x00000030,0x00000030,
0x00000030,0x0007000c,0x00000025,0x00000032,0x00000001,0x0000001a,0x00000027,0x00000031,
0x00050041,0x0000001a,0x00000033,0x00000009,0x00000019,0x0004003d,0x00000006,0x00000034,
0x00000033,0x00050051,0x00000006,0x00000035,0x00000032,0x00000000,0x00050051,0x00000006,
0x00000036,0x00000032,0x00000001,0x00050051,0x00000006,0x00000037,0x00000032,0x00000002,
0x00070050,0x00000007,0x00000038,0x00000035,0x00000036,0x00000037,0x00000034,0x0003003e,
0x00000009,0x00000038,0x000100fd,0x00010038
0x0000001e,0x65725461,0x6c6f6873,0x00000064,0x00060005,0x00000028,0x68737550,0x736e6f43,
0x746e6174,0x00000000,0x00050006,0x00000028,0x00000000,0x6d6d6167,0x00000061,0x00030005,
0x0000002a,0x00006370,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,
0x00000022,0x00000000,0x00040047,0x0000000d,0x00000021,0x00000000,0x00040047,0x00000011,
0x0000001e,0x00000000,0x00040047,0x00000015,0x0000001e,0x00000001,0x00040047,0x0000001e,
0x0000001e,0x00000002,0x00050048,0x00000028,0x00000000,0x00000023,0x00000044,0x00030047,
0x00000028,0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,
0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,
0x00000003,0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00090019,0x0000000a,
0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,
0x0000000b,0x0000000a,0x00040020,0x0000000c,0x00000000,0x0000000b,0x0004003b,0x0000000c,
0x0000000d,0x00000000,0x00040017,0x0000000f,0x00000006,0x00000002,0x00040020,0x00000010,
0x00000001,0x0000000f,0x0004003b,0x00000010,0x00000011,0x00000001,0x00040020,0x00000014,
0x00000001,0x00000007,0x0004003b,0x00000014,0x00000015,0x00000001,0x00040015,0x00000018,
0x00000020,0x00000000,0x0004002b,0x00000018,0x00000019,0x00000003,0x00040020,0x0000001a,
0x00000003,0x00000006,0x00040020,0x0000001d,0x00000001,0x00000006,0x0004003b,0x0000001d,
0x0000001e,0x00000001,0x00020014,0x00000020,0x00040017,0x00000025,0x00000006,0x00000003,
0x0003001e,0x00000028,0x00000006,0x00040020,0x00000029,0x00000009,0x00000028,0x0004003b,
0x00000029,0x0000002a,0x00000009,0x00040015,0x0000002b,0x00000020,0x00000001,0x0004002b,
0x0000002b,0x0000002c,0x00000000,0x00040020,0x0000002d,0x00000009,0x00000006,0x00050036,
0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003d,0x0000000b,
0x0000000e,0x0000000d,0x0004003d,0x0000000f,0x00000012,0x00000011,0x00050057,0x00000007,
0x00000013,0x0000000e,0x00000012,0x0004003d,0x00000007,0x00000016,0x00000015,0x00050085,
0x00000007,0x00000017,0x00000013,0x00000016,0x0003003e,0x00000009,0x00000017,0x00050041,
0x0000001a,0x0000001b,0x00000009,0x00000019,0x0004003d,0x00000006,0x0000001c,0x0000001b,
0x0004003d,0x00000006,0x0000001f,0x0000001e,0x000500b8,0x00000020,0x00000021,0x0000001c,
0x0000001f,0x000300f7,0x00000023,0x00000000,0x000400fa,0x00000021,0x00000022,0x00000023,
0x000200f8,0x00000022,0x000100fc,0x000200f8,0x00000023,0x0004003d,0x00000007,0x00000026,
0x00000009,0x0008004f,0x00000025,0x00000027,0x00000026,0x00000026,0x00000000,0x00000001,
0x00000002,0x00050041,0x0000002d,0x0000002e,0x0000002a,0x0000002c,0x0004003d,0x00000006,
0x0000002f,0x0000002e,0x00060050,0x00000025,0x00000030,0x0000002f,0x0000002f,0x0000002f,
0x0007000c,0x00000025,0x00000031,0x00000001,0x0000001a,0x00000027,0x00000030,0x00050041,
0x0000001a,0x00000032,0x00000009,0x00000019,0x0004003d,0x00000006,0x00000033,0x00000032,
0x00050051,0x00000006,0x00000034,0x00000031,0x00000000,0x00050051,0x00000006,0x00000035,
0x00000031,0x00000001,0x00050051,0x00000006,0x00000036,0x00000031,0x00000002,0x00070050,
0x00000007,0x00000037,0x00000034,0x00000035,0x00000036,0x00000033,0x0003003e,0x00000009,
0x00000037,0x000100fd,0x00010038
};

View file

@ -11,7 +11,7 @@ const uint32_t postprocess_frag_spv[] = {
0x00000001,0x6d6d6167,0x00000061,0x00030005,0x00000009,0x00006370,0x00060005,0x00000016,
0x67617266,0x746e656d,0x6f6c6f43,0x00000072,0x00050005,0x0000001a,0x78655473,0x65727574,
0x00000000,0x00050005,0x0000001e,0x43786574,0x64726f6f,0x00000000,0x00050048,0x00000007,
0x00000000,0x00000023,0x00000000,0x00050048,0x00000007,0x00000001,0x00000023,0x00000004,
0x00000000,0x00000023,0x00000044,0x00050048,0x00000007,0x00000001,0x00000023,0x00000048,
0x00030047,0x00000007,0x00000002,0x00040047,0x00000016,0x0000001e,0x00000000,0x00040047,
0x0000001a,0x00000022,0x00000000,0x00040047,0x0000001a,0x00000021,0x00000000,0x00040047,
0x0000001e,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,

View file

@ -16,8 +16,8 @@ const uint32_t world_warp_frag_spv[] = {
0x00050005,0x00000060,0x74736964,0x6974726f,0x00006e6f,0x00060005,0x00000070,0x67617266,
0x746e656d,0x6f6c6f43,0x00000072,0x00050005,0x00000074,0x78655473,0x65727574,0x00000000,
0x00040047,0x0000000c,0x0000000b,0x0000000f,0x00050048,0x00000012,0x00000000,0x00000023,
0x00000000,0x00050048,0x00000012,0x00000001,0x00000023,0x00000004,0x00050048,0x00000012,
0x00000002,0x00000023,0x00000008,0x00050048,0x00000012,0x00000003,0x00000023,0x0000000c,
0x00000044,0x00050048,0x00000012,0x00000001,0x00000023,0x00000048,0x00050048,0x00000012,
0x00000002,0x00000023,0x0000004c,0x00050048,0x00000012,0x00000003,0x00000023,0x00000050,
0x00030047,0x00000012,0x00000002,0x00040047,0x00000070,0x0000001e,0x00000000,0x00040047,
0x00000074,0x00000022,0x00000000,0x00040047,0x00000074,0x00000021,0x00000000,0x00020013,
0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,

View file

@ -1212,22 +1212,10 @@ static void CreatePipelines()
// shader array (vertex and fragment, no compute... yet)
qvkshader_t shaders[2] = {0};
// push constant sizes accomodate for maximum number of uploaded elements (should probably be checked against the hardware's maximum supported value)
VkPushConstantRange pushConstantRangeVert = {
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
.offset = 0,
.size = 32 * sizeof(float)
};
VkPushConstantRange pushConstantRangeFrag = {
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
.offset = 0,
.size = 4 * sizeof(float)
};
// textured quad pipeline
VK_LOAD_VERTFRAG_SHADERS(shaders, basic, basic);
vk_drawTexQuadPipeline.depthTestEnable = VK_FALSE;
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRG_RG, &vk_drawTexQuadPipeline, &vk_renderpasses[RP_UI], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRG_RG, &vk_drawTexQuadPipeline, &vk_renderpasses[RP_UI], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawTexQuadPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: textured quad");
QVk_DebugSetObjectName((uint64_t)vk_drawTexQuadPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: textured quad");
@ -1235,7 +1223,7 @@ static void CreatePipelines()
VK_LOAD_VERTFRAG_SHADERS(shaders, particle, basic);
vk_drawParticlesPipeline.depthWriteEnable = VK_FALSE;
vk_drawParticlesPipeline.blendOpts.blendEnable = VK_TRUE;
QVk_CreatePipeline(&vk_samplerDescSetLayout, 1, &vertInfoRGB_RGBA_RG, &vk_drawParticlesPipeline, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(&vk_samplerDescSetLayout, 1, &vertInfoRGB_RGBA_RG, &vk_drawParticlesPipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawParticlesPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: textured particles");
QVk_DebugSetObjectName((uint64_t)vk_drawParticlesPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: textured particles");
@ -1244,7 +1232,7 @@ static void CreatePipelines()
vk_drawPointParticlesPipeline.topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
vk_drawPointParticlesPipeline.depthWriteEnable = VK_FALSE;
vk_drawPointParticlesPipeline.blendOpts.blendEnable = VK_TRUE;
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB_RGBA, &vk_drawPointParticlesPipeline, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB_RGBA, &vk_drawPointParticlesPipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawPointParticlesPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: point particles");
QVk_DebugSetObjectName((uint64_t)vk_drawPointParticlesPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: point particles");
@ -1254,7 +1242,7 @@ static void CreatePipelines()
{
vk_drawColorQuadPipeline[i].depthTestEnable = VK_FALSE;
vk_drawColorQuadPipeline[i].blendOpts.blendEnable = VK_TRUE;
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRG, &vk_drawColorQuadPipeline[i], &vk_renderpasses[i], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRG, &vk_drawColorQuadPipeline[i], &vk_renderpasses[i], shaders, 2);
}
QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[0].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: colored quad (RP_WORLD)");
QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[0].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: colored quad (RP_WORLD)");
@ -1265,7 +1253,7 @@ static void CreatePipelines()
VK_LOAD_VERTFRAG_SHADERS(shaders, nullmodel, basic_color_quad);
vk_drawNullModelPipeline.cullMode = VK_CULL_MODE_NONE;
vk_drawNullModelPipeline.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB_RGB, &vk_drawNullModelPipeline, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB_RGB, &vk_drawNullModelPipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawNullModelPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: null model");
QVk_DebugSetObjectName((uint64_t)vk_drawNullModelPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: null model");
@ -1275,11 +1263,11 @@ static void CreatePipelines()
{
vk_drawModelPipelineStrip[i].topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
vk_drawModelPipelineStrip[i].blendOpts.blendEnable = VK_TRUE;
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawModelPipelineStrip[i], &vk_renderpasses[i], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawModelPipelineStrip[i], &vk_renderpasses[i], shaders, 2);
vk_drawModelPipelineFan[i].topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
vk_drawModelPipelineFan[i].blendOpts.blendEnable = VK_TRUE;
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawModelPipelineFan[i], &vk_renderpasses[i], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawModelPipelineFan[i], &vk_renderpasses[i], shaders, 2);
}
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[0].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: draw model: strip (RP_WORLD)");
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[0].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: draw model: strip (RP_WORLD)");
@ -1294,34 +1282,34 @@ static void CreatePipelines()
vk_drawNoDepthModelPipelineStrip.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
vk_drawNoDepthModelPipelineStrip.depthWriteEnable = VK_FALSE;
vk_drawNoDepthModelPipelineStrip.blendOpts.blendEnable = VK_TRUE;
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawNoDepthModelPipelineStrip, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawNoDepthModelPipelineStrip, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawNoDepthModelPipelineStrip.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: translucent model: strip");
QVk_DebugSetObjectName((uint64_t)vk_drawNoDepthModelPipelineStrip.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: translucent model: strip");
vk_drawNoDepthModelPipelineFan.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
vk_drawNoDepthModelPipelineFan.depthWriteEnable = VK_FALSE;
vk_drawNoDepthModelPipelineFan.blendOpts.blendEnable = VK_TRUE;
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawNoDepthModelPipelineFan, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawNoDepthModelPipelineFan, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawNoDepthModelPipelineFan.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: translucent model: fan");
QVk_DebugSetObjectName((uint64_t)vk_drawNoDepthModelPipelineFan.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: translucent model: fan");
// dedicated model pipelines for when left-handed weapon model is drawn
vk_drawLefthandModelPipelineStrip.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
vk_drawLefthandModelPipelineStrip.cullMode = VK_CULL_MODE_FRONT_BIT;
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawLefthandModelPipelineStrip, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawLefthandModelPipelineStrip, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawLefthandModelPipelineStrip.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: left-handed model: strip");
QVk_DebugSetObjectName((uint64_t)vk_drawLefthandModelPipelineStrip.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: left-handed model: strip");
vk_drawLefthandModelPipelineFan.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
vk_drawLefthandModelPipelineFan.cullMode = VK_CULL_MODE_FRONT_BIT;
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawLefthandModelPipelineFan, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawLefthandModelPipelineFan, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawLefthandModelPipelineFan.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: left-handed model: fan");
QVk_DebugSetObjectName((uint64_t)vk_drawLefthandModelPipelineFan.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: left-handed model: fan");
// draw sprite pipeline
VK_LOAD_VERTFRAG_SHADERS(shaders, sprite, basic);
vk_drawSpritePipeline.blendOpts.blendEnable = VK_TRUE;
QVk_CreatePipeline(&vk_samplerDescSetLayout, 1, &vertInfoRGB_RG, &vk_drawSpritePipeline, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(&vk_samplerDescSetLayout, 1, &vertInfoRGB_RG, &vk_drawSpritePipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawSpritePipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: sprite");
QVk_DebugSetObjectName((uint64_t)vk_drawSpritePipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: sprite");
@ -1329,14 +1317,14 @@ static void CreatePipelines()
VK_LOAD_VERTFRAG_SHADERS(shaders, polygon, basic);
vk_drawPolyPipeline.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
vk_drawPolyPipeline.blendOpts.blendEnable = VK_TRUE;
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RG, &vk_drawPolyPipeline, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RG, &vk_drawPolyPipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawPolyPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: polygon");
QVk_DebugSetObjectName((uint64_t)vk_drawPolyPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: polygon");
// draw lightmapped polygon
VK_LOAD_VERTFRAG_SHADERS(shaders, polygon_lmap, polygon_lmap);
vk_drawPolyLmapPipeline.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
QVk_CreatePipeline(samplerUboLmapDsLayouts, 3, &vertInfoRGB_RG_RG, &vk_drawPolyLmapPipeline, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(samplerUboLmapDsLayouts, 3, &vertInfoRGB_RG_RG, &vk_drawPolyLmapPipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawPolyLmapPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: lightmapped polygon");
QVk_DebugSetObjectName((uint64_t)vk_drawPolyLmapPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: lightmapped polygon");
@ -1344,7 +1332,7 @@ static void CreatePipelines()
VK_LOAD_VERTFRAG_SHADERS(shaders, polygon_warp, basic);
vk_drawPolyWarpPipeline.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
vk_drawPolyWarpPipeline.blendOpts.blendEnable = VK_TRUE;
QVk_CreatePipeline(samplerUboLmapDsLayouts, 2, &vertInfoRGB_RG, &vk_drawPolyWarpPipeline, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(samplerUboLmapDsLayouts, 2, &vertInfoRGB_RG, &vk_drawPolyWarpPipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawPolyWarpPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: warped polygon (liquids)");
QVk_DebugSetObjectName((uint64_t)vk_drawPolyWarpPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: warped polygon (liquids)");
@ -1353,13 +1341,13 @@ static void CreatePipelines()
vk_drawBeamPipeline.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
vk_drawBeamPipeline.depthWriteEnable = VK_FALSE;
vk_drawBeamPipeline.blendOpts.blendEnable = VK_TRUE;
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB, &vk_drawBeamPipeline, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB, &vk_drawBeamPipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawBeamPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: beam");
QVk_DebugSetObjectName((uint64_t)vk_drawBeamPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: beam");
// draw skybox pipeline
VK_LOAD_VERTFRAG_SHADERS(shaders, skybox, basic);
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RG, &vk_drawSkyboxPipeline, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RG, &vk_drawSkyboxPipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawSkyboxPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: skybox");
QVk_DebugSetObjectName((uint64_t)vk_drawSkyboxPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: skybox");
@ -1373,7 +1361,7 @@ static void CreatePipelines()
vk_drawDLightPipeline.blendOpts.dstColorBlendFactor = VK_BLEND_FACTOR_ONE;
vk_drawDLightPipeline.blendOpts.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
vk_drawDLightPipeline.blendOpts.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB_RGB, &vk_drawDLightPipeline, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB_RGB, &vk_drawDLightPipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_drawDLightPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: dynamic light");
QVk_DebugSetObjectName((uint64_t)vk_drawDLightPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: dynamic light");
@ -1383,7 +1371,7 @@ static void CreatePipelines()
vk_showTrisPipeline.depthTestEnable = VK_FALSE;
vk_showTrisPipeline.depthWriteEnable = VK_FALSE;
vk_showTrisPipeline.topology = VK_PRIMITIVE_TOPOLOGY_LINE_STRIP;
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB_RGB, &vk_showTrisPipeline, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB_RGB, &vk_showTrisPipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_showTrisPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: show triangles");
QVk_DebugSetObjectName((uint64_t)vk_showTrisPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: show triangles");
@ -1391,13 +1379,13 @@ static void CreatePipelines()
VK_LOAD_VERTFRAG_SHADERS(shaders, shadows, basic_color_quad);
vk_shadowsPipelineStrip.blendOpts.blendEnable = VK_TRUE;
vk_shadowsPipelineStrip.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB, &vk_shadowsPipelineStrip, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB, &vk_shadowsPipelineStrip, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_shadowsPipelineStrip.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: draw shadows: strip");
QVk_DebugSetObjectName((uint64_t)vk_shadowsPipelineStrip.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: draw shadows: strip");
vk_shadowsPipelineFan.blendOpts.blendEnable = VK_TRUE;
vk_shadowsPipelineFan.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB, &vk_shadowsPipelineFan, &vk_renderpasses[RP_WORLD], shaders, 2, &pushConstantRangeVert);
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB, &vk_shadowsPipelineFan, &vk_renderpasses[RP_WORLD], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_shadowsPipelineFan.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: draw shadows: fan");
QVk_DebugSetObjectName((uint64_t)vk_shadowsPipelineFan.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: draw shadows: fan");
@ -1406,7 +1394,7 @@ static void CreatePipelines()
vk_worldWarpPipeline.depthTestEnable = VK_FALSE;
vk_worldWarpPipeline.depthWriteEnable = VK_FALSE;
vk_worldWarpPipeline.cullMode = VK_CULL_MODE_NONE;
QVk_CreatePipeline(&vk_samplerDescSetLayout, 1, &vertInfoNull, &vk_worldWarpPipeline, &vk_renderpasses[RP_WORLD_WARP], shaders, 2, &pushConstantRangeFrag);
QVk_CreatePipeline(&vk_samplerDescSetLayout, 1, &vertInfoNull, &vk_worldWarpPipeline, &vk_renderpasses[RP_WORLD_WARP], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_worldWarpPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: underwater view warp");
QVk_DebugSetObjectName((uint64_t)vk_worldWarpPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: underwater view warp");
@ -1415,7 +1403,7 @@ static void CreatePipelines()
vk_postprocessPipeline.depthTestEnable = VK_FALSE;
vk_postprocessPipeline.depthWriteEnable = VK_FALSE;
vk_postprocessPipeline.cullMode = VK_CULL_MODE_NONE;
QVk_CreatePipeline(&vk_samplerDescSetLayout, 1, &vertInfoNull, &vk_postprocessPipeline, &vk_renderpasses[RP_UI], shaders, 2, &pushConstantRangeFrag);
QVk_CreatePipeline(&vk_samplerDescSetLayout, 1, &vertInfoNull, &vk_postprocessPipeline, &vk_renderpasses[RP_UI], shaders, 2);
QVk_DebugSetObjectName((uint64_t)vk_postprocessPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: world postprocess");
QVk_DebugSetObjectName((uint64_t)vk_postprocessPipeline.pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: world postprocess");
@ -2369,12 +2357,10 @@ void QVk_DrawTexRect(const float *ubo, VkDeviceSize uboSize, qvktexture_t *textu
VkDeviceSize offsets = 0;
VkDescriptorSet descriptorSets[] = { texture->descriptorSet, uboDescriptorSet };
float fragment_constants[17] = {0};
memcpy(fragment_constants, r_viewproj_matrix, sizeof(r_viewproj_matrix));
fragment_constants[16] = 2.1F - vid_gamma->value;
float gamma = 2.1F - vid_gamma->value;
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(fragment_constants), &fragment_constants);
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawTexQuadPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset);
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1,

View file

@ -49,7 +49,7 @@ qvkshader_t QVk_CreateShader(const uint32_t *shaderSrc, size_t shaderCodeSize, V
}
void QVk_CreatePipeline(const VkDescriptorSetLayout *descriptorLayout, const uint32_t descLayoutCount, const VkPipelineVertexInputStateCreateInfo *vertexInputInfo,
qvkpipeline_t *pipeline, const qvkrenderpass_t *renderpass, const qvkshader_t *shaders, uint32_t shaderCount, VkPushConstantRange *pcRange)
qvkpipeline_t *pipeline, const qvkrenderpass_t *renderpass, const qvkshader_t *shaders, uint32_t shaderCount)
{
VkPipelineShaderStageCreateInfo *ssCreateInfos = (VkPipelineShaderStageCreateInfo *)malloc(shaderCount * sizeof(VkPipelineShaderStageCreateInfo));
for (int i = 0; i < shaderCount; i++)
@ -156,14 +156,29 @@ void QVk_CreatePipeline(const VkDescriptorSetLayout *descriptorLayout, const uin
.pDynamicStates = dynamicStates
};
// push constant sizes accomodate for maximum number of uploaded elements (should probably be checked against the hardware's maximum supported value)
VkPushConstantRange pushConstantRange[] = {
{
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
.offset = 0,
.size = 17 * sizeof(float)
},
{
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
.offset = 17 * sizeof(float),
.size = 4 * sizeof(float)
}};
VkPipelineLayoutCreateInfo plCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.setLayoutCount = descLayoutCount,
.pSetLayouts = descriptorLayout,
.pushConstantRangeCount = pcRange ? 1 : 0, // for simplicity assume only one push constant range is passed, so it's not the most flexible approach
.pPushConstantRanges = pcRange
// for simplicity assume only two push constant range is passed,
// so it's not the most flexible approach
.pushConstantRangeCount = 2,
.pPushConstantRanges = pushConstantRange
};
VK_VERIFY(vkCreatePipelineLayout(vk_device.logical, &plCreateInfo, NULL, &pipeline->layout));

View file

@ -231,12 +231,10 @@ void R_DrawSpriteModel (entity_t *e)
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
float fragment_constants[17] = {0};
memcpy(fragment_constants, r_viewproj_matrix, sizeof(r_viewproj_matrix));
fragment_constants[16] = 2.1F - vid_gamma->value;
float gamma = 2.1F - vid_gamma->value;
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawSpritePipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(fragment_constants), &fragment_constants);
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawSpritePipeline.layout, 0, 1, &currentmodel->skins[e->frame]->vk_texture.descriptorSet, 0, NULL);
vkCmdDraw(vk_activeCmdbuffer, 6, 1, 0, 0);
@ -495,12 +493,10 @@ void Vk_DrawParticles(int num_particles, const particle_t particles[], const uns
uint8_t *vertData = QVk_GetVertexBuffer((currentvertex - visibleParticles) * sizeof(pvertex), &vbo, &vboOffset);
memcpy(vertData, &visibleParticles, (currentvertex - visibleParticles) * sizeof(pvertex));
float fragment_constants[17] = {0};
memcpy(fragment_constants, r_viewproj_matrix, sizeof(r_viewproj_matrix));
fragment_constants[16] = 2.1F - vid_gamma->value;
float gamma = 2.1F - vid_gamma->value;
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawParticlesPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(fragment_constants), &fragment_constants);
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
if (particle_square)
{
@ -994,7 +990,8 @@ qboolean RE_EndWorldRenderpass(void)
// apply postprocessing effects (underwater view warp if the player is submerged in liquid) to offscreen buffer
QVk_BeginRenderpass(RP_WORLD_WARP);
float pushConsts[] = { (r_newrefdef.rdflags & RDF_UNDERWATER) ? r_newrefdef.time : 0.f, viewsize->value / 100, vid.width, vid.height };
vkCmdPushConstants(vk_activeCmdbuffer, vk_worldWarpPipeline.layout, VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(pushConsts), pushConsts);
vkCmdPushConstants(vk_activeCmdbuffer, vk_worldWarpPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(pushConsts), pushConsts);
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_worldWarpPipeline.layout, 0, 1, &vk_colorbuffer.descriptorSet, 0, NULL);
QVk_BindPipeline(&vk_worldWarpPipeline);
vkCmdDraw(vk_activeCmdbuffer, 3, 1, 0, 0);
@ -1022,7 +1019,8 @@ static void R_SetVulkan2D (const VkViewport* viewport, const VkRect2D* scissor)
if (!(r_newrefdef.rdflags & RDF_NOWORLDMODEL))
{
float pushConsts[] = { vk_postprocess->value, (2.1 - vid_gamma->value)};
vkCmdPushConstants(vk_activeCmdbuffer, vk_postprocessPipeline.layout, VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(pushConsts), pushConsts);
vkCmdPushConstants(vk_activeCmdbuffer, vk_postprocessPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(pushConsts), pushConsts);
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_postprocessPipeline.layout, 0, 1, &vk_colorbufferWarp.descriptorSet, 0, NULL);
QVk_BindPipeline(&vk_postprocessPipeline);
vkCmdDraw(vk_activeCmdbuffer, 3, 1, 0, 0);

View file

@ -133,12 +133,10 @@ static void DrawVkPoly (vkpoly_t *p, image_t *texture, float *color)
VkDescriptorSet descriptorSets[] = { texture->vk_texture.descriptorSet, uboDescriptorSet };
float fragment_constants[17] = {0};
memcpy(fragment_constants, r_viewproj_matrix, sizeof(r_viewproj_matrix));
fragment_constants[16] = 2.1F - vid_gamma->value;
float gamma = 2.1F - vid_gamma->value;
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawPolyPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(fragment_constants), &fragment_constants);
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset);
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
@ -196,12 +194,10 @@ static void DrawVkFlowingPoly (msurface_t *fa, image_t *texture, float *color)
VkDescriptorSet descriptorSets[] = { texture->vk_texture.descriptorSet, uboDescriptorSet };
float fragment_constants[17] = {0};
memcpy(fragment_constants, r_viewproj_matrix, sizeof(r_viewproj_matrix));
fragment_constants[16] = 2.1F - vid_gamma->value;
float gamma = 2.1F - vid_gamma->value;
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawPolyPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(fragment_constants), &fragment_constants);
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset);
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);

View file

@ -252,12 +252,10 @@ void EmitWaterPolys (msurface_t *fa, image_t *texture, float *modelMatrix, float
VkDeviceSize vboOffset;
VkDescriptorSet descriptorSets[] = { texture->vk_texture.descriptorSet, uboDescriptorSet };
float fragment_constants[17] = {0};
memcpy(fragment_constants, r_viewproj_matrix, sizeof(r_viewproj_matrix));
fragment_constants[16] = 2.1F - vid_gamma->value;
float gamma = 2.1F - vid_gamma->value;
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawPolyWarpPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(fragment_constants), &fragment_constants);
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyWarpPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset);
@ -649,12 +647,10 @@ void R_DrawSkyBox (void)
VkDescriptorSet descriptorSets[] = { sky_images[skytexorder[i]]->vk_texture.descriptorSet, uboDescriptorSet };
float fragment_constants[17] = {0};
memcpy(fragment_constants, r_viewproj_matrix, sizeof(r_viewproj_matrix));
fragment_constants[16] = 2.1F - vid_gamma->value;
float gamma = 2.1F - vid_gamma->value;
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawSkyboxPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(fragment_constants), &fragment_constants);
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
vk_drawSkyboxPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset);

View file

@ -2,8 +2,8 @@
layout(push_constant) uniform PushConstant
{
mat4 vpMatrix;
float gamma;
// vertex shader has 'mat4 vpMatrix;' at begin.
layout(offset = 68) float gamma;
} pc;
layout(set = 0, binding = 0) uniform sampler2D sTexture;

View file

@ -3,8 +3,8 @@
layout(push_constant) uniform PushConstant
{
float postprocess;
float gamma;
layout(offset = 68) float postprocess;
layout(offset = 72) float gamma;
} pc;
layout(set = 0, binding = 0) uniform sampler2D sTexture;
@ -12,7 +12,7 @@ layout(set = 0, binding = 0) uniform sampler2D sTexture;
layout(location = 0) in vec2 texCoord;
layout(location = 0) out vec4 fragmentColor;
void main()
void main()
{
// apply any additional world-only postprocessing effects here (if enabled)
if (pc.postprocess > 0.0)

View file

@ -5,10 +5,10 @@
layout(push_constant) uniform PushConstant
{
float time;
float scale;
float scrWidth;
float scrHeight;
layout(offset = 68) float time;
layout(offset = 72) float scale;
layout(offset = 76) float scrWidth;
layout(offset = 80) float scrHeight;
} pc;
layout(set = 0, binding = 0) uniform sampler2D sTexture;