rendervulkan: Stop using unnormalized ycbcr samplers.

This is not allowed for ycbcr samplers.
This commit is contained in:
Georg Lehmann 2021-12-19 15:58:39 +01:00 committed by Joshua Ashton
parent 73025b24e2
commit ca09577632
2 changed files with 6 additions and 4 deletions

View file

@ -70,7 +70,7 @@ void compositing_debug(uvec2 size, uvec2 coord) {
} }
} }
vec4 sampleLayer(sampler2D layerSampler, uint layerIdx, vec2 uv) { vec4 sampleLayer(sampler2D layerSampler, uint layerIdx, vec2 uv, bool unnormalized) {
vec2 coord = ((uv + u_offset[layerIdx]) * u_scale[layerIdx]); vec2 coord = ((uv + u_offset[layerIdx]) * u_scale[layerIdx]);
vec2 texSize = textureSize(layerSampler, 0); vec2 texSize = textureSize(layerSampler, 0);
@ -80,13 +80,16 @@ vec4 sampleLayer(sampler2D layerSampler, uint layerIdx, vec2 uv) {
return vec4(0.0f, 0.0f, 0.0f, border); return vec4(0.0f, 0.0f, 0.0f, border);
} }
if (!unnormalized)
coord /= texSize;
return textureLod(layerSampler, coord, 0.0f); return textureLod(layerSampler, coord, 0.0f);
} }
vec4 sampleLayer(uint layerIdx, vec2 uv) { vec4 sampleLayer(uint layerIdx, vec2 uv) {
if ((c_ycbcrMask & (1 << layerIdx)) != 0) if ((c_ycbcrMask & (1 << layerIdx)) != 0)
return srgbToLinear(sampleLayer(s_ycbcr_samplers[layerIdx], layerIdx, uv)); return srgbToLinear(sampleLayer(s_ycbcr_samplers[layerIdx], layerIdx, uv, false));
return sampleLayer(s_samplers[layerIdx], layerIdx, uv); return sampleLayer(s_samplers[layerIdx], layerIdx, uv, true);
} }
void main() { void main() {

View file

@ -1228,7 +1228,6 @@ retry:
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, .addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, .addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK, .borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK,
.unnormalizedCoordinates = VK_TRUE,
}; };
vkCreateSampler( device, &ycbcrSamplerInfo, nullptr, &ycbcrSampler ); vkCreateSampler( device, &ycbcrSamplerInfo, nullptr, &ycbcrSampler );