From c0351af854133e55592edc4d0e407cec10c50d42 Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Tue, 27 Aug 2024 21:53:51 +0200 Subject: [PATCH] Vulkan shader fixes --- libraries/gpu-vk/src/gpu/vk/VKBackend.cpp | 2 +- libraries/gpu/src/gpu/Batch.cpp | 3 +-- libraries/gpu/src/gpu/Inputs.slh | 2 +- libraries/render-utils/src/LightAmbient.slh | 2 +- libraries/render-utils/src/ssao_bilateralBlur.slf | 2 +- libraries/render-utils/src/ssao_gather.slf | 2 +- libraries/vk/src/vk/Pipelines.h | 4 ++-- tools/gpu-frame-player/src/RenderThread.cpp | 2 +- 8 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libraries/gpu-vk/src/gpu/vk/VKBackend.cpp b/libraries/gpu-vk/src/gpu/vk/VKBackend.cpp index c865d25016..b2b4344ded 100644 --- a/libraries/gpu-vk/src/gpu/vk/VKBackend.cpp +++ b/libraries/gpu-vk/src/gpu/vk/VKBackend.cpp @@ -301,7 +301,7 @@ struct Cache { #endif VkPipelineLayoutCreateInfo pipelineLayoutCI = vks::initializers::pipelineLayoutCreateInfo(layouts.data(), (uint32_t)layouts.size()); VkPipelineLayout pipelineLayout; - vkCreatePipelineLayout(context.device->logicalDevice, &pipelineLayoutCI, nullptr, &pipelineLayout); + VK_CHECK_RESULT(vkCreatePipelineLayout(context.device->logicalDevice, &pipelineLayoutCI, nullptr, &pipelineLayout)); return _layoutMap[this->pipeline] = pipelineLayout; //return _layoutMap[this->pipeline] = nullptr; } diff --git a/libraries/gpu/src/gpu/Batch.cpp b/libraries/gpu/src/gpu/Batch.cpp index 6396ea531d..c834f52d5f 100644 --- a/libraries/gpu/src/gpu/Batch.cpp +++ b/libraries/gpu/src/gpu/Batch.cpp @@ -130,7 +130,6 @@ void Batch::setDrawcallUniformReset(uint16_t uniformReset) { //#pragma optimize("", off) void Batch::validateDrawState() const { - return; if (!_currentPipeline) { qCWarning(gpulogging) << "Missing pipeline during draw call"; } @@ -151,7 +150,7 @@ void Batch::validateDrawState() const { continue; } if (!_currentStreamFormat || (0 == _currentStreamFormat->getAttributes().count(slot))) { - qCWarning(gpulogging) << "Vertex shader expects slot " << slot << " which is not proveded"; + qCWarning(gpulogging) << "Vertex shader expects slot " << slot << " which is not provided"; } } } diff --git a/libraries/gpu/src/gpu/Inputs.slh b/libraries/gpu/src/gpu/Inputs.slh index 0af51ac345..c5e181a994 100644 --- a/libraries/gpu/src/gpu/Inputs.slh +++ b/libraries/gpu/src/gpu/Inputs.slh @@ -18,7 +18,7 @@ INPUT(GPU_ATTR_NORMAL, vec4, inNormal); INPUT(GPU_ATTR_COLOR, vec4, inColor); INPUT(GPU_ATTR_TEXCOORD0, vec4, inTexCoord0); INPUT(GPU_ATTR_TANGENT, vec4, inTangent); -INPUT(GPU_ATTR_SKIN_CLUSTER_INDEX, ivec4, inSkinClusterIndex); +INPUT(GPU_ATTR_SKIN_CLUSTER_INDEX, uvec4, inSkinClusterIndex); INPUT(GPU_ATTR_SKIN_CLUSTER_WEIGHT, vec4, inSkinClusterWeight); INPUT(GPU_ATTR_TEXCOORD1, vec4, inTexCoord1); INPUT(GPU_ATTR_TEXCOORD2, vec4, inTexCoord2); diff --git a/libraries/render-utils/src/LightAmbient.slh b/libraries/render-utils/src/LightAmbient.slh index 1bf92b02e0..03122e4140 100644 --- a/libraries/render-utils/src/LightAmbient.slh +++ b/libraries/render-utils/src/LightAmbient.slh @@ -28,7 +28,7 @@ vec4 evalSkyboxLight(vec3 direction, float lod) { <@endfunc@> <@func declareEvalAmbientSpecularIrradiance(supportAmbientSphere, supportAmbientMap, supportIfAmbientMapElseAmbientSphere)@> -LAYOUT(binding=RENDER_UTILS_TEXTURE_AMBIENT_FRESNEL) uniform sampler2D ambientFresnelLUT; +TEXTURE(RENDER_UTILS_TEXTURE_AMBIENT_FRESNEL, sampler2D, ambientFresnelLUT); vec3 fresnelSchlickAmbient(vec3 fresnelColor, float ndotd, float roughness) { #if RENDER_UTILS_ENABLE_AMBIENT_FRESNEL_LUT diff --git a/libraries/render-utils/src/ssao_bilateralBlur.slf b/libraries/render-utils/src/ssao_bilateralBlur.slf index 52e7356e85..10a54bc534 100644 --- a/libraries/render-utils/src/ssao_bilateralBlur.slf +++ b/libraries/render-utils/src/ssao_bilateralBlur.slf @@ -20,7 +20,7 @@ <$declarePackOcclusionDepth()$> // the source occlusion texture -LAYOUT(binding=RENDER_UTILS_TEXTURE_SSAO_OCCLUSION) uniform sampler2D occlusionMap; +TEXTURE(RENDER_UTILS_TEXTURE_SSAO_OCCLUSION, sampler2D, occlusionMap); LAYOUT(binding=RENDER_UTILS_BUFFER_SSAO_BLUR_PARAMS) uniform blurParamsBuffer { AmbientOcclusionBlurParams blurParams; diff --git a/libraries/render-utils/src/ssao_gather.slf b/libraries/render-utils/src/ssao_gather.slf index 3e3b8e9120..43fd679555 100644 --- a/libraries/render-utils/src/ssao_gather.slf +++ b/libraries/render-utils/src/ssao_gather.slf @@ -18,7 +18,7 @@ <$declareAmbientOcclusion()$> // the source occlusion texture -LAYOUT(binding=RENDER_UTILS_TEXTURE_SSAO_OCCLUSION) uniform sampler2DArray occlusionMaps; +TEXTURE(RENDER_UTILS_TEXTURE_SSAO_OCCLUSION, sampler2DArray, occlusionMaps); layout(location=0) out vec4 outFragColor; diff --git a/libraries/vk/src/vk/Pipelines.h b/libraries/vk/src/vk/Pipelines.h index e2db6f2fa6..011b427717 100644 --- a/libraries/vk/src/vk/Pipelines.h +++ b/libraries/vk/src/vk/Pipelines.h @@ -145,7 +145,7 @@ namespace vks { } const VkDevice& device; - VkPipelineCache pipelineCache; + VkPipelineCache pipelineCache{ VK_NULL_HANDLE }; // TODO: Add pipeline cache here // TODO: is this initialized properly VkRenderPass& renderPass { pipelineCreateInfo.renderPass }; VkPipelineLayout& layout { pipelineCreateInfo.layout }; @@ -182,7 +182,7 @@ namespace vks { VkPipeline create(const VkPipelineCache& cache) { update(); VkPipeline vkPipeline; - vkCreateGraphicsPipelines(device, cache, 1, &pipelineCreateInfo, nullptr, &vkPipeline); + VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, cache, 1, &pipelineCreateInfo, nullptr, &vkPipeline)); return vkPipeline; } diff --git a/tools/gpu-frame-player/src/RenderThread.cpp b/tools/gpu-frame-player/src/RenderThread.cpp index e0bc7cc55b..a84f60bbf3 100644 --- a/tools/gpu-frame-player/src/RenderThread.cpp +++ b/tools/gpu-frame-player/src/RenderThread.cpp @@ -256,7 +256,7 @@ void RenderThread::renderFrame(gpu::FramePointer& frame) { submitInfo.signalSemaphoreCount = 1; submitInfo.pSignalSemaphores = &renderComplete; submitInfo.commandBufferCount = 1; - VkFenceCreateInfo fenceCI{}; + VkFenceCreateInfo fenceCI = vks::initializers::fenceCreateInfo(); VkFence frameFence; vkCreateFence(_vkcontext.device->logicalDevice, &fenceCI, nullptr, &frameFence); vkQueueSubmit(_vkcontext.queue, 1, &submitInfo, frameFence);