Skip to content

rtx: cleanup repetitive implementation of texture lookups#342

Closed
jeffamstutz wants to merge 1 commit into
next_releasefrom
texture_eval_cleanup
Closed

rtx: cleanup repetitive implementation of texture lookups#342
jeffamstutz wants to merge 1 commit into
next_releasefrom
texture_eval_cleanup

Conversation

@jeffamstutz

Copy link
Copy Markdown
Collaborator

No description provided.

@jeffamstutz
jeffamstutz requested a review from tarcila July 16, 2026 02:40
@jeffamstutz
jeffamstutz force-pushed the texture_eval_cleanup branch from c09b8cd to 85ce5c4 Compare July 16, 2026 02:42
@jeffamstutz
jeffamstutz force-pushed the texture_eval_cleanup branch from 85ce5c4 to 5ff7827 Compare July 16, 2026 02:45

@tarcila tarcila left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)*/);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that we will be applying the transforms and offsets twice, to be double-checked.

@jeffamstutz

Copy link
Copy Markdown
Collaborator Author

I see why it is the way it is now, I'll close this as it's not immediately obvious what could be done.

@jeffamstutz
jeffamstutz deleted the texture_eval_cleanup branch July 16, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants