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

View File

@ -964,10 +964,17 @@ static void shader_generate_glsl_declarations(IWineD3DBaseShader *iface, const s
}
/* Declare attributes */
for (i = 0; i < This->baseShader.limits.attributes; i++) {
if (reg_maps->attributes[i])
if (reg_maps->shader_version.type == WINED3D_SHADER_TYPE_VERTEX)
{
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);
}
}
/* Declare loop registers aLx */
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 */
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];
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
* in order to make the bindings work, and it has to be done prior
* to linking the GLSL program. */
for (i = 0; i < max_attribs; ++i) {
if (((IWineD3DBaseShaderImpl*)vshader)->baseShader.reg_maps.attributes[i]) {
snprintf(tmp_name, sizeof(tmp_name), "attrib%i", i);
for (i = 0; map; map >>= 1, ++i)
{
if (!(map & 1)) continue;
snprintf(tmp_name, sizeof(tmp_name), "attrib%u", i);
GL_EXTCALL(glBindAttribLocationARB(programId, i, tmp_name));
}
}
checkGLcall("glBindAttribLocationARB");
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;
}
BOOL vshader_get_input(
IWineD3DVertexShader* iface,
BYTE usage_req, BYTE usage_idx_req,
unsigned int* regnum) {
BOOL vshader_get_input(IWineD3DVertexShader* iface, BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum)
{
IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
int i;
WORD map = This->baseShader.reg_maps.input_registers;
unsigned int i;
for (i = 0; i < MAX_ATTRIBS; i++) {
if (!This->baseShader.reg_maps.attributes[i]) continue;
for (i = 0; map; map >>= 1, ++i)
{
if (!(map & 1)) continue;
if (match_usage(This->semantics_in[i].usage,
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 address[MAX_REG_ADDR]; /* vertex */
char packed_output[MAX_REG_OUTPUT]; /* vertex >= 3.0 */
char attributes[MAX_ATTRIBS]; /* vertex */
char labels[MAX_LABELS]; /* pixel, vertex */
DWORD *constf; /* pixel, vertex */
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 boolean_constants; /* MAX_CONST_B, 16 */