wined3d: Use the "input_registers" bitmap for vertex shader attributes as well.

This commit is contained in:
Henri Verbeet 2009-05-27 10:24:49 +02:00 committed by Alexandre Julliard
parent 664b17b9ee
commit 10fadadc54
4 changed files with 27 additions and 22 deletions

View File

@ -260,7 +260,7 @@ static void shader_record_register_usage(IWineD3DBaseShaderImpl *This, struct sh
break; break;
case WINED3DSPR_INPUT: case WINED3DSPR_INPUT:
if (!pshader) reg_maps->attributes[reg->idx] = 1; if (!pshader) reg_maps->input_registers |= 1 << reg->idx;
else else
{ {
if (reg->rel_addr) if (reg->rel_addr)
@ -410,8 +410,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
/* Vshader: mark attributes used /* Vshader: mark attributes used
* Pshader: mark 3.0 input registers used, save token */ * Pshader: mark 3.0 input registers used, save token */
case WINED3DSPR_INPUT: case WINED3DSPR_INPUT:
if (!pshader) reg_maps->attributes[semantic.reg.reg.idx] = 1; reg_maps->input_registers |= 1 << semantic.reg.reg.idx;
else reg_maps->input_registers |= 1 << semantic.reg.reg.idx;
semantics_in[semantic.reg.reg.idx] = semantic; semantics_in[semantic.reg.reg.idx] = semantic;
break; break;

View File

@ -964,10 +964,17 @@ static void shader_generate_glsl_declarations(IWineD3DBaseShader *iface, const s
} }
/* Declare attributes */ /* Declare attributes */
for (i = 0; i < This->baseShader.limits.attributes; i++) { if (reg_maps->shader_version.type == WINED3D_SHADER_TYPE_VERTEX)
if (reg_maps->attributes[i]) {
WORD map = reg_maps->input_registers;
for (i = 0; map; map >>= 1, ++i)
{
if (!(map & 1)) continue;
shader_addline(buffer, "attribute vec4 attrib%i;\n", i); shader_addline(buffer, "attribute vec4 attrib%i;\n", i);
} }
}
/* Declare loop registers aLx */ /* Declare loop registers aLx */
for (i = 0; i < reg_maps->loop_depth; i++) { for (i = 0; i < reg_maps->loop_depth; i++) {
@ -3652,7 +3659,7 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
/* Attach GLSL vshader */ /* Attach GLSL vshader */
if (vshader_id) { if (vshader_id) {
const unsigned int max_attribs = 16; /* TODO: Will this always be the case? It is at the moment... */ WORD map = ((IWineD3DBaseShaderImpl *)vshader)->baseShader.reg_maps.input_registers;
char tmp_name[10]; char tmp_name[10];
reorder_shader_id = generate_param_reorder_function(vshader, pshader, gl_info); reorder_shader_id = generate_param_reorder_function(vshader, pshader, gl_info);
@ -3677,12 +3684,13 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
* We have to do this here because we need to know the Program ID * We have to do this here because we need to know the Program ID
* in order to make the bindings work, and it has to be done prior * in order to make the bindings work, and it has to be done prior
* to linking the GLSL program. */ * to linking the GLSL program. */
for (i = 0; i < max_attribs; ++i) { for (i = 0; map; map >>= 1, ++i)
if (((IWineD3DBaseShaderImpl*)vshader)->baseShader.reg_maps.attributes[i]) { {
snprintf(tmp_name, sizeof(tmp_name), "attrib%i", i); if (!(map & 1)) continue;
snprintf(tmp_name, sizeof(tmp_name), "attrib%u", i);
GL_EXTCALL(glBindAttribLocationARB(programId, i, tmp_name)); GL_EXTCALL(glBindAttribLocationARB(programId, i, tmp_name));
} }
}
checkGLcall("glBindAttribLocationARB"); checkGLcall("glBindAttribLocationARB");
list_add_head(&((IWineD3DBaseShaderImpl *)vshader)->baseShader.linked_programs, &entry->vshader_entry); list_add_head(&((IWineD3DBaseShaderImpl *)vshader)->baseShader.linked_programs, &entry->vshader_entry);

View File

@ -134,16 +134,15 @@ static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_id
return FALSE; return FALSE;
} }
BOOL vshader_get_input( BOOL vshader_get_input(IWineD3DVertexShader* iface, BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum)
IWineD3DVertexShader* iface, {
BYTE usage_req, BYTE usage_idx_req, IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
unsigned int* regnum) { WORD map = This->baseShader.reg_maps.input_registers;
unsigned int i;
IWineD3DVertexShaderImpl* This = (IWineD3DVertexShaderImpl*) iface; for (i = 0; map; map >>= 1, ++i)
int i; {
if (!(map & 1)) continue;
for (i = 0; i < MAX_ATTRIBS; i++) {
if (!This->baseShader.reg_maps.attributes[i]) continue;
if (match_usage(This->semantics_in[i].usage, if (match_usage(This->semantics_in[i].usage,
This->semantics_in[i].usage_idx, usage_req, usage_idx_req)) This->semantics_in[i].usage_idx, usage_req, usage_idx_req))

View File

@ -622,11 +622,10 @@ typedef struct shader_reg_maps
char temporary[MAX_REG_TEMP]; /* pixel, vertex */ char temporary[MAX_REG_TEMP]; /* pixel, vertex */
char address[MAX_REG_ADDR]; /* vertex */ char address[MAX_REG_ADDR]; /* vertex */
char packed_output[MAX_REG_OUTPUT]; /* vertex >= 3.0 */ char packed_output[MAX_REG_OUTPUT]; /* vertex >= 3.0 */
char attributes[MAX_ATTRIBS]; /* vertex */
char labels[MAX_LABELS]; /* pixel, vertex */ char labels[MAX_LABELS]; /* pixel, vertex */
DWORD *constf; /* pixel, vertex */ DWORD *constf; /* pixel, vertex */
DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */ DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */
WORD input_registers; /* MAX_REG_INPUT, 12 */ WORD input_registers; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 16 */
WORD integer_constants; /* MAX_CONST_I, 16 */ WORD integer_constants; /* MAX_CONST_I, 16 */
WORD boolean_constants; /* MAX_CONST_B, 16 */ WORD boolean_constants; /* MAX_CONST_B, 16 */