summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-10-18 10:47:14 +1100
committerTimothy Arceri <[email protected]>2016-10-26 14:29:36 +1100
commitd9d04373c1ba2ae3e20c6b507262ee3c88c4ab78 (patch)
treec083b6227695e42682f149decbc5c66948eada84 /src/mesa
parenta317b40d1d3f4f684f1601ba061dd806c080811b (diff)
st/mesa: get interpolation location at translation time
Rather then messing around creating bitfields and arrays to store the interpolation location just translate it on the fly. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp22
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.h1
-rw-r--r--src/mesa/state_tracker/st_program.c10
3 files changed, 18 insertions, 15 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index d0d2431f9bb..a58bedc4974 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -338,6 +338,7 @@ struct inout_decl {
unsigned mesa_index;
unsigned array_id; /* TGSI ArrayID; 1-based: 0 means not an array */
unsigned size;
+ unsigned interp_loc;
enum glsl_interp_mode interp;
enum glsl_base_type base_type;
ubyte usage_mask; /* GLSL-style usage-mask, i.e. single bit per double */
@@ -2385,6 +2386,17 @@ is_inout_array(unsigned stage, ir_variable *var, bool *remove_array)
return type->is_array() || type->is_matrix();
}
+static unsigned
+st_translate_interp_loc(ir_variable *var)
+{
+ if (var->data.centroid)
+ return TGSI_INTERPOLATE_LOC_CENTROID;
+ else if (var->data.sample)
+ return TGSI_INTERPOLATE_LOC_SAMPLE;
+ else
+ return TGSI_INTERPOLATE_LOC_CENTER;
+}
+
void
glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
{
@@ -2422,6 +2434,7 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
decl->mesa_index = var->data.location;
decl->interp = (glsl_interp_mode) var->data.interpolation;
+ decl->interp_loc = st_translate_interp_loc(var);
decl->base_type = type_without_array->base_type;
decl->usage_mask = u_bit_consecutive(component, num_components);
@@ -5926,7 +5939,6 @@ st_translate_interp(enum glsl_interp_mode glsl_qual, GLuint varying)
* \param inputSemanticIndex the semantic index (ex: which texcoord) for
* each input
* \param interpMode the TGSI_INTERPOLATE_LINEAR/PERSP mode for each input
- * \param interpLocation the TGSI_INTERPOLATE_LOC_* location for each input
* \param numOutputs number of output registers used
* \param outputMapping maps Mesa fragment program outputs to TGSI
* generic outputs
@@ -5949,7 +5961,6 @@ st_translate_program(
const ubyte inputSemanticName[],
const ubyte inputSemanticIndex[],
const GLuint interpMode[],
- const GLuint interpLocation[],
GLuint numOutputs,
const GLuint outputMapping[],
const GLuint outputSlotToAttr[],
@@ -6006,17 +6017,20 @@ st_translate_program(
}
unsigned interp_mode = 0;
+ unsigned interp_location = 0;
if (procType == PIPE_SHADER_FRAGMENT) {
assert(interpMode);
interp_mode = interpMode[slot] != TGSI_INTERPOLATE_COUNT ?
interpMode[slot] :
st_translate_interp(decl->interp, inputSlotToAttr[slot]);
+
+ interp_location = decl->interp_loc;
}
src = ureg_DECL_fs_input_cyl_centroid_layout(ureg,
inputSemanticName[slot], inputSemanticIndex[slot],
- interp_mode, 0, interpLocation ? interpLocation[slot] : 0,
- slot, tgsi_usage_mask, decl->array_id, decl->size);
+ interp_mode, 0, interp_location, slot, tgsi_usage_mask,
+ decl->array_id, decl->size);
for (unsigned j = 0; j < decl->size; ++j) {
if (t->inputs[slot + j].File != TGSI_FILE_INPUT) {
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.h b/src/mesa/state_tracker/st_glsl_to_tgsi.h
index 0f485fb2541..add534ce997 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.h
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.h
@@ -47,7 +47,6 @@ enum pipe_error st_translate_program(
const ubyte inputSemanticName[],
const ubyte inputSemanticIndex[],
const GLuint interpMode[],
- const GLuint interpLocation[],
GLuint numOutputs,
const GLuint outputMapping[],
const GLuint outputSlotToAttr[],
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 6ea46781762..7a4ac26066b 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -425,7 +425,6 @@ st_translate_vertex_program(struct st_context *st,
NULL, /* input semantic name */
NULL, /* input semantic index */
NULL, /* interp mode */
- NULL, /* interp location */
/* outputs */
num_outputs,
stvp->result_to_output,
@@ -569,7 +568,6 @@ st_translate_fragment_program(struct st_context *st,
GLuint inputMapping[VARYING_SLOT_MAX];
GLuint inputSlotToAttr[VARYING_SLOT_MAX];
GLuint interpMode[PIPE_MAX_SHADER_INPUTS]; /* XXX size? */
- GLuint interpLocation[PIPE_MAX_SHADER_INPUTS];
GLuint attr;
GLbitfield64 inputsRead;
struct ureg_program *ureg;
@@ -623,12 +621,6 @@ st_translate_fragment_program(struct st_context *st,
inputMapping[attr] = slot;
inputSlotToAttr[slot] = attr;
- if (stfp->Base.IsCentroid & BITFIELD64_BIT(attr))
- interpLocation[slot] = TGSI_INTERPOLATE_LOC_CENTROID;
- else if (stfp->Base.IsSample & BITFIELD64_BIT(attr))
- interpLocation[slot] = TGSI_INTERPOLATE_LOC_SAMPLE;
- else
- interpLocation[slot] = TGSI_INTERPOLATE_LOC_CENTER;
switch (attr) {
case VARYING_SLOT_POS:
@@ -888,7 +880,6 @@ st_translate_fragment_program(struct st_context *st,
input_semantic_name,
input_semantic_index,
interpMode,
- interpLocation,
/* outputs */
fs_num_outputs,
outputMapping,
@@ -1459,7 +1450,6 @@ st_translate_program_common(struct st_context *st,
input_semantic_name,
input_semantic_index,
NULL,
- NULL,
/* outputs */
num_outputs,
outputMapping,