gpu renderer: always pass tex_coord to fragment shader

As suggested in #14843, pass vertex tex_coord to vertex shader and to fragment shader even when no texture is bounded so they can be used by custom fragment shaders.
This commit is contained in:
Void Star Caster
2026-01-16 23:50:04 +01:00
committed by Sam Lantinga
parent 15ceaffcb5
commit b1aaa41921
6 changed files with 410 additions and 351 deletions

View File

@@ -665,7 +665,7 @@ static bool GPU_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SD
int i;
int count = indices ? num_indices : num_vertices;
float *verts;
size_t sz = 2 * sizeof(float) + 4 * sizeof(float) + (texture ? 2 : 0) * sizeof(float);
size_t sz = 2 * sizeof(float) + 4 * sizeof(float) + 2 * sizeof(float);
bool convert_color = SDL_RenderingLinearSpace(renderer);
verts = (float *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
@@ -705,10 +705,13 @@ static bool GPU_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SD
*(verts++) = col_.b;
*(verts++) = col_.a;
if (texture) {
if (uv) {
float *uv_ = (float *)((char *)uv + j * uv_stride);
*(verts++) = uv_[0];
*(verts++) = uv_[1];
} else {
*(verts++) = 0.0f;
*(verts++) = 0.0f;
}
}
return true;