mirror of
https://github.com/reactos/wine.git
synced 2024-11-29 22:50:43 +00:00
wined3d: Always handle WINED3DSPR_INPUT registers as input registers in shader_get_registers_used().
The "attributes" vertexshader field is now derived from the input signature, and only used to speed up matching D3D9 vertex declaration elements to shader inputs. D3D8 and D3D10 both explicitly specify input registers.
This commit is contained in:
parent
2b1ee87328
commit
736aaf7d09
@ -363,26 +363,26 @@ static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HAN
|
||||
}
|
||||
}
|
||||
|
||||
static const char *semantic_names[] =
|
||||
{
|
||||
/* WINED3DDECLUSAGE_POSITION */ "SV_POSITION",
|
||||
/* WINED3DDECLUSAGE_BLENDWEIGHT */ "BLENDWEIGHT",
|
||||
/* WINED3DDECLUSAGE_BLENDINDICES */ "BLENDINDICES",
|
||||
/* WINED3DDECLUSAGE_NORMAL */ "NORMAL",
|
||||
/* WINED3DDECLUSAGE_PSIZE */ "PSIZE",
|
||||
/* WINED3DDECLUSAGE_TEXCOORD */ "TEXCOORD",
|
||||
/* WINED3DDECLUSAGE_TANGENT */ "TANGENT",
|
||||
/* WINED3DDECLUSAGE_BINORMAL */ "BINORMAL",
|
||||
/* WINED3DDECLUSAGE_TESSFACTOR */ "TESSFACTOR",
|
||||
/* WINED3DDECLUSAGE_POSITIONT */ "POSITIONT",
|
||||
/* WINED3DDECLUSAGE_COLOR */ "COLOR",
|
||||
/* WINED3DDECLUSAGE_FOG */ "FOG",
|
||||
/* WINED3DDECLUSAGE_DEPTH */ "DEPTH",
|
||||
/* WINED3DDECLUSAGE_SAMPLE */ "SAMPLE",
|
||||
};
|
||||
|
||||
static const char *shader_semantic_name_from_usage(WINED3DDECLUSAGE usage)
|
||||
{
|
||||
static const char *semantic_names[] =
|
||||
{
|
||||
/* WINED3DDECLUSAGE_POSITION */ "SV_POSITION",
|
||||
/* WINED3DDECLUSAGE_BLENDWEIGHT */ "BLENDWEIGHT",
|
||||
/* WINED3DDECLUSAGE_BLENDINDICES */ "BLENDINDICES",
|
||||
/* WINED3DDECLUSAGE_NORMAL */ "NORMAL",
|
||||
/* WINED3DDECLUSAGE_PSIZE */ "PSIZE",
|
||||
/* WINED3DDECLUSAGE_TEXCOORD */ "TEXCOORD",
|
||||
/* WINED3DDECLUSAGE_TANGENT */ "TANGENT",
|
||||
/* WINED3DDECLUSAGE_BINORMAL */ "BINORMAL",
|
||||
/* WINED3DDECLUSAGE_TESSFACTOR */ "TESSFACTOR",
|
||||
/* WINED3DDECLUSAGE_POSITIONT */ "POSITIONT",
|
||||
/* WINED3DDECLUSAGE_COLOR */ "COLOR",
|
||||
/* WINED3DDECLUSAGE_FOG */ "FOG",
|
||||
/* WINED3DDECLUSAGE_DEPTH */ "DEPTH",
|
||||
/* WINED3DDECLUSAGE_SAMPLE */ "SAMPLE",
|
||||
};
|
||||
|
||||
if (usage >= sizeof(semantic_names) / sizeof(*semantic_names))
|
||||
{
|
||||
FIXME("Unrecognized usage %#x\n", usage);
|
||||
@ -392,6 +392,18 @@ static const char *shader_semantic_name_from_usage(WINED3DDECLUSAGE usage)
|
||||
return semantic_names[usage];
|
||||
}
|
||||
|
||||
WINED3DDECLUSAGE shader_usage_from_semantic_name(const char *name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof(semantic_names) / sizeof(*semantic_names); ++i)
|
||||
{
|
||||
if (!strcmp(name, semantic_names[i])) return i;
|
||||
}
|
||||
|
||||
return ~0U;
|
||||
}
|
||||
|
||||
BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage)
|
||||
{
|
||||
return !strcmp(semantic_name, shader_semantic_name_from_usage(usage));
|
||||
@ -412,8 +424,7 @@ static void shader_signature_from_semantic(struct wined3d_shader_signature_eleme
|
||||
* as an address register. */
|
||||
|
||||
HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
|
||||
struct shader_reg_maps *reg_maps, struct wined3d_shader_attribute *attributes,
|
||||
struct wined3d_shader_signature_element *input_signature,
|
||||
struct shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature,
|
||||
struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size)
|
||||
{
|
||||
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
|
||||
@ -473,19 +484,10 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
|
||||
|
||||
switch (semantic.reg.reg.type)
|
||||
{
|
||||
/* Vshader: mark attributes used
|
||||
* Pshader: mark 3.0 input registers used, save token */
|
||||
/* Mark input registers used. */
|
||||
case WINED3DSPR_INPUT:
|
||||
reg_maps->input_registers |= 1 << semantic.reg.reg.idx;
|
||||
if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX)
|
||||
{
|
||||
attributes[semantic.reg.reg.idx].usage = semantic.usage;
|
||||
attributes[semantic.reg.reg.idx].usage_idx = semantic.usage_idx;
|
||||
}
|
||||
else
|
||||
{
|
||||
shader_signature_from_semantic(&input_signature[semantic.reg.reg.idx], &semantic);
|
||||
}
|
||||
shader_signature_from_semantic(&input_signature[semantic.reg.reg.idx], &semantic);
|
||||
break;
|
||||
|
||||
/* Vshader: mark 3.0 output registers used, save token */
|
||||
|
@ -288,6 +288,7 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader,
|
||||
const struct wined3d_shader_frontend *fe;
|
||||
unsigned int i;
|
||||
HRESULT hr;
|
||||
WORD map;
|
||||
|
||||
TRACE("shader %p, byte_code %p, output_signature %p.\n", shader, byte_code, output_signature);
|
||||
|
||||
@ -317,10 +318,20 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader,
|
||||
shader->min_rel_offset = device->d3d_vshader_constantF;
|
||||
shader->max_rel_offset = 0;
|
||||
hr = shader_get_registers_used((IWineD3DBaseShader *)shader, fe,
|
||||
reg_maps, shader->attributes, NULL, shader->output_signature,
|
||||
reg_maps, shader->input_signature, shader->output_signature,
|
||||
byte_code, device->d3d_vshader_constantF);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
|
||||
map = shader->baseShader.reg_maps.input_registers;
|
||||
for (i = 0; map; map >>= 1, ++i)
|
||||
{
|
||||
if (!(map & 1) || !shader->baseShader.input_signature[i].semantic_name) continue;
|
||||
|
||||
shader->attributes[i].usage = shader_usage_from_semantic_name(shader->input_signature[i].semantic_name);
|
||||
shader->attributes[i].usage_idx = shader->input_signature[i].semantic_idx;
|
||||
}
|
||||
|
||||
if (output_signature)
|
||||
{
|
||||
for (i = 0; i < output_signature->element_count; ++i)
|
||||
@ -666,7 +677,7 @@ static HRESULT pixelshader_set_function(IWineD3DPixelShaderImpl *shader,
|
||||
|
||||
/* Second pass: figure out which registers are used, what the semantics are, etc.. */
|
||||
hr = shader_get_registers_used((IWineD3DBaseShader *)shader, fe,
|
||||
reg_maps, NULL, shader->input_signature, NULL,
|
||||
reg_maps, shader->input_signature, NULL,
|
||||
byte_code, device->d3d_pshader_constantF);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
|
@ -2647,8 +2647,7 @@ unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_m
|
||||
void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer,
|
||||
const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx) DECLSPEC_HIDDEN;
|
||||
HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
|
||||
struct shader_reg_maps *reg_maps, struct wined3d_shader_attribute *attributes,
|
||||
struct wined3d_shader_signature_element *input_signature,
|
||||
struct shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature,
|
||||
struct wined3d_shader_signature_element *output_signature,
|
||||
const DWORD *byte_code, DWORD constf_size) DECLSPEC_HIDDEN;
|
||||
void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device,
|
||||
@ -2656,6 +2655,7 @@ void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *dev
|
||||
BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) DECLSPEC_HIDDEN;
|
||||
const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token) DECLSPEC_HIDDEN;
|
||||
void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction) DECLSPEC_HIDDEN;
|
||||
WINED3DDECLUSAGE shader_usage_from_semantic_name(const char *semantic_name) DECLSPEC_HIDDEN;
|
||||
|
||||
static inline BOOL shader_is_pshader_version(enum wined3d_shader_type type)
|
||||
{
|
||||
@ -2731,6 +2731,7 @@ typedef struct IWineD3DVertexShaderImpl {
|
||||
|
||||
/* Vertex shader input and output semantics */
|
||||
struct wined3d_shader_attribute attributes[MAX_ATTRIBS];
|
||||
struct wined3d_shader_signature_element input_signature[max(MAX_ATTRIBS, MAX_REG_INPUT)];
|
||||
struct wined3d_shader_signature_element output_signature[MAX_REG_OUTPUT];
|
||||
|
||||
UINT min_rel_offset, max_rel_offset;
|
||||
|
Loading…
Reference in New Issue
Block a user