aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorAlejandro Piñeiro <[email protected]>2019-02-07 18:43:58 +0100
committerAlejandro Piñeiro <[email protected]>2019-02-21 11:47:59 +0100
commit0629b2a462a1dfc729fb487419b3c2749ef9e728 (patch)
tree4b6bc4c0a9033f666dd55c59dcc64c3f31f1e2ee /src/mesa
parent675eabb56069795a2dbcc55ced7e77cfe4e93b92 (diff)
nir, glsl: move pixel_center_integer/origin_upper_left to shader_info.fs
On GLSL that info is set as a layout qualifier when redeclaring gl_FragCoord, so somehow tied to a specific variable. But in practice, they behave as a global of the shader. On ARB programs they are set using a global OPTION (defined at ARB_fragment_coord_conventions), and on SPIR-V using ExecutionModes, that are also not tied specifically to the builtin. This patch moves that info from nir variable and ir variable to nir shader and gl_program shader_info respectively, so the map is more similar to SPIR-V, and ARB programs, instead of more similar to GLSL. FWIW, shader_info.fs already had pixel_center_integer, so this change also removes some redundancy. Also, as struct gl_program also includes a shader_info, we removed gl_program::OriginUpperLeft and PixelCenterInteger, as it would be superfluous. This change was needed because recently spirv_to_nir changed the order in which execution modes and variables are handled, so the variables didn't get the correct values. Now the info is set on the shader itself, and we don't need to go back to the builtin variable to set it. Fixes: e68871f6a ("spirv: Handle constants and types before execution modes") v2: (Jason) * glsl_to_nir: get the info before glsl_to_nir, while all the rest of the info gathering is happening * prog_to_nir: gather the info on a general info-gathering pass, not on variable setup. v3: (Jason) * Squash with the patch that removes that info from ir variable * anv: assert that OriginUpperLeft is true. It should be already set by spirv_to_nir. * blorp: set origin_upper_left on its core "compile fragment shader", not just on some specific places (for this we added an helper on a previous patch). * prog_to_nir: no need to gather specifically this fragcoord modes as the full gl_program shader_info is copied. * spirv_to_nir: assert that we are a fragment shader when handling this execution modes. v4: (reported by failing gitlab pipeline #18750) * state_tracker: update too due changes on ir.h/gl_program v5: * blorp: minor change after change on previous patch * radeonsi: update due this change. v6: (Timothy Arceri) * prog_to_nir: remove extra whitespace * shader_info: don't use :1 on origin_upper_left * glsl: program.fs.origin_upper_left/pixel_center_integer can be move out of the shader list loop
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/mtypes.h4
-rw-r--r--src/mesa/program/arbprogparse.c4
-rw-r--r--src/mesa/program/ir_to_mesa.cpp5
-rw-r--r--src/mesa/program/prog_to_nir.c11
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp9
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c4
-rw-r--r--src/mesa/swrast/s_fragprog.c4
7 files changed, 9 insertions, 32 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ca00de7dc63..9bca5c153ad 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2102,10 +2102,6 @@ struct gl_program
/** Texture units used for samplerExternalOES */
GLbitfield ExternalSamplersUsed;
- /* Fragement shader only fields */
- GLboolean OriginUpperLeft;
- GLboolean PixelCenterInteger;
-
/** Named parameters, constants, etc. from program text */
struct gl_program_parameter_list *Parameters;
diff --git a/src/mesa/program/arbprogparse.c b/src/mesa/program/arbprogparse.c
index 7cb1beb5bbb..4038e475c92 100644
--- a/src/mesa/program/arbprogparse.c
+++ b/src/mesa/program/arbprogparse.c
@@ -117,8 +117,8 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
program->SamplersUsed |= (1 << i);
}
program->ShadowSamplers = prog.ShadowSamplers;
- program->OriginUpperLeft = state.option.OriginUpperLeft;
- program->PixelCenterInteger = state.option.PixelCenterInteger;
+ program->info.fs.origin_upper_left = state.option.OriginUpperLeft;
+ program->info.fs.pixel_center_integer = state.option.PixelCenterInteger;
program->info.fs.uses_discard = state.fragment.UsesKill;
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 2908819d28e..e65a6743353 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -618,11 +618,6 @@ ir_to_mesa_visitor::find_variable_storage(const ir_variable *var)
void
ir_to_mesa_visitor::visit(ir_variable *ir)
{
- if (strcmp(ir->name, "gl_FragCoord") == 0) {
- this->prog->OriginUpperLeft = ir->data.origin_upper_left;
- this->prog->PixelCenterInteger = ir->data.pixel_center_integer;
- }
-
if (ir->data.mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) {
unsigned int i;
const ir_state_slot *const slots = ir->get_state_slots();
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
index 312b299361e..1c9d0018d55 100644
--- a/src/mesa/program/prog_to_nir.c
+++ b/src/mesa/program/prog_to_nir.c
@@ -890,10 +890,7 @@ setup_registers_and_variables(struct ptn_compile *c)
var->data.index = 0;
if (c->prog->Target == GL_FRAGMENT_PROGRAM_ARB) {
- if (i == VARYING_SLOT_POS) {
- var->data.origin_upper_left = c->prog->OriginUpperLeft;
- var->data.pixel_center_integer = c->prog->PixelCenterInteger;
- } else if (i == VARYING_SLOT_FOGC) {
+ if (i == VARYING_SLOT_FOGC) {
/* fogcoord is defined as <f, 0.0, 0.0, 1.0>. Make the actual
* input variable a float, and create a local containing the
* full vec4 value.
@@ -934,12 +931,6 @@ setup_registers_and_variables(struct ptn_compile *c)
var->data.location = i;
var->data.index = 0;
- if (c->prog->Target == GL_FRAGMENT_PROGRAM_ARB &&
- i == SYSTEM_VALUE_FRAG_COORD) {
- var->data.origin_upper_left = c->prog->OriginUpperLeft;
- var->data.pixel_center_integer = c->prog->PixelCenterInteger;
- }
-
c->sysval_vars[i] = var;
}
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 2102b7a57d5..484a5329455 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1136,11 +1136,6 @@ glsl_to_tgsi_visitor::find_variable_storage(ir_variable *var)
void
glsl_to_tgsi_visitor::visit(ir_variable *ir)
{
- if (strcmp(ir->name, "gl_FragCoord") == 0) {
- this->prog->OriginUpperLeft = ir->data.origin_upper_left;
- this->prog->PixelCenterInteger = ir->data.pixel_center_integer;
- }
-
if (ir->data.mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) {
unsigned int i;
const ir_state_slot *const slots = ir->get_state_slots();
@@ -6422,7 +6417,7 @@ emit_wpos(struct st_context *st,
* u,i -> l,h: (99.0 + 0.5) * -1 + 100 = 0.5
* u,h -> l,i: (99.5 + 0.5) * -1 + 100 = 0
*/
- if (program->OriginUpperLeft) {
+ if (program->info.fs.origin_upper_left) {
/* Fragment shader wants origin in upper-left */
if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT)) {
/* the driver supports upper-left origin */
@@ -6449,7 +6444,7 @@ emit_wpos(struct st_context *st,
assert(0);
}
- if (program->PixelCenterInteger) {
+ if (program->info.fs.pixel_center_integer) {
/* Fragment shader wants pixel center integer */
if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {
/* the driver supports pixel center integer */
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 0ea201fdd6a..03a2dee6778 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -734,7 +734,7 @@ emit_wpos(struct st_context *st,
* u,i -> l,h: (99.0 + 0.5) * -1 + 100 = 0.5
* u,h -> l,i: (99.5 + 0.5) * -1 + 100 = 0
*/
- if (program->OriginUpperLeft) {
+ if (program->info.fs.origin_upper_left) {
/* Fragment shader wants origin in upper-left */
if (pscreen->get_param(pscreen,
PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT)) {
@@ -764,7 +764,7 @@ emit_wpos(struct st_context *st,
assert(0);
}
- if (program->PixelCenterInteger) {
+ if (program->info.fs.pixel_center_integer) {
/* Fragment shader wants pixel center integer */
if (pscreen->get_param(pscreen,
PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {
diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c
index 8b47e48355b..6fb793fb621 100644
--- a/src/mesa/swrast/s_fragprog.c
+++ b/src/mesa/swrast/s_fragprog.c
@@ -164,9 +164,9 @@ init_machine(struct gl_context *ctx, struct gl_program_machine *machine,
GLfloat *wpos = span->array->attribs[VARYING_SLOT_POS][col];
/* ARB_fragment_coord_conventions */
- if (program->OriginUpperLeft)
+ if (program->info.fs.origin_upper_left)
wpos[1] = ctx->DrawBuffer->Height - 1 - wpos[1];
- if (!program->PixelCenterInteger) {
+ if (!program->info.fs.pixel_center_integer) {
wpos[0] += 0.5F;
wpos[1] += 0.5F;
}