#define FOURCC_SHDR FOURCC('S', 'H', 'D', 'R')
#define FOURCC_SHEX FOURCC('S', 'H', 'E', 'X')
#define FOURCC_STAT FOURCC('S', 'T', 'A', 'T')
+#define FOURCC_PCSG FOURCC('P', 'C', 'S', 'G')
/* this is always little-endian! */
struct dxbc_chunk_header
return chunk;
}
-static inline dxbc_chunk_signature* dxbc_find_signature(const void* data, int size, bool output)
+#define DXBC_FIND_INPUT_SIGNATURE 0
+#define DXBC_FIND_OUTPUT_SIGNATURE 1
+#define DXBC_FIND_PATCH_SIGNATURE 2
+
+static inline dxbc_chunk_signature* dxbc_find_signature(const void* data, int size, unsigned kind)
{
- return (dxbc_chunk_signature*)dxbc_find_chunk(data, size, output ? FOURCC_OSGN : FOURCC_ISGN);
+ unsigned fourcc;
+ switch(kind) {
+ case DXBC_FIND_INPUT_SIGNATURE: fourcc = FOURCC_ISGN; break;
+ case DXBC_FIND_OUTPUT_SIGNATURE: fourcc = FOURCC_OSGN; break;
+ case DXBC_FIND_PATCH_SIGNATURE: fourcc = FOURCC_PCSG; break;
+ default:
+ return NULL;
+ }
+ return (dxbc_chunk_signature*)dxbc_find_chunk(data, size, fourcc);
}
struct _D3D11_SIGNATURE_PARAMETER_DESC;
{}
};
+struct _D3D11_SIGNATURE_PARAMETER_DESC;
+
struct sm4_program
{
sm4_token_version version;
std::vector<sm4_dcl*> dcls;
std::vector<sm4_insn*> insns;
+ _D3D11_SIGNATURE_PARAMETER_DESC* params_in;
+ _D3D11_SIGNATURE_PARAMETER_DESC* params_out;
+ _D3D11_SIGNATURE_PARAMETER_DESC* params_patch;
+ unsigned num_params_in;
+ unsigned num_params_out;
+ unsigned num_params_patch;
+
/* for ifs, the insn number of the else or endif if there is no else
* for elses, the insn number of the endif
* for endifs, the insn number of the if
{
memset(&version, 0, sizeof(version));
labels_found = false;
+ num_params_in = num_params_out = num_params_patch = 0;
}
~sm4_program()
delete *i;
for(std::vector<sm4_insn*>::iterator i = insns.begin(), e = insns.end(); i != e; ++i)
delete *i;
+
+ if(num_params_in)
+ free(params_in);
+ if(num_params_out)
+ free(params_out);
+ if(num_params_patch)
+ free(params_patch);
}
void dump();
param.SemanticIndex = bswap_le32(sig->elements[i].semantic_index);
param.SystemValueType = (D3D_NAME)bswap_le32(sig->elements[i].system_value_type);
param.ComponentType = (D3D_REGISTER_COMPONENT_TYPE)bswap_le32(sig->elements[i].component_type);
+ param.Register = bswap_le32(sig->elements[i].register_num);
param.Mask = sig->elements[i].mask;
param.ReadWriteMask = sig->elements[i].read_write_mask;
param.Stream = sig->elements[i].stream;
ID3D10Blob **signature_blob
)
{
- dxbc_chunk_signature* sig = dxbc_find_signature(shader_bytecode, bytecode_length, false);
+ dxbc_chunk_signature* sig = dxbc_find_signature(shader_bytecode, bytecode_length, DXBC_FIND_INPUT_SIGNATURE);
if(!sig)
return E_FAIL;
ID3D10Blob **signature_blob
)
{
- dxbc_chunk_signature* sig = dxbc_find_signature(shader_bytecode, bytecode_length, true);
+ dxbc_chunk_signature* sig = dxbc_find_signature(shader_bytecode, bytecode_length, DXBC_FIND_OUTPUT_SIGNATURE);
if(!sig)
return E_FAIL;
)
{
dxbc_chunk_signature* sigs[2];
- sigs[0] = dxbc_find_signature(shader_bytecode, bytecode_length, false);
+ sigs[0] = dxbc_find_signature(shader_bytecode, bytecode_length, DXBC_FIND_INPUT_SIGNATURE);
if(!sigs[0])
return E_FAIL;
- sigs[1] = dxbc_find_signature(shader_bytecode, bytecode_length, true);
+ sigs[1] = dxbc_find_signature(shader_bytecode, bytecode_length, DXBC_FIND_OUTPUT_SIGNATURE);
if(!sigs[1])
return E_FAIL;
// putting semantics matching in the core API seems to be a (minor) design mistake
- struct dxbc_chunk_signature* sig = dxbc_find_signature(shader_bytecode_with_input_signature, bytecode_length, false);
+ struct dxbc_chunk_signature* sig = dxbc_find_signature(shader_bytecode_with_input_signature, bytecode_length, DXBC_FIND_INPUT_SIGNATURE);
D3D11_SIGNATURE_PARAMETER_DESC* params;
unsigned num_params = dxbc_parse_signature(sig, ¶ms);
if(dump)
sm4->dump();
+ struct dxbc_chunk_signature* sig;
+
+ sig = dxbc_find_signature(shader_bytecode, bytecode_length, DXBC_FIND_INPUT_SIGNATURE);
+ if(sig)
+ sm4->num_params_in = dxbc_parse_signature(sig, &sm4->params_in);
+
+ sig = dxbc_find_signature(shader_bytecode, bytecode_length, DXBC_FIND_OUTPUT_SIGNATURE);
+ if(sig)
+ sm4->num_params_out = dxbc_parse_signature(sig, &sm4->params_out);
+
+ sig = dxbc_find_signature(shader_bytecode, bytecode_length, DXBC_FIND_PATCH_SIGNATURE);
+ if(sig)
+ sm4->num_params_patch = dxbc_parse_signature(sig, &sm4->params_patch);
+
struct pipe_shader_state tgsi_shader;
memset(&tgsi_shader, 0, sizeof(tgsi_shader));
tgsi_shader.tokens = (const tgsi_token*)sm4_to_tgsi(*sm4);