rtx: cleanup repetitive implementation of texture lookups#342
rtx: cleanup repetitive implementation of texture lookups#342jeffamstutz wants to merge 1 commit into
Conversation
c09b8cd to
85ce5c4
Compare
85ce5c4 to
5ff7827
Compare
tarcila
left a comment
There was a problem hiding this comment.
Maybe the texture sampling code should be factorized around a single:
vec4 sampleImageTex(const SamplerGPUData &sampler, vec4 tc, bool texel)
(or some template version of that to ensure the texel case is handled at compile time)?
Ensuring that the right sampler is being used and the alpha channel adjustment is applied in that help, then the rest of the functions are as usual (pre and post transform application)
| retval.w = 1.0f; | ||
|
|
||
| return sampler.outTransform * retval + sampler.outOffset; | ||
| return evaluateImageTextureSampler(sampler, vec4(at) /*+ vec4(0.5f)*/); |
There was a problem hiding this comment.
This code now hits a different sampler, texobj (normalized-coordinates, linear) instead of the expected texelTexobj (non-normalized coordinates, nearest interpolation).
This breaks texel sampling (used solely by MDL as of today)
The commented +0.5f is not required as the target sampler is non-normalized, nearest and always get exact integer coordinates. Could be cheap safety net if we ever tweak the sampler later, but strictly not necessary today.
| case SamplerType::TEXTURE3D: { | ||
| retval = | ||
| make_vec4(tex3D<::float4>(sampler.image3D.texobj, tc.x, tc.y, tc.z)); | ||
| retval = evaluateImageTextureSampler(sampler, tc); |
There was a problem hiding this comment.
Seems that we will be applying the transforms and offsets twice, to be double-checked.
|
I see why it is the way it is now, I'll close this as it's not immediately obvious what could be done. |
No description provided.