mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 11:00:11 +01:00
r300: remove finalize_nir
This was added so we could report compile failures. Since we can now just do that simply from create_vs/fs_state there is no need for finalize_nir anymore. Move the optimization loop to the beginning of create_vs/fs_state. This could be probably optimized a bit more, but right now there should be no functional change, we can improve the pass order later. Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33961>
This commit is contained in:
parent
ba80a11b69
commit
20b51133f3
4 changed files with 10 additions and 32 deletions
|
|
@ -137,12 +137,12 @@ remove_clip_vertex(nir_builder *b, nir_instr *instr, UNUSED void *_)
|
|||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
r300_optimize_nir(struct nir_shader *s, struct pipe_screen *screen)
|
||||
void
|
||||
r300_optimize_nir(struct nir_shader *s, struct r300_screen *screen)
|
||||
{
|
||||
bool is_r500 = r300_screen(screen)->caps.is_r500;
|
||||
bool is_r500 = screen->caps.is_r500;
|
||||
|
||||
if (s->info.stage == MESA_SHADER_VERTEX && r300_screen(screen)->caps.has_tcl) {
|
||||
if (s->info.stage == MESA_SHADER_VERTEX && screen->caps.has_tcl) {
|
||||
/* There is no HW support for gl_ClipVertex, so we just remove it early. */
|
||||
if (nir_shader_instructions_pass(s, remove_clip_vertex,
|
||||
nir_metadata_control_flow, NULL)) {
|
||||
|
|
@ -260,28 +260,3 @@ r300_check_control_flow(nir_shader *s)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
r300_finalize_nir(struct pipe_screen *pscreen, struct nir_shader *s)
|
||||
{
|
||||
r300_optimize_nir(s, pscreen);
|
||||
|
||||
/* st_program.c's parameter list optimization requires that future nir
|
||||
* variants don't reallocate the uniform storage, so we have to remove
|
||||
* uniforms that occupy storage. But we don't want to remove samplers,
|
||||
* because they're needed for YUV variant lowering.
|
||||
*/
|
||||
nir_remove_dead_derefs(s);
|
||||
nir_foreach_uniform_variable_safe (var, s) {
|
||||
if (var->data.mode == nir_var_uniform &&
|
||||
(glsl_type_get_image_count(var->type) || glsl_type_get_sampler_count(var->type)))
|
||||
continue;
|
||||
|
||||
exec_node_remove(&var->node);
|
||||
}
|
||||
nir_validate_shader(s, "after uniform var removal");
|
||||
|
||||
nir_sweep(s);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "compiler/nir/nir.h"
|
||||
#include "pipe/p_screen.h"
|
||||
#include "r300_screen.h"
|
||||
|
||||
static inline bool
|
||||
is_ubo_or_input(UNUSED struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
||||
|
|
@ -133,7 +134,7 @@ bool r300_is_only_used_as_float(const nir_alu_instr *instr);
|
|||
|
||||
char *r300_check_control_flow(nir_shader *s);
|
||||
|
||||
char *r300_finalize_nir(struct pipe_screen *pscreen, struct nir_shader *nir);
|
||||
void r300_optimize_nir(struct nir_shader *s, struct r300_screen *screen);
|
||||
|
||||
extern bool r300_transform_vs_trig_input(struct nir_shader *shader);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
#include "r300_screen_buffer.h"
|
||||
#include "r300_state_inlines.h"
|
||||
#include "r300_public.h"
|
||||
#include "compiler/r300_nir.h"
|
||||
|
||||
#include "draw/draw_context.h"
|
||||
|
||||
|
|
@ -711,7 +710,6 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws,
|
|||
r300screen->screen.get_name = r300_get_name;
|
||||
r300screen->screen.get_vendor = r300_get_vendor;
|
||||
r300screen->screen.get_compiler_options = r300_get_compiler_options;
|
||||
r300screen->screen.finalize_nir = r300_finalize_nir;
|
||||
r300screen->screen.get_device_vendor = r300_get_device_vendor;
|
||||
r300screen->screen.get_disk_shader_cache = r300_get_disk_shader_cache;
|
||||
r300screen->screen.get_screen_fd = r300_screen_get_fd;
|
||||
|
|
|
|||
|
|
@ -1033,6 +1033,8 @@ static void* r300_create_fs_state(struct pipe_context* pipe,
|
|||
fs->state = *shader;
|
||||
|
||||
if (fs->state.type == PIPE_SHADER_IR_NIR) {
|
||||
r300_optimize_nir(shader->ir.nir, r300->screen);
|
||||
|
||||
/* R300/R400 can not do any kind of control flow, so abort early here. */
|
||||
if (!r300->screen->caps.is_r500) {
|
||||
char *msg = r300_check_control_flow(shader->ir.nir);
|
||||
|
|
@ -1949,6 +1951,8 @@ static void* r300_create_vs_state(struct pipe_context* pipe,
|
|||
vs->state = *shader;
|
||||
|
||||
if (vs->state.type == PIPE_SHADER_IR_NIR) {
|
||||
r300_optimize_nir(shader->ir.nir, r300->screen);
|
||||
|
||||
/* R300/R400 can not do any kind of control flow, so abort early here. */
|
||||
if (!r300->screen->caps.is_r500 && r300->screen->caps.has_tcl) {
|
||||
char *msg = r300_check_control_flow(shader->ir.nir);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue