Commit 4d39cb56 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Handle WINED3DSPR_CONSTBUFFER registers in the GLSL shader backend.

parent e55416a1
...@@ -994,6 +994,12 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont ...@@ -994,6 +994,12 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
if (shader->limits.constant_bool > 0 && reg_maps->boolean_constants) if (shader->limits.constant_bool > 0 && reg_maps->boolean_constants)
shader_addline(buffer, "uniform bool %s_b[%u];\n", prefix, shader->limits.constant_bool); shader_addline(buffer, "uniform bool %s_b[%u];\n", prefix, shader->limits.constant_bool);
for (i = 0; i < WINED3D_MAX_CBS; ++i)
{
if (reg_maps->cb_sizes[i])
shader_addline(buffer, "uniform vec4 %s_cb%u[%u];\n", prefix, i, reg_maps->cb_sizes[i]);
}
if (!pshader) if (!pshader)
{ {
shader_addline(buffer, "uniform vec4 posFixup;\n"); shader_addline(buffer, "uniform vec4 posFixup;\n");
...@@ -1530,8 +1536,21 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * ...@@ -1530,8 +1536,21 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
} }
break; break;
case WINED3DSPR_CONSTBUFFER:
if (reg->rel_addr)
{
struct glsl_src_param rel_param;
shader_glsl_add_src_param(ins, reg->rel_addr, WINED3DSP_WRITEMASK_0, &rel_param);
sprintf(register_name, "%s_cb%u[%s + %u]", prefix, reg->idx, rel_param.param_str, reg->array_idx);
}
else
{
sprintf(register_name, "%s_cb%u[%u]", prefix, reg->idx, reg->array_idx);
}
break;
default: default:
FIXME("Unhandled register name Type(%d)\n", reg->type); FIXME("Unhandled register type %#x.\n", reg->type);
sprintf(register_name, "unrecognized_register"); sprintf(register_name, "unrecognized_register");
break; break;
} }
......
...@@ -533,6 +533,14 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st ...@@ -533,6 +533,14 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
break; break;
} }
} }
else if (ins.handler_idx == WINED3DSIH_DCL_CONSTANT_BUFFER)
{
struct wined3d_shader_register *reg = &ins.declaration.src.reg;
if (reg->idx >= WINED3D_MAX_CBS)
ERR("Invalid CB index %u.\n", reg->idx);
else
reg_maps->cb_sizes[reg->idx] = reg->array_idx;
}
else if (ins.handler_idx == WINED3DSIH_DEF) else if (ins.handler_idx == WINED3DSIH_DEF)
{ {
struct wined3d_shader_lconst *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(*lconst)); struct wined3d_shader_lconst *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(*lconst));
......
...@@ -409,6 +409,7 @@ enum wined3d_shader_rel_op ...@@ -409,6 +409,7 @@ enum wined3d_shader_rel_op
#define MAX_REG_OUTPUT 32 #define MAX_REG_OUTPUT 32
#define MAX_CONST_I 16 #define MAX_CONST_I 16
#define MAX_CONST_B 16 #define MAX_CONST_B 16
#define WINED3D_MAX_CBS 15
/* FIXME: This needs to go up to 2048 for /* FIXME: This needs to go up to 2048 for
* Shader model 3 according to msdn (and for software shaders) */ * Shader model 3 according to msdn (and for software shaders) */
...@@ -571,6 +572,7 @@ struct wined3d_shader_reg_maps ...@@ -571,6 +572,7 @@ struct wined3d_shader_reg_maps
WORD boolean_constants; /* MAX_CONST_B, 16 */ WORD boolean_constants; /* MAX_CONST_B, 16 */
WORD local_int_consts; /* MAX_CONST_I, 16 */ WORD local_int_consts; /* MAX_CONST_I, 16 */
WORD local_bool_consts; /* MAX_CONST_B, 16 */ WORD local_bool_consts; /* MAX_CONST_B, 16 */
UINT cb_sizes[WINED3D_MAX_CBS];
enum wined3d_sampler_texture_type sampler_type[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)]; enum wined3d_sampler_texture_type sampler_type[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)];
BYTE bumpmat; /* MAX_TEXTURES, 8 */ BYTE bumpmat; /* MAX_TEXTURES, 8 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment