i965: Generalize GL_FIXED VS w/a support
Next few patches build on this to add other workarounds for packed formats. V2: rename BRW_ATTRIB_WA_COMPONENTS to BRW_ATTRIB_WA_COMPONENT_MASK; V3 (Kayden): remove separate bit for ES3 signed normalization Signed-off-by: Chris Forbes <chrisf@ijw.co.nz> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
committed by
Kenneth Graunke
parent
23f4411c41
commit
c3c680950d
@@ -815,13 +815,13 @@ vec4_visitor::visit(ir_variable *ir)
|
||||
* come in as floating point conversions of the integer values.
|
||||
*/
|
||||
for (int i = ir->location; i < ir->location + type_size(ir->type); i++) {
|
||||
if (!c->key.gl_fixed_input_size[i])
|
||||
continue;
|
||||
|
||||
dst_reg dst = *reg;
|
||||
dst.type = brw_type_for_base_type(ir->type);
|
||||
dst.writemask = (1 << c->key.gl_fixed_input_size[i]) - 1;
|
||||
emit(MUL(dst, src_reg(dst), src_reg(1.0f / 65536.0f)));
|
||||
uint8_t wa_flags = c->key.gl_attrib_wa_flags[i];
|
||||
if (wa_flags & BRW_ATTRIB_WA_COMPONENT_MASK) {
|
||||
dst_reg dst = *reg;
|
||||
dst.type = brw_type_for_base_type(ir->type);
|
||||
dst.writemask = (1 << (wa_flags & BRW_ATTRIB_WA_COMPONENT_MASK)) - 1;
|
||||
emit(MUL(dst, src_reg(dst), src_reg(1.0f / 65536.0f)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -362,9 +362,9 @@ brw_vs_debug_recompile(struct brw_context *brw,
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < VERT_ATTRIB_MAX; i++) {
|
||||
found |= key_debug("GL_FIXED rescaling",
|
||||
old_key->gl_fixed_input_size[i],
|
||||
key->gl_fixed_input_size[i]);
|
||||
found |= key_debug("Vertex attrib w/a flags",
|
||||
old_key->gl_attrib_wa_flags[i],
|
||||
key->gl_attrib_wa_flags[i]);
|
||||
}
|
||||
|
||||
found |= key_debug("user clip flags",
|
||||
@@ -446,9 +446,10 @@ static void brw_upload_vs_prog(struct brw_context *brw)
|
||||
|
||||
/* BRW_NEW_VERTICES */
|
||||
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
|
||||
/* TODO: flag w/a for packed vertex formats here too */
|
||||
if (vp->program.Base.InputsRead & BITFIELD64_BIT(i) &&
|
||||
brw->vb.inputs[i].glarray->Type == GL_FIXED) {
|
||||
key.gl_fixed_input_size[i] = brw->vb.inputs[i].glarray->Size;
|
||||
key.gl_attrib_wa_flags[i] = brw->vb.inputs[i].glarray->Size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,13 +39,24 @@
|
||||
#include "brw_program.h"
|
||||
#include "program/program.h"
|
||||
|
||||
/**
|
||||
* The VF can't natively handle certain types of attributes, such as GL_FIXED
|
||||
* or most 10_10_10_2 types. These flags enable various VS workarounds to
|
||||
* "fix" attributes at the beginning of shaders.
|
||||
*/
|
||||
#define BRW_ATTRIB_WA_COMPONENT_MASK 7 /* mask for GL_FIXED scale channel count */
|
||||
#define BRW_ATTRIB_WA_NORMALIZE 8 /* normalize in shader */
|
||||
#define BRW_ATTRIB_WA_BGRA 16 /* swap r/b channels in shader */
|
||||
#define BRW_ATTRIB_WA_SIGN 32 /* interpret as signed in shader */
|
||||
#define BRW_ATTRIB_WA_SCALE 64 /* interpret as scaled in shader */
|
||||
|
||||
struct brw_vs_prog_key {
|
||||
GLuint program_string_id;
|
||||
/**
|
||||
* Number of channels of the vertex attribute that need GL_FIXED rescaling
|
||||
|
||||
/*
|
||||
* Per-attribute workaround flags
|
||||
*/
|
||||
uint8_t gl_fixed_input_size[VERT_ATTRIB_MAX];
|
||||
uint8_t gl_attrib_wa_flags[VERT_ATTRIB_MAX];
|
||||
|
||||
/**
|
||||
* True if at least one clip flag is enabled, regardless of whether the
|
||||
|
||||
Reference in New Issue
Block a user