mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-22 00:08:09 +02:00
nir: Make nir_lower_samplers take a gl_shader_stage, not a gl_program *.
We don't actually need a gl_program struct. We only used it to translate prog->Target (i.e. GL_VERTEX_PROGRAM) to the gl_shader_stage (i.e. MESA_SHADER_VERTEX). We may as well just pass that. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
4b27391cad
commit
99264b7f37
3 changed files with 14 additions and 16 deletions
|
|
@ -1612,7 +1612,7 @@ void nir_lower_phis_to_scalar(nir_shader *shader);
|
|||
|
||||
void nir_lower_samplers(nir_shader *shader,
|
||||
struct gl_shader_program *shader_program,
|
||||
struct gl_program *prog);
|
||||
gl_shader_stage stage);
|
||||
|
||||
void nir_lower_system_values(nir_shader *shader);
|
||||
void nir_lower_tex_projector(nir_shader *shader);
|
||||
|
|
|
|||
|
|
@ -36,11 +36,9 @@ extern "C" {
|
|||
}
|
||||
|
||||
static unsigned
|
||||
get_sampler_index(struct gl_shader_program *shader_program, const char *name,
|
||||
const struct gl_program *prog)
|
||||
get_sampler_index(struct gl_shader_program *shader_program,
|
||||
gl_shader_stage stage, const char *name)
|
||||
{
|
||||
GLuint shader = _mesa_program_enum_to_shader_stage(prog->Target);
|
||||
|
||||
unsigned location;
|
||||
if (!shader_program->UniformHash->get(location, name)) {
|
||||
linker_error(shader_program,
|
||||
|
|
@ -48,7 +46,7 @@ get_sampler_index(struct gl_shader_program *shader_program, const char *name,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!shader_program->UniformStorage[location].sampler[shader].active) {
|
||||
if (!shader_program->UniformStorage[location].sampler[stage].active) {
|
||||
assert(0 && "cannot return a sampler");
|
||||
linker_error(shader_program,
|
||||
"cannot return a sampler named %s, because it is not "
|
||||
|
|
@ -57,12 +55,12 @@ get_sampler_index(struct gl_shader_program *shader_program, const char *name,
|
|||
return 0;
|
||||
}
|
||||
|
||||
return shader_program->UniformStorage[location].sampler[shader].index;
|
||||
return shader_program->UniformStorage[location].sampler[stage].index;
|
||||
}
|
||||
|
||||
static void
|
||||
lower_sampler(nir_tex_instr *instr, struct gl_shader_program *shader_program,
|
||||
const struct gl_program *prog, void *mem_ctx)
|
||||
gl_shader_stage stage, void *mem_ctx)
|
||||
{
|
||||
if (instr->sampler == NULL)
|
||||
return;
|
||||
|
|
@ -133,7 +131,7 @@ lower_sampler(nir_tex_instr *instr, struct gl_shader_program *shader_program,
|
|||
}
|
||||
}
|
||||
|
||||
instr->sampler_index += get_sampler_index(shader_program, name, prog);
|
||||
instr->sampler_index += get_sampler_index(shader_program, stage, name);
|
||||
|
||||
instr->sampler = NULL;
|
||||
}
|
||||
|
|
@ -141,7 +139,7 @@ lower_sampler(nir_tex_instr *instr, struct gl_shader_program *shader_program,
|
|||
typedef struct {
|
||||
void *mem_ctx;
|
||||
struct gl_shader_program *shader_program;
|
||||
struct gl_program *prog;
|
||||
gl_shader_stage stage;
|
||||
} lower_state;
|
||||
|
||||
static bool
|
||||
|
|
@ -152,7 +150,7 @@ lower_block_cb(nir_block *block, void *_state)
|
|||
nir_foreach_instr(block, instr) {
|
||||
if (instr->type == nir_instr_type_tex) {
|
||||
nir_tex_instr *tex_instr = nir_instr_as_tex(instr);
|
||||
lower_sampler(tex_instr, state->shader_program, state->prog,
|
||||
lower_sampler(tex_instr, state->shader_program, state->stage,
|
||||
state->mem_ctx);
|
||||
}
|
||||
}
|
||||
|
|
@ -162,23 +160,23 @@ lower_block_cb(nir_block *block, void *_state)
|
|||
|
||||
static void
|
||||
lower_impl(nir_function_impl *impl, struct gl_shader_program *shader_program,
|
||||
struct gl_program *prog)
|
||||
gl_shader_stage stage)
|
||||
{
|
||||
lower_state state;
|
||||
|
||||
state.mem_ctx = ralloc_parent(impl);
|
||||
state.shader_program = shader_program;
|
||||
state.prog = prog;
|
||||
state.stage = stage;
|
||||
|
||||
nir_foreach_block(impl, lower_block_cb, &state);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
nir_lower_samplers(nir_shader *shader, struct gl_shader_program *shader_program,
|
||||
struct gl_program *prog)
|
||||
gl_shader_stage stage)
|
||||
{
|
||||
nir_foreach_overload(shader, overload) {
|
||||
if (overload->impl)
|
||||
lower_impl(overload->impl, shader_program, prog);
|
||||
lower_impl(overload->impl, shader_program, stage);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ fs_visitor::emit_nir_code()
|
|||
nir_validate_shader(nir);
|
||||
|
||||
if (shader_prog) {
|
||||
nir_lower_samplers(nir, shader_prog, shader->base.Program);
|
||||
nir_lower_samplers(nir, shader_prog, stage);
|
||||
nir_validate_shader(nir);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue