Commit d12e4892 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Store a struct wined3d_shader_dst_param in struct wined3d_shader_semantic.

parent 59148d0b
......@@ -212,11 +212,23 @@ static void shader_delete_constant_list(struct list* clist) {
list_init(clist);
}
static void shader_parse_dst_param(DWORD param, DWORD addr_param, struct wined3d_shader_dst_param *dst)
{
dst->register_type = ((param & WINED3DSP_REGTYPE_MASK) >> WINED3DSP_REGTYPE_SHIFT)
| ((param & WINED3DSP_REGTYPE_MASK2) >> WINED3DSP_REGTYPE_SHIFT2);
dst->register_idx = param & WINED3DSP_REGNUM_MASK;
dst->write_mask = param & WINED3DSP_WRITEMASK_ALL;
dst->modifiers = param & WINED3DSP_DSTMOD_MASK;
dst->token = param;
dst->addr_token = addr_param;
}
/* Note that this does not count the loop register
* as an address register. */
HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_maps *reg_maps,
struct semantic *semantics_in, struct semantic *semantics_out, const DWORD *byte_code)
struct wined3d_shader_semantic *semantics_in, struct wined3d_shader_semantic *semantics_out,
const DWORD *byte_code)
{
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
const SHADER_OPCODE *shader_ins = This->baseShader.shader_ins;
......@@ -286,13 +298,14 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_m
reg_maps->packed_input[regnum] = 1;
semantics_in[regnum].usage = usage;
semantics_in[regnum].reg = param;
shader_parse_dst_param(param, 0, &semantics_in[regnum].reg);
/* Vshader: mark 3.0 output registers used, save token */
} else if (WINED3DSPR_OUTPUT == regtype) {
reg_maps->packed_output[regnum] = 1;
semantics_out[regnum].usage = usage;
semantics_out[regnum].reg = param;
shader_parse_dst_param(param, 0, &semantics_out[regnum].reg);
if (usage & (WINED3DDECLUSAGE_FOG << WINED3DSP_DCL_USAGE_SHIFT))
reg_maps->fog = 1;
......@@ -848,13 +861,9 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
ins.dst_count = curOpcode->dst_token ? 1 : 0;
if (ins.dst_count)
{
dst_param.addr_token = 0;
pToken += shader_get_param(pToken, shader_version, &dst_param.token, &dst_param.addr_token);
dst_param.register_type = ((dst_param.token & WINED3DSP_REGTYPE_MASK) >> WINED3DSP_REGTYPE_SHIFT)
| ((dst_param.token & WINED3DSP_REGTYPE_MASK2) >> WINED3DSP_REGTYPE_SHIFT2);
dst_param.register_idx = dst_param.token & WINED3DSP_REGNUM_MASK;
dst_param.write_mask = dst_param.token & WINED3DSP_WRITEMASK_ALL;
dst_param.modifiers = dst_param.token & WINED3DSP_DSTMOD_MASK;
DWORD param, addr_param = 0;
pToken += shader_get_param(pToken, shader_version, &param, &addr_param);
shader_parse_dst_param(param, addr_param, &dst_param);
}
/* Predication token */
......
......@@ -2993,7 +2993,7 @@ static void pshader_glsl_dp2add(const struct wined3d_shader_instruction *ins)
}
}
static void pshader_glsl_input_pack(SHADER_BUFFER* buffer, const struct semantic* semantics_in,
static void pshader_glsl_input_pack(SHADER_BUFFER *buffer, const struct wined3d_shader_semantic *semantics_in,
IWineD3DPixelShader *iface, enum vertexprocessing_mode vertexprocessing)
{
unsigned int i;
......@@ -3002,7 +3002,6 @@ static void pshader_glsl_input_pack(SHADER_BUFFER* buffer, const struct semantic
for (i = 0; i < MAX_REG_INPUT; i++) {
DWORD usage_token = semantics_in[i].usage;
DWORD register_token = semantics_in[i].reg;
DWORD usage, usage_idx;
char reg_mask[6];
......@@ -3010,7 +3009,7 @@ static void pshader_glsl_input_pack(SHADER_BUFFER* buffer, const struct semantic
if (!usage_token) continue;
usage = (usage_token & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT;
usage_idx = (usage_token & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
shader_glsl_get_write_mask(register_token, reg_mask);
shader_glsl_get_write_mask(semantics_in[i].reg.token, reg_mask);
switch(usage) {
......@@ -3092,12 +3091,11 @@ static void delete_glsl_program_entry(struct shader_glsl_priv *priv, const WineD
HeapFree(GetProcessHeap(), 0, entry);
}
static void handle_ps3_input(SHADER_BUFFER *buffer, const struct semantic *semantics_in,
const struct semantic *semantics_out, const WineD3D_GL_Info *gl_info, const DWORD *map)
static void handle_ps3_input(SHADER_BUFFER *buffer, const struct wined3d_shader_semantic *semantics_in,
const struct wined3d_shader_semantic *semantics_out, const WineD3D_GL_Info *gl_info, const DWORD *map)
{
unsigned int i, j;
DWORD usage_token, usage_token_out;
DWORD register_token, register_token_out;
DWORD usage, usage_idx, usage_out, usage_idx_out;
DWORD *set;
DWORD in_idx;
......@@ -3136,11 +3134,9 @@ static void handle_ps3_input(SHADER_BUFFER *buffer, const struct semantic *seman
sprintf(destination, "IN[%u]", in_idx);
}
register_token = semantics_in[i].reg;
usage = (usage_token & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT;
usage_idx = (usage_token & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
set[map[i]] = shader_glsl_get_write_mask(register_token, reg_mask);
set[map[i]] = shader_glsl_get_write_mask(semantics_in[i].reg.token, reg_mask);
if(!semantics_out) {
switch(usage) {
......@@ -3180,11 +3176,10 @@ static void handle_ps3_input(SHADER_BUFFER *buffer, const struct semantic *seman
for(j = 0; j < MAX_REG_OUTPUT; j++) {
usage_token_out = semantics_out[j].usage;
if (!usage_token_out) continue;
register_token_out = semantics_out[j].reg;
usage_out = (usage_token_out & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT;
usage_idx_out = (usage_token_out & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
shader_glsl_get_write_mask(register_token_out, reg_mask_out);
shader_glsl_get_write_mask(semantics_out[j].reg.token, reg_mask_out);
if(usage == usage_out &&
usage_idx == usage_idx_out) {
......@@ -3256,10 +3251,9 @@ static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexs
unsigned int i;
SHADER_BUFFER buffer;
DWORD usage_token;
DWORD register_token;
DWORD usage, usage_idx, writemask;
char reg_mask[6];
const struct semantic *semantics_out, *semantics_in;
const struct wined3d_shader_semantic *semantics_out, *semantics_in;
shader_buffer_init(&buffer);
......@@ -3291,11 +3285,10 @@ static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexs
for(i = 0; i < MAX_REG_OUTPUT; i++) {
usage_token = semantics_out[i].usage;
if (!usage_token) continue;
register_token = semantics_out[i].reg;
usage = (usage_token & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT;
usage_idx = (usage_token & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
writemask = shader_glsl_get_write_mask(register_token, reg_mask);
writemask = shader_glsl_get_write_mask(semantics_out[i].reg.token, reg_mask);
switch(usage) {
case WINED3DDECLUSAGE_COLOR:
......@@ -3347,11 +3340,10 @@ static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexs
for(i = 0; i < MAX_REG_OUTPUT; i++) {
usage_token = semantics_out[i].usage;
if (!usage_token) continue;
register_token = semantics_out[i].reg;
usage = (usage_token & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT;
usage_idx = (usage_token & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
shader_glsl_get_write_mask(register_token, reg_mask);
shader_glsl_get_write_mask(semantics_out[i].reg.token, reg_mask);
switch(usage) {
case WINED3DDECLUSAGE_POSITION:
......
......@@ -183,7 +183,12 @@ static void vshader_set_input(
WINED3DSP_WRITEMASK_ALL | (WINED3DSPR_INPUT << WINED3DSP_REGTYPE_SHIFT) | regnum;
This->semantics_in[regnum].usage = usage_token;
This->semantics_in[regnum].reg = reg_token;
This->semantics_in[regnum].reg.register_type = WINED3DSPR_INPUT;
This->semantics_in[regnum].reg.register_idx = regnum;
This->semantics_in[regnum].reg.write_mask = WINED3DSP_WRITEMASK_ALL;
This->semantics_in[regnum].reg.modifiers = 0;
This->semantics_in[regnum].reg.token = reg_token;
This->semantics_in[regnum].reg.addr_token = 0;
}
static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_idx2) {
......
......@@ -406,12 +406,6 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
WINED3DSIH_TABLE_SIZE
};
typedef struct semantic
{
DWORD usage;
DWORD reg;
} semantic;
typedef struct shader_reg_maps
{
DWORD shader_version;
......@@ -476,6 +470,12 @@ struct wined3d_shader_instruction
UINT src_count;
};
struct wined3d_shader_semantic
{
DWORD usage;
struct wined3d_shader_dst_param reg;
};
typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
struct shader_caps {
......@@ -2341,7 +2341,8 @@ void shader_buffer_init(struct SHADER_BUFFER *buffer);
void shader_buffer_free(struct SHADER_BUFFER *buffer);
void shader_cleanup(IWineD3DBaseShader *iface);
HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_maps *reg_maps,
struct semantic *semantics_in, struct semantic *semantics_out, const DWORD *byte_code);
struct wined3d_shader_semantic *semantics_in, struct wined3d_shader_semantic *semantics_out,
const DWORD *byte_code);
void shader_init(struct IWineD3DBaseShaderClass *shader,
IWineD3DDevice *device, const SHADER_OPCODE *instruction_table);
void shader_trace_init(const DWORD *byte_code, const SHADER_OPCODE *opcode_table);
......@@ -2439,8 +2440,8 @@ typedef struct IWineD3DVertexShaderImpl {
UINT num_gl_shaders, shader_array_size;
/* Vertex shader input and output semantics */
semantic semantics_in [MAX_ATTRIBS];
semantic semantics_out [MAX_REG_OUTPUT];
struct wined3d_shader_semantic semantics_in[MAX_ATTRIBS];
struct wined3d_shader_semantic semantics_out[MAX_REG_OUTPUT];
UINT min_rel_offset, max_rel_offset;
UINT rel_offset;
......@@ -2474,7 +2475,7 @@ typedef struct IWineD3DPixelShaderImpl {
IUnknown *parent;
/* Pixel shader input semantics */
semantic semantics_in [MAX_REG_INPUT];
struct wined3d_shader_semantic semantics_in[MAX_REG_INPUT];
DWORD input_reg_map[MAX_REG_INPUT];
BOOL input_reg_used[MAX_REG_INPUT];
int declared_in_count;
......
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