Commit: 95a1d854ee4745a9b11d3bda1109dd9549fcf006
Parent: b5aca30273a410da0b2109f2bde09ad5b0a127df
Author: Randy Palamar
Date: Wed, 2 Oct 2024 13:25:45 -0600
drop remaining useless sampler/image uniform setting
Diffstat:
4 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/beamformer.c b/beamformer.c
@@ -27,7 +27,6 @@ alloc_output_image(BeamformerCtx *ctx)
* this is shared between compute and fragment shaders */
uv4 odim = ctx->out_data_dim;
u32 max_dim = MAX(odim.x, MAX(odim.y, odim.z));
- ctx->out_texture_unit = 0;
ctx->out_texture_mips = _tzcnt_u32(max_dim) + 1;
glActiveTexture(GL_TEXTURE0);
@@ -160,8 +159,6 @@ do_volume_computation_step(BeamformerCtx *ctx, enum compute_shaders shader)
glBindBufferBase(GL_UNIFORM_BUFFER, 0, cs->shared_ubo);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, e->rf_data_ssbo);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_3D, e->volume_texture);
glBindImageTexture(0, e->volume_texture, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R32F);
glUniform1i(cs->volume_export_pass_id, 1);
@@ -274,7 +271,6 @@ do_compute_shader(BeamformerCtx *ctx, enum compute_shaders shader)
glUniform3iv(csctx->volume_export_dim_offset_id, 1, (i32 []){0, 0, 0});
glUniform1i(csctx->volume_export_pass_id, 0);
- glActiveTexture(GL_TEXTURE0 + ctx->out_texture_unit);
for (u32 i = 0; i < bp->array_count; i++) {
u32 texture;
if (bp->array_count == 1) {
@@ -291,9 +287,7 @@ do_compute_shader(BeamformerCtx *ctx, enum compute_shaders shader)
bp->xdc_origin[i].xyz,
bp->xdc_corner1[i].xyz,
bp->xdc_corner2[i].xyz);
- glBindTexture(GL_TEXTURE_3D, texture);
- glBindImageTexture(ctx->out_texture_unit, texture, 0, GL_TRUE, 0,
- GL_WRITE_ONLY, GL_RG32F);
+ glBindImageTexture(0, texture, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_RG32F);
glUniform1i(csctx->xdc_index_id, i);
glUniformMatrix3fv(csctx->xdc_transform_id, 1, GL_FALSE, xdc_transform.E);
glDispatchCompute(ORONE(ctx->out_data_dim.x / 32),
@@ -480,9 +474,7 @@ do_beamformer(BeamformerCtx *ctx, Arena arena)
BeginShaderMode(ctx->fsctx.shader);
FragmentShaderCtx *fs = &ctx->fsctx;
glUseProgram(fs->shader.id);
- glActiveTexture(GL_TEXTURE0 + ctx->out_texture_unit);
- glBindTexture(GL_TEXTURE_3D, ctx->out_texture);
- glUniform1i(fs->out_data_tex_id, ctx->out_texture_unit);
+ glBindTextureUnit(0, ctx->out_texture);
glUniform1f(fs->db_cutoff_id, fs->db);
DrawTexture(fs->output.texture, 0, 0, WHITE);
EndShaderMode();
diff --git a/beamformer.h b/beamformer.h
@@ -207,7 +207,6 @@ typedef struct {
typedef struct {
Shader shader;
RenderTexture2D output;
- i32 out_data_tex_id;
i32 db_cutoff_id;
f32 db;
} FragmentShaderCtx;
@@ -255,7 +254,6 @@ typedef struct {
uv4 out_data_dim;
u32 out_texture;
- u32 out_texture_unit;
u32 out_texture_mips;
ComputeShaderCtx csctx;
diff --git a/main.c b/main.c
@@ -183,9 +183,8 @@ reload_shaders(BeamformerCtx *ctx, Arena a)
Shader updated_fs = LoadShader(NULL, "shaders/render.glsl");
if (updated_fs.id != rlGetShaderIdDefault()) {
UnloadShader(ctx->fsctx.shader);
- ctx->fsctx.shader = updated_fs;
- ctx->fsctx.out_data_tex_id = GetShaderLocation(updated_fs, "u_out_data_tex");
- ctx->fsctx.db_cutoff_id = GetShaderLocation(updated_fs, "u_db_cutoff");
+ ctx->fsctx.shader = updated_fs;
+ ctx->fsctx.db_cutoff_id = GetShaderLocation(updated_fs, "u_db_cutoff");
}
}
diff --git a/shaders/render.glsl b/shaders/render.glsl
@@ -4,8 +4,8 @@
in vec2 fragTexCoord;
out vec4 v_out_colour;
-layout(location = 1) uniform sampler3D u_out_data_tex;
-layout(location = 2) uniform float u_db_cutoff = -60;
+layout(binding = 0) uniform sampler3D u_out_data_tex;
+layout(location = 1) uniform float u_db_cutoff = -60;
/* input: h [0,360] | s,v [0, 1] *
* output: rgb [0,1] */