From bdd715ee5cc155b8e14cf869a29a74659148f14b Mon Sep 17 00:00:00 2001 From: Ricardo Garcia Date: Tue, 23 Feb 2021 22:07:32 +0100 Subject: [PATCH] Fix validation errors with unnormalized samplers When using samplers with unnormalized coordinates in Vulkan, the shaders must specify the LOD explicitly. --- .../refresh/vk/spirv/postprocess_frag.c | 26 +++++++++---------- src/client/refresh/vk/spirv/world_warp_frag.c | 5 ++-- stuff/shaders/postprocess.frag | 4 +-- stuff/shaders/world_warp.frag | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/client/refresh/vk/spirv/postprocess_frag.c b/src/client/refresh/vk/spirv/postprocess_frag.c index c2ecf1b9..7196d32e 100644 --- a/src/client/refresh/vk/spirv/postprocess_frag.c +++ b/src/client/refresh/vk/spirv/postprocess_frag.c @@ -48,17 +48,17 @@ const uint32_t postprocess_frag_spv[] = { 0x00000012,0x00000023,0x0000000f,0x00000022,0x0004003d,0x00000006,0x00000024,0x00000023, 0x000500ba,0x00000026,0x00000027,0x00000024,0x00000025,0x000300f7,0x00000029,0x00000000, 0x000400fa,0x00000027,0x00000028,0x00000042,0x000200f8,0x00000028,0x0004003d,0x0000002e, - 0x00000031,0x00000030,0x0004003d,0x00000007,0x00000032,0x00000009,0x00050057,0x0000002a, - 0x00000033,0x00000031,0x00000032,0x0008004f,0x00000034,0x00000035,0x00000033,0x00000033, - 0x00000000,0x00000001,0x00000002,0x0005008e,0x00000034,0x00000037,0x00000035,0x00000036, - 0x00050041,0x00000012,0x00000039,0x0000000f,0x00000038,0x0004003d,0x00000006,0x0000003a, - 0x00000039,0x00060050,0x00000034,0x0000003b,0x0000003a,0x0000003a,0x0000003a,0x0007000c, - 0x00000034,0x0000003c,0x00000001,0x0000001a,0x00000037,0x0000003b,0x00050051,0x00000006, - 0x0000003e,0x0000003c,0x00000000,0x00050051,0x00000006,0x0000003f,0x0000003c,0x00000001, - 0x00050051,0x00000006,0x00000040,0x0000003c,0x00000002,0x00070050,0x0000002a,0x00000041, - 0x0000003e,0x0000003f,0x00000040,0x0000003d,0x0003003e,0x0000002c,0x00000041,0x000200f9, - 0x00000029,0x000200f8,0x00000042,0x0004003d,0x0000002e,0x00000043,0x00000030,0x0004003d, - 0x00000007,0x00000044,0x00000009,0x00050057,0x0000002a,0x00000045,0x00000043,0x00000044, - 0x0003003e,0x0000002c,0x00000045,0x000200f9,0x00000029,0x000200f8,0x00000029,0x000100fd, - 0x00010038 + 0x00000031,0x00000030,0x0004003d,0x00000007,0x00000032,0x00000009,0x00070058,0x0000002a, + 0x00000033,0x00000031,0x00000032,0x00000002,0x00000025,0x0008004f,0x00000034,0x00000035, + 0x00000033,0x00000033,0x00000000,0x00000001,0x00000002,0x0005008e,0x00000034,0x00000037, + 0x00000035,0x00000036,0x00050041,0x00000012,0x00000039,0x0000000f,0x00000038,0x0004003d, + 0x00000006,0x0000003a,0x00000039,0x00060050,0x00000034,0x0000003b,0x0000003a,0x0000003a, + 0x0000003a,0x0007000c,0x00000034,0x0000003c,0x00000001,0x0000001a,0x00000037,0x0000003b, + 0x00050051,0x00000006,0x0000003e,0x0000003c,0x00000000,0x00050051,0x00000006,0x0000003f, + 0x0000003c,0x00000001,0x00050051,0x00000006,0x00000040,0x0000003c,0x00000002,0x00070050, + 0x0000002a,0x00000041,0x0000003e,0x0000003f,0x00000040,0x0000003d,0x0003003e,0x0000002c, + 0x00000041,0x000200f9,0x00000029,0x000200f8,0x00000042,0x0004003d,0x0000002e,0x00000043, + 0x00000030,0x0004003d,0x00000007,0x00000044,0x00000009,0x00070058,0x0000002a,0x00000045, + 0x00000043,0x00000044,0x00000002,0x00000025,0x0003003e,0x0000002c,0x00000045,0x000200f9, + 0x00000029,0x000200f8,0x00000029,0x000100fd,0x00010038 }; \ No newline at end of file diff --git a/src/client/refresh/vk/spirv/world_warp_frag.c b/src/client/refresh/vk/spirv/world_warp_frag.c index 736ef253..0f6ba662 100644 --- a/src/client/refresh/vk/spirv/world_warp_frag.c +++ b/src/client/refresh/vk/spirv/world_warp_frag.c @@ -148,6 +148,7 @@ const uint32_t world_warp_frag_spv[] = { 0x000000b0,0x0004003d,0x00000007,0x000000b3,0x00000009,0x00050083,0x00000007,0x000000b6, 0x000000b3,0x000000b5,0x0008000c,0x00000007,0x000000b7,0x00000001,0x0000002b,0x000000b1, 0x000000b2,0x000000b6,0x0003003e,0x00000024,0x000000b7,0x0004003d,0x000000bb,0x000000be, - 0x000000bd,0x0004003d,0x00000007,0x000000bf,0x00000024,0x00050057,0x00000017,0x000000c0, - 0x000000be,0x000000bf,0x0003003e,0x000000b9,0x000000c0,0x000100fd,0x00010038 + 0x000000bd,0x0004003d,0x00000007,0x000000bf,0x00000024,0x00070058,0x00000017,0x000000c0, + 0x000000be,0x000000bf,0x00000002,0x00000043,0x0003003e,0x000000b9,0x000000c0,0x000100fd, + 0x00010038 }; \ No newline at end of file diff --git a/stuff/shaders/postprocess.frag b/stuff/shaders/postprocess.frag index 2d53d593..879b555f 100644 --- a/stuff/shaders/postprocess.frag +++ b/stuff/shaders/postprocess.frag @@ -24,10 +24,10 @@ void main() if (pc.postprocess > 0.0) { //gamma + color intensity bump - fragmentColor = vec4(pow(texture(sTexture, unnormTexCoord).rgb * 1.5, vec3(pc.gamma)), 1.0); + fragmentColor = vec4(pow(textureLod(sTexture, unnormTexCoord, 0.0).rgb * 1.5, vec3(pc.gamma)), 1.0); } else { - fragmentColor = texture(sTexture, unnormTexCoord); + fragmentColor = textureLod(sTexture, unnormTexCoord, 0.0); } } diff --git a/stuff/shaders/world_warp.frag b/stuff/shaders/world_warp.frag index 2f1edf22..cbbeea19 100644 --- a/stuff/shaders/world_warp.frag +++ b/stuff/shaders/world_warp.frag @@ -51,5 +51,5 @@ void main() uv = clamp(uv * scrSize, vec2(0.0, 0.0), scrSize - vec2(0.5, 0.5)); - fragmentColor = texture(sTexture, uv); + fragmentColor = textureLod(sTexture, uv, 0.0); }