diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp index d79151c1f56..b94ded29dfe 100644 --- a/src/compiler/glsl/standalone.cpp +++ b/src/compiler/glsl/standalone.cpp @@ -102,7 +102,7 @@ init_gl_program(struct gl_program *prog, bool is_arb_asm, gl_shader_stage stage) { prog->RefCount = 1; prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB; - prog->info.is_arb_asm = is_arb_asm; + prog->info.use_legacy_math_rules = is_arb_asm; prog->info.stage = stage; } diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h index 186cef2619c..86d7ca14505 100644 --- a/src/compiler/shader_info.h +++ b/src/compiler/shader_info.h @@ -310,9 +310,28 @@ typedef struct shader_info { bool workgroup_size_variable:1; /** - * Is this an ARB assembly-style program. + * Set if this shader uses legacy (DX9 or ARB assembly) math rules. + * + * From the ARB_fragment_program specification: + * + * "The following rules apply to multiplication: + * + * 1. * == * , for all and . + * 2. +/-0.0 * = +/-0.0, at least for all that correspond to + * *representable numbers (IEEE "not a number" and "infinity" + * *encodings may be exceptions). + * 3. +1.0 * = , for all ."" + * + * However, in effect this was due to DX9 semantics implying that 0*x=0 even + * for inf/nan if the hardware generated them instead of float_min/max. So, + * you should not have an exception for inf/nan to rule 2 above. + * + * One implementation of this behavior would be to flush all generated NaNs + * to zero, at which point 0*Inf=Nan=0. Most DX9/ARB-asm hardware did not + * generate NaNs, and the only way the GPU saw one was to possibly feed it + * in as a uniform. */ - bool is_arb_asm; + bool use_legacy_math_rules; union { struct { diff --git a/src/gallium/drivers/crocus/crocus_program.c b/src/gallium/drivers/crocus/crocus_program.c index f1ee9b9c816..b07a4ceb20f 100644 --- a/src/gallium/drivers/crocus/crocus_program.c +++ b/src/gallium/drivers/crocus/crocus_program.c @@ -1208,7 +1208,7 @@ crocus_compile_vs(struct crocus_context *ice, if (key->clamp_pointsize) nir_lower_point_size(nir, 1.0, 255.0); - prog_data->use_alt_mode = nir->info.is_arb_asm; + prog_data->use_alt_mode = nir->info.use_legacy_math_rules; crocus_setup_uniforms(compiler, mem_ctx, nir, prog_data, &system_values, &num_system_values, &num_cbufs); @@ -1858,7 +1858,7 @@ crocus_compile_fs(struct crocus_context *ice, nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir); - prog_data->use_alt_mode = nir->info.is_arb_asm; + prog_data->use_alt_mode = nir->info.use_legacy_math_rules; crocus_setup_uniforms(compiler, mem_ctx, nir, prog_data, &system_values, &num_system_values, &num_cbufs); diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c index 02423c0d308..64097d87de2 100644 --- a/src/gallium/drivers/iris/iris_program.c +++ b/src/gallium/drivers/iris/iris_program.c @@ -1335,7 +1335,7 @@ iris_compile_vs(struct iris_screen *screen, nir_shader_gather_info(nir, impl); } - prog_data->use_alt_mode = nir->info.is_arb_asm; + prog_data->use_alt_mode = nir->info.use_legacy_math_rules; iris_setup_uniforms(compiler, mem_ctx, nir, prog_data, 0, &system_values, &num_system_values, &num_cbufs); @@ -1967,7 +1967,7 @@ iris_compile_fs(struct iris_screen *screen, nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir); const struct iris_fs_prog_key *const key = &shader->key.fs; - prog_data->use_alt_mode = nir->info.is_arb_asm; + prog_data->use_alt_mode = nir->info.use_legacy_math_rules; iris_setup_uniforms(compiler, mem_ctx, nir, prog_data, 0, &system_values, &num_system_values, &num_cbufs); diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index ec1013f8d74..0c64689ccef 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -273,7 +273,7 @@ static void si_lower_nir(struct si_screen *sscreen, struct nir_shader *nir) NIR_PASS_V(nir, nir_lower_discard_or_demote, (sscreen->debug_flags & DBG(FS_CORRECT_DERIVS_AFTER_KILL)) || - nir->info.is_arb_asm); + nir->info.use_legacy_math_rules); /* Lower load constants to scalar and then clean up the mess */ NIR_PASS_V(nir, nir_lower_load_const_to_scalar); diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 86e25c8861d..6135c80586a 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -956,7 +956,7 @@ associate_uniform_storage(struct gl_context *ctx, unsigned columns = 0; int dmul; - if (ctx->Const.PackedDriverUniformStorage && !prog->info.is_arb_asm) { + if (ctx->Const.PackedDriverUniformStorage && !prog->info.use_legacy_math_rules) { dmul = storage->type->vector_elements * sizeof(float); } else { dmul = 4 * sizeof(float); @@ -1050,7 +1050,7 @@ associate_uniform_storage(struct gl_context *ctx, * initializers in the source code to be copied over. */ unsigned array_elements = MAX2(1, storage->array_elements); - if (ctx->Const.PackedDriverUniformStorage && !prog->info.is_arb_asm && + if (ctx->Const.PackedDriverUniformStorage && !prog->info.use_legacy_math_rules && (storage->is_bindless || !storage->type->contains_opaque())) { const int dmul = storage->type->is_64bit() ? 2 : 1; const unsigned components = diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c index 1cf8ae48004..c151b92ee50 100644 --- a/src/mesa/program/program.c +++ b/src/mesa/program/program.c @@ -196,7 +196,7 @@ _mesa_init_gl_program(struct gl_program *prog, gl_shader_stage stage, prog->RefCount = 1; prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB; prog->info.stage = stage; - prog->info.is_arb_asm = is_arb_asm; + prog->info.use_legacy_math_rules = is_arb_asm; /* Uniforms that lack an initializer in the shader code have an initial * value of zero. This includes sampler uniforms.