Skip to content

Commit

Permalink
Correct use of nonuniformEXT()
Browse files Browse the repository at this point in the history
  • Loading branch information
corporateshark committed May 6, 2024
1 parent cb9145b commit 2eeed36
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lvk/vulkan/VulkanClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4011,6 +4011,8 @@ lvk::ShaderModuleState lvk::VulkanContext::createShaderModuleFromGLSL(ShaderStag
)";
}
if (vkStage == VK_SHADER_STAGE_FRAGMENT_BIT) {
// Note how nonuniformEXT() should be used:
// https://github.com/KhronosGroup/Vulkan-Samples/blob/main/shaders/descriptor_indexing/nonuniform-quads.frag#L33-L39
sourcePatched += R"(
#version 460
#extension GL_EXT_buffer_reference_uvec2 : require
Expand All @@ -4025,29 +4027,27 @@ lvk::ShaderModuleState lvk::VulkanContext::createShaderModuleFromGLSL(ShaderStag
layout (set = 3, binding = 0) uniform texture2D kTextures2DShadow[];
layout (set = 0, binding = 1) uniform sampler kSamplers[];
layout (set = 3, binding = 1) uniform samplerShadow kSamplersShadow[];
)";
sourcePatched += R"(
vec4 textureBindless2D(uint textureid, uint samplerid, vec2 uv) {
return texture(sampler2D(kTextures2D[textureid], kSamplers[samplerid]), uv);
return texture(nonuniformEXT(sampler2D(kTextures2D[textureid], kSamplers[samplerid])), uv);
}
vec4 textureBindless2DLod(uint textureid, uint samplerid, vec2 uv, float lod) {
return textureLod(sampler2D(kTextures2D[textureid], kSamplers[samplerid]), uv, lod);
return textureLod(nonuniformEXT(sampler2D(kTextures2D[textureid], kSamplers[samplerid])), uv, lod);
}
float textureBindless2DShadow(uint textureid, uint samplerid, vec3 uvw) {
return texture(sampler2DShadow(kTextures2DShadow[textureid], kSamplersShadow[samplerid]), uvw);
return texture(nonuniformEXT(sampler2DShadow(kTextures2DShadow[textureid], kSamplersShadow[samplerid])), uvw);
}
ivec2 textureBindlessSize2D(uint textureid) {
return textureSize(kTextures2D[textureid], 0);
return textureSize(nonuniformEXT(kTextures2D[textureid]), 0);
}
vec4 textureBindlessCube(uint textureid, uint samplerid, vec3 uvw) {
return texture(samplerCube(kTexturesCube[textureid], kSamplers[samplerid]), uvw);
return texture(nonuniformEXT(samplerCube(kTexturesCube[textureid], kSamplers[samplerid])), uvw);
}
vec4 textureBindlessCubeLod(uint textureid, uint samplerid, vec3 uvw, float lod) {
return textureLod(samplerCube(kTexturesCube[textureid], kSamplers[samplerid]), uvw, lod);
return textureLod(nonuniformEXT(samplerCube(kTexturesCube[textureid], kSamplers[samplerid])), uvw, lod);
}
int textureBindlessQueryLevels2D(uint textureid) {
return textureQueryLevels(kTextures2D[textureid]);
return textureQueryLevels(nonuniformEXT(kTextures2D[textureid]));
}
)";
}
Expand Down

0 comments on commit 2eeed36

Please sign in to comment.