Commit c59f036e authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Recognize SM4 dcl_immediateConstantBuffer.

parent 64c772dc
...@@ -5227,6 +5227,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL ...@@ -5227,6 +5227,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL
/* WINED3DSIH_CUT */ NULL, /* WINED3DSIH_CUT */ NULL,
/* WINED3DSIH_DCL */ shader_hw_nop, /* WINED3DSIH_DCL */ shader_hw_nop,
/* WINED3DSIH_DCL_CONSTANT_BUFFER */ shader_hw_nop, /* WINED3DSIH_DCL_CONSTANT_BUFFER */ shader_hw_nop,
/* WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER */ NULL,
/* WINED3DSIH_DCL_INPUT_PRIMITIVE */ shader_hw_nop, /* WINED3DSIH_DCL_INPUT_PRIMITIVE */ shader_hw_nop,
/* WINED3DSIH_DCL_OUTPUT_TOPOLOGY */ shader_hw_nop, /* WINED3DSIH_DCL_OUTPUT_TOPOLOGY */ shader_hw_nop,
/* WINED3DSIH_DCL_TEMPS */ NULL, /* WINED3DSIH_DCL_TEMPS */ NULL,
......
...@@ -8010,6 +8010,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB ...@@ -8010,6 +8010,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_CUT */ shader_glsl_cut, /* WINED3DSIH_CUT */ shader_glsl_cut,
/* WINED3DSIH_DCL */ shader_glsl_nop, /* WINED3DSIH_DCL */ shader_glsl_nop,
/* WINED3DSIH_DCL_CONSTANT_BUFFER */ shader_glsl_nop, /* WINED3DSIH_DCL_CONSTANT_BUFFER */ shader_glsl_nop,
/* WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER */ NULL,
/* WINED3DSIH_DCL_INPUT_PRIMITIVE */ shader_glsl_nop, /* WINED3DSIH_DCL_INPUT_PRIMITIVE */ shader_glsl_nop,
/* WINED3DSIH_DCL_OUTPUT_TOPOLOGY */ shader_glsl_nop, /* WINED3DSIH_DCL_OUTPUT_TOPOLOGY */ shader_glsl_nop,
/* WINED3DSIH_DCL_TEMPS */ shader_glsl_nop, /* WINED3DSIH_DCL_TEMPS */ shader_glsl_nop,
......
...@@ -55,6 +55,7 @@ static const char * const shader_opcode_names[] = ...@@ -55,6 +55,7 @@ static const char * const shader_opcode_names[] =
/* WINED3DSIH_CUT */ "cut", /* WINED3DSIH_CUT */ "cut",
/* WINED3DSIH_DCL */ "dcl", /* WINED3DSIH_DCL */ "dcl",
/* WINED3DSIH_DCL_CONSTANT_BUFFER */ "dcl_constantBuffer", /* WINED3DSIH_DCL_CONSTANT_BUFFER */ "dcl_constantBuffer",
/* WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER */ "dcl_immediateConstantBuffer",
/* WINED3DSIH_DCL_INPUT_PRIMITIVE */ "dcl_inputPrimitive", /* WINED3DSIH_DCL_INPUT_PRIMITIVE */ "dcl_inputPrimitive",
/* WINED3DSIH_DCL_OUTPUT_TOPOLOGY */ "dcl_outputTopology", /* WINED3DSIH_DCL_OUTPUT_TOPOLOGY */ "dcl_outputTopology",
/* WINED3DSIH_DCL_TEMPS */ "dcl_temps", /* WINED3DSIH_DCL_TEMPS */ "dcl_temps",
...@@ -811,6 +812,12 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st ...@@ -811,6 +812,12 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
else else
reg_maps->cb_sizes[reg->idx[0].offset] = reg->idx[1].offset; reg_maps->cb_sizes[reg->idx[0].offset] = reg->idx[1].offset;
} }
else if (ins.handler_idx == WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER)
{
if (reg_maps->icb)
FIXME("Multiple immediate constant buffers.\n");
reg_maps->icb = ins.declaration.icb;
}
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PRIMITIVE) else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PRIMITIVE)
{ {
if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY) if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
...@@ -1822,6 +1829,19 @@ static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe ...@@ -1822,6 +1829,19 @@ static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe
shader_dump_src_param(&ins.declaration.src, &shader_version); shader_dump_src_param(&ins.declaration.src, &shader_version);
TRACE(", %s", ins.flags & WINED3DSI_INDEXED_DYNAMIC ? "dynamicIndexed" : "immediateIndexed"); TRACE(", %s", ins.flags & WINED3DSI_INDEXED_DYNAMIC ? "dynamicIndexed" : "immediateIndexed");
} }
else if (ins.handler_idx == WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER)
{
TRACE("%s {\n", shader_opcode_names[ins.handler_idx]);
for (i = 0; i < ins.declaration.icb->element_count / 4; ++i)
{
TRACE("{ 0x%08x, 0x%08x, 0x%08x, 0x%08x },\n",
ins.declaration.icb->data[4 * i + 0],
ins.declaration.icb->data[4 * i + 1],
ins.declaration.icb->data[4 * i + 2],
ins.declaration.icb->data[4 * i + 3]);
}
TRACE("}");
}
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PRIMITIVE else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PRIMITIVE
|| ins.handler_idx == WINED3DSIH_DCL_OUTPUT_TOPOLOGY) || ins.handler_idx == WINED3DSIH_DCL_OUTPUT_TOPOLOGY)
{ {
......
...@@ -41,6 +41,9 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_bytecode); ...@@ -41,6 +41,9 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_bytecode);
#define WINED3D_SM4_INDEX_TYPE_SHIFT 11 #define WINED3D_SM4_INDEX_TYPE_SHIFT 11
#define WINED3D_SM4_INDEX_TYPE_MASK (0x1u << WINED3D_SM4_INDEX_TYPE_SHIFT) #define WINED3D_SM4_INDEX_TYPE_MASK (0x1u << WINED3D_SM4_INDEX_TYPE_SHIFT)
#define WINED3D_SM4_SHADER_DATA_TYPE_SHIFT 11
#define WINED3D_SM4_SHADER_DATA_TYPE_MASK (0xfu << WINED3D_SM4_SHADER_DATA_TYPE_SHIFT)
#define WINED3D_SM4_OPCODE_MASK 0xff #define WINED3D_SM4_OPCODE_MASK 0xff
#define WINED3D_SM4_REGISTER_MODIFIER (0x1u << 31) #define WINED3D_SM4_REGISTER_MODIFIER (0x1u << 31)
...@@ -121,6 +124,7 @@ enum wined3d_sm4_opcode ...@@ -121,6 +124,7 @@ enum wined3d_sm4_opcode
WINED3D_SM4_OP_MAD = 0x32, WINED3D_SM4_OP_MAD = 0x32,
WINED3D_SM4_OP_MIN = 0x33, WINED3D_SM4_OP_MIN = 0x33,
WINED3D_SM4_OP_MAX = 0x34, WINED3D_SM4_OP_MAX = 0x34,
WINED3D_SM4_OP_SHADER_DATA = 0x35,
WINED3D_SM4_OP_MOV = 0x36, WINED3D_SM4_OP_MOV = 0x36,
WINED3D_SM4_OP_MOVC = 0x37, WINED3D_SM4_OP_MOVC = 0x37,
WINED3D_SM4_OP_MUL = 0x38, WINED3D_SM4_OP_MUL = 0x38,
...@@ -219,6 +223,12 @@ enum wined3d_sm4_data_type ...@@ -219,6 +223,12 @@ enum wined3d_sm4_data_type
WINED3D_SM4_DATA_FLOAT = 0x5, WINED3D_SM4_DATA_FLOAT = 0x5,
}; };
enum wined3d_sm4_shader_data_type
{
WINED3D_SM4_SHADER_DATA_IMMEDIATE_CONSTANT_BUFFER = 0x3,
WINED3D_SM4_SHADER_DATA_MESSAGE = 0x4,
};
struct wined3d_shader_src_param_entry struct wined3d_shader_src_param_entry
{ {
struct list entry; struct list entry;
...@@ -240,6 +250,7 @@ struct wined3d_sm4_data ...@@ -240,6 +250,7 @@ struct wined3d_sm4_data
struct wined3d_shader_dst_param dst_param[2]; struct wined3d_shader_dst_param dst_param[2];
struct list src_free; struct list src_free;
struct list src; struct list src;
struct wined3d_shader_immediate_constant_buffer icb;
}; };
struct wined3d_sm4_opcode_info struct wined3d_sm4_opcode_info
...@@ -308,6 +319,7 @@ static const struct wined3d_sm4_opcode_info opcode_table[] = ...@@ -308,6 +319,7 @@ static const struct wined3d_sm4_opcode_info opcode_table[] =
{WINED3D_SM4_OP_MAD, WINED3DSIH_MAD, "F", "FFF"}, {WINED3D_SM4_OP_MAD, WINED3DSIH_MAD, "F", "FFF"},
{WINED3D_SM4_OP_MIN, WINED3DSIH_MIN, "F", "FF"}, {WINED3D_SM4_OP_MIN, WINED3DSIH_MIN, "F", "FF"},
{WINED3D_SM4_OP_MAX, WINED3DSIH_MAX, "F", "FF"}, {WINED3D_SM4_OP_MAX, WINED3DSIH_MAX, "F", "FF"},
{WINED3D_SM4_OP_SHADER_DATA, WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER, "", ""},
{WINED3D_SM4_OP_MOV, WINED3DSIH_MOV, "F", "F"}, {WINED3D_SM4_OP_MOV, WINED3DSIH_MOV, "F", "F"},
{WINED3D_SM4_OP_MOVC, WINED3DSIH_MOVC, "F", "UFF"}, {WINED3D_SM4_OP_MOVC, WINED3DSIH_MOVC, "F", "UFF"},
{WINED3D_SM4_OP_MUL, WINED3DSIH_MUL, "F", "FF"}, {WINED3D_SM4_OP_MUL, WINED3DSIH_MUL, "F", "FF"},
...@@ -804,7 +816,11 @@ static void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct wi ...@@ -804,7 +816,11 @@ static void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct wi
opcode_token = *(*ptr)++; opcode_token = *(*ptr)++;
opcode = opcode_token & WINED3D_SM4_OPCODE_MASK; opcode = opcode_token & WINED3D_SM4_OPCODE_MASK;
len = ((opcode_token & WINED3D_SM4_INSTRUCTION_LENGTH_MASK) >> WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT) - 1;
len = ((opcode_token & WINED3D_SM4_INSTRUCTION_LENGTH_MASK) >> WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT);
if (!len)
len = **ptr;
--len;
if (TRACE_ON(d3d_bytecode)) if (TRACE_ON(d3d_bytecode))
{ {
...@@ -842,7 +858,33 @@ static void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct wi ...@@ -842,7 +858,33 @@ static void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct wi
FIXME("Skipping modifier 0x%08x.\n", modifier); FIXME("Skipping modifier 0x%08x.\n", modifier);
} }
if (opcode == WINED3D_SM4_OP_DCL_RESOURCE) if (opcode == WINED3D_SM4_OP_SHADER_DATA)
{
unsigned int icb_size;
enum wined3d_sm4_shader_data_type type;
type = (opcode_token & WINED3D_SM4_SHADER_DATA_TYPE_MASK) >> WINED3D_SM4_SHADER_DATA_TYPE_SHIFT;
if (type != WINED3D_SM4_SHADER_DATA_IMMEDIATE_CONSTANT_BUFFER)
{
FIXME("Unhandled shader data type %#x.\n", type);
ins->handler_idx = WINED3DSIH_TABLE_SIZE;
return;
}
++p;
icb_size = len - 1;
if (icb_size % 4 || icb_size > MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE)
{
FIXME("Unexpected immediate constant buffer size %u.\n", len);
ins->handler_idx = WINED3DSIH_TABLE_SIZE;
return;
}
ins->declaration.icb = &priv->icb;
ins->declaration.icb->element_count = len;
memcpy(ins->declaration.icb->data, p, sizeof(*p) * icb_size);
}
else if (opcode == WINED3D_SM4_OP_DCL_RESOURCE)
{ {
enum wined3d_sm4_resource_type resource_type; enum wined3d_sm4_resource_type resource_type;
enum wined3d_sm4_data_type data_type; enum wined3d_sm4_data_type data_type;
......
...@@ -460,6 +460,8 @@ enum wined3d_shader_rel_op ...@@ -460,6 +460,8 @@ enum wined3d_shader_rel_op
* Shader model 3 according to msdn (and for software shaders) */ * Shader model 3 according to msdn (and for software shaders) */
#define MAX_LABELS 16 #define MAX_LABELS 16
#define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
struct wined3d_string_buffer struct wined3d_string_buffer
{ {
struct list entry; struct list entry;
...@@ -485,6 +487,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER ...@@ -485,6 +487,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
WINED3DSIH_CUT, WINED3DSIH_CUT,
WINED3DSIH_DCL, WINED3DSIH_DCL,
WINED3DSIH_DCL_CONSTANT_BUFFER, WINED3DSIH_DCL_CONSTANT_BUFFER,
WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER,
WINED3DSIH_DCL_INPUT_PRIMITIVE, WINED3DSIH_DCL_INPUT_PRIMITIVE,
WINED3DSIH_DCL_OUTPUT_TOPOLOGY, WINED3DSIH_DCL_OUTPUT_TOPOLOGY,
WINED3DSIH_DCL_TEMPS, WINED3DSIH_DCL_TEMPS,
...@@ -640,6 +643,12 @@ struct wined3d_shader_sampler_map ...@@ -640,6 +643,12 @@ struct wined3d_shader_sampler_map
size_t count; size_t count;
}; };
struct wined3d_shader_immediate_constant_buffer
{
UINT element_count;
DWORD data[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE];
};
#define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor)) #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
struct wined3d_shader_reg_maps struct wined3d_shader_reg_maps
...@@ -650,6 +659,7 @@ struct wined3d_shader_reg_maps ...@@ -650,6 +659,7 @@ struct wined3d_shader_reg_maps
WORD labels; /* MAX_LABELS, 16 */ WORD labels; /* MAX_LABELS, 16 */
DWORD temporary; /* MAX_REG_TEMP, 32 */ DWORD temporary; /* MAX_REG_TEMP, 32 */
DWORD *constf; /* pixel, vertex */ DWORD *constf; /* pixel, vertex */
struct wined3d_shader_immediate_constant_buffer *icb;
union union
{ {
DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */ DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */
...@@ -772,6 +782,7 @@ struct wined3d_shader_instruction ...@@ -772,6 +782,7 @@ struct wined3d_shader_instruction
enum wined3d_primitive_type primitive_type; enum wined3d_primitive_type primitive_type;
struct wined3d_shader_src_param src; struct wined3d_shader_src_param src;
UINT count; UINT count;
struct wined3d_shader_immediate_constant_buffer *icb;
} declaration; } declaration;
}; };
......
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