d3dx9: Support skip_constants parameter for effect.
Signed-off-by: Paul Gofman <gofmanp@gmail.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6498a03a8e
commit
4b11a99108
|
@ -347,7 +347,8 @@ struct d3dx_parameter *get_parameter_by_name(struct d3dx9_base_effect *base,
|
|||
|
||||
HRESULT d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_code,
|
||||
unsigned int byte_code_size, D3DXPARAMETER_TYPE type,
|
||||
struct d3dx_param_eval **peval, ULONG64 *version_counter) DECLSPEC_HIDDEN;
|
||||
struct d3dx_param_eval **peval, ULONG64 *version_counter,
|
||||
const char **skip_constants, unsigned int skip_constants_count) DECLSPEC_HIDDEN;
|
||||
void d3dx_free_param_eval(struct d3dx_param_eval *peval) DECLSPEC_HIDDEN;
|
||||
HRESULT d3dx_evaluate_parameter(struct d3dx_param_eval *peval,
|
||||
const struct d3dx_parameter *param, void *param_value) DECLSPEC_HIDDEN;
|
||||
|
@ -357,6 +358,7 @@ BOOL is_param_eval_input_dirty(struct d3dx_param_eval *peval, ULONG64 update_ver
|
|||
|
||||
struct ctab_constant {
|
||||
D3DXCONSTANT_DESC desc;
|
||||
WORD constantinfo_reserved;
|
||||
struct ctab_constant *constants;
|
||||
};
|
||||
|
||||
|
|
|
@ -5942,7 +5942,8 @@ static HRESULT d3dx9_create_object(struct d3dx9_base_effect *base, struct d3dx_o
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT d3dx9_parse_array_selector(struct d3dx9_base_effect *base, struct d3dx_parameter *param)
|
||||
static HRESULT d3dx9_parse_array_selector(struct d3dx9_base_effect *base, struct d3dx_parameter *param,
|
||||
const char **skip_constants, unsigned int skip_constants_count)
|
||||
{
|
||||
DWORD string_size;
|
||||
struct d3dx_object *object = &base->objects[param->object_id];
|
||||
|
@ -5968,7 +5969,7 @@ static HRESULT d3dx9_parse_array_selector(struct d3dx9_base_effect *base, struct
|
|||
FIXME("Unaligned string_size %u.\n", string_size);
|
||||
if (FAILED(ret = d3dx_create_param_eval(base, (DWORD *)(ptr + string_size) + 1,
|
||||
object->size - (string_size + sizeof(DWORD)), D3DXPT_INT, ¶m->param_eval,
|
||||
get_version_counter_ptr(base))))
|
||||
get_version_counter_ptr(base), NULL, 0)))
|
||||
return ret;
|
||||
ret = D3D_OK;
|
||||
param = param->u.referenced_param;
|
||||
|
@ -5988,7 +5989,8 @@ static HRESULT d3dx9_parse_array_selector(struct d3dx9_base_effect *base, struct
|
|||
TRACE("Creating preshader for object %u.\n", param->members[i].object_id);
|
||||
object = &base->objects[param->members[i].object_id];
|
||||
if (FAILED(ret = d3dx_create_param_eval(base, object->data, object->size, param->type,
|
||||
¶m->members[i].param_eval, get_version_counter_ptr(base))))
|
||||
¶m->members[i].param_eval, get_version_counter_ptr(base),
|
||||
skip_constants, skip_constants_count)))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -5996,7 +5998,8 @@ static HRESULT d3dx9_parse_array_selector(struct d3dx9_base_effect *base, struct
|
|||
return ret;
|
||||
}
|
||||
|
||||
static HRESULT d3dx9_parse_resource(struct d3dx9_base_effect *base, const char *data, const char **ptr)
|
||||
static HRESULT d3dx9_parse_resource(struct d3dx9_base_effect *base, const char *data, const char **ptr,
|
||||
const char **skip_constants, unsigned int skip_constants_count)
|
||||
{
|
||||
DWORD technique_index;
|
||||
DWORD index, state_index, usage, element_index;
|
||||
|
@ -6103,7 +6106,8 @@ static HRESULT d3dx9_parse_resource(struct d3dx9_base_effect *base, const char *
|
|||
if (FAILED(hr = d3dx9_create_object(base, object)))
|
||||
return hr;
|
||||
if (FAILED(hr = d3dx_create_param_eval(base, object->data, object->size, param->type,
|
||||
¶m->param_eval, get_version_counter_ptr(base))))
|
||||
¶m->param_eval, get_version_counter_ptr(base),
|
||||
skip_constants, skip_constants_count)))
|
||||
return hr;
|
||||
}
|
||||
break;
|
||||
|
@ -6116,7 +6120,7 @@ static HRESULT d3dx9_parse_resource(struct d3dx9_base_effect *base, const char *
|
|||
if (FAILED(hr = d3dx9_copy_data(base, param->object_id, ptr)))
|
||||
return hr;
|
||||
if (FAILED(hr = d3dx_create_param_eval(base, object->data, object->size, param->type,
|
||||
¶m->param_eval, get_version_counter_ptr(base))))
|
||||
¶m->param_eval, get_version_counter_ptr(base), NULL, 0)))
|
||||
return hr;
|
||||
break;
|
||||
|
||||
|
@ -6145,7 +6149,8 @@ static HRESULT d3dx9_parse_resource(struct d3dx9_base_effect *base, const char *
|
|||
if (!refpar->param_eval)
|
||||
{
|
||||
if (FAILED(hr = d3dx_create_param_eval(base, refobj->data, refobj->size,
|
||||
refpar->type, &refpar->param_eval, get_version_counter_ptr(base))))
|
||||
refpar->type, &refpar->param_eval, get_version_counter_ptr(base),
|
||||
skip_constants, skip_constants_count)))
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
@ -6161,7 +6166,7 @@ static HRESULT d3dx9_parse_resource(struct d3dx9_base_effect *base, const char *
|
|||
state->type = ST_ARRAY_SELECTOR;
|
||||
if (FAILED(hr = d3dx9_copy_data(base, param->object_id, ptr)))
|
||||
return hr;
|
||||
hr = d3dx9_parse_array_selector(base, param);
|
||||
hr = d3dx9_parse_array_selector(base, param, skip_constants, skip_constants_count);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -6178,7 +6183,8 @@ static BOOL param_set_top_level_param(void *top_level_param, struct d3dx_paramet
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static HRESULT d3dx9_parse_effect(struct d3dx9_base_effect *base, const char *data, UINT data_size, DWORD start)
|
||||
static HRESULT d3dx9_parse_effect(struct d3dx9_base_effect *base, const char *data, UINT data_size,
|
||||
DWORD start, const char **skip_constants, unsigned int skip_constants_count)
|
||||
{
|
||||
const char *ptr = data + start;
|
||||
UINT stringcount, resourcecount;
|
||||
|
@ -6277,7 +6283,7 @@ static HRESULT d3dx9_parse_effect(struct d3dx9_base_effect *base, const char *da
|
|||
{
|
||||
TRACE("parse resource %u\n", i);
|
||||
|
||||
hr = d3dx9_parse_resource(base, data, &ptr);
|
||||
hr = d3dx9_parse_resource(base, data, &ptr, skip_constants, skip_constants_count);
|
||||
if (hr != D3D_OK)
|
||||
{
|
||||
WARN("Failed to parse resource %u\n", i);
|
||||
|
@ -6331,16 +6337,77 @@ err_out:
|
|||
return hr;
|
||||
}
|
||||
|
||||
#define INITIAL_CONST_NAMES_SIZE 4
|
||||
|
||||
static char *next_valid_constant_name(char **string)
|
||||
{
|
||||
char *ret = *string;
|
||||
char *next;
|
||||
|
||||
while (*ret && !isalpha(*ret) && *ret != '_')
|
||||
++ret;
|
||||
if (!*ret)
|
||||
return NULL;
|
||||
|
||||
next = ret + 1;
|
||||
while (isalpha(*next) || isdigit(*next) || *next == '_')
|
||||
++next;
|
||||
if (*next)
|
||||
*next++ = 0;
|
||||
*string = next;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const char **parse_skip_constants_string(char *skip_constants_string, unsigned int *names_count)
|
||||
{
|
||||
const char **names, **new_alloc;
|
||||
const char *name;
|
||||
char *s;
|
||||
unsigned int size = INITIAL_CONST_NAMES_SIZE;
|
||||
|
||||
names = HeapAlloc(GetProcessHeap(), 0, sizeof(*names) * size);
|
||||
if (!names)
|
||||
return NULL;
|
||||
|
||||
*names_count = 0;
|
||||
s = skip_constants_string;
|
||||
while ((name = next_valid_constant_name(&s)))
|
||||
{
|
||||
if (*names_count == size)
|
||||
{
|
||||
size *= 2;
|
||||
new_alloc = HeapReAlloc(GetProcessHeap(), 0, names, sizeof(*names) * size);
|
||||
if (!new_alloc)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, names);
|
||||
return NULL;
|
||||
}
|
||||
names = new_alloc;
|
||||
}
|
||||
names[(*names_count)++] = name;
|
||||
}
|
||||
new_alloc = HeapReAlloc(GetProcessHeap(), 0, names, *names_count * sizeof(*names));
|
||||
if (!new_alloc)
|
||||
return names;
|
||||
return new_alloc;
|
||||
}
|
||||
|
||||
static HRESULT d3dx9_base_effect_init(struct d3dx9_base_effect *base,
|
||||
const char *data, SIZE_T data_size, const D3D_SHADER_MACRO *defines, ID3DInclude *include,
|
||||
UINT eflags, ID3DBlob **errors, struct ID3DXEffectImpl *effect, struct d3dx_effect_pool *pool)
|
||||
UINT eflags, ID3DBlob **errors, struct ID3DXEffectImpl *effect, struct d3dx_effect_pool *pool,
|
||||
const char *skip_constants_string)
|
||||
{
|
||||
DWORD tag, offset;
|
||||
const char *ptr = data;
|
||||
HRESULT hr;
|
||||
ID3DBlob *bytecode = NULL, *temp_errors = NULL;
|
||||
char *skip_constants_buffer = NULL;
|
||||
const char **skip_constants = NULL;
|
||||
unsigned int skip_constants_count = 0;
|
||||
unsigned int i, j;
|
||||
|
||||
TRACE("base %p, data %p, data_size %lu, effect %p, pool %p.\n", base, data, data_size, effect, pool);
|
||||
TRACE("base %p, data %p, data_size %lu, effect %p, pool %p, skip_constants %s.\n",
|
||||
base, data, data_size, effect, pool, debugstr_a(skip_constants_string));
|
||||
|
||||
base->effect = effect;
|
||||
base->pool = pool;
|
||||
|
@ -6397,24 +6464,75 @@ static HRESULT d3dx9_base_effect_init(struct d3dx9_base_effect *base,
|
|||
TRACE("Tag: %x\n", tag);
|
||||
}
|
||||
|
||||
if (skip_constants_string)
|
||||
{
|
||||
skip_constants_buffer = HeapAlloc(GetProcessHeap(), 0,
|
||||
sizeof(*skip_constants_buffer) * (strlen(skip_constants_string) + 1));
|
||||
if (!skip_constants_buffer)
|
||||
{
|
||||
if (bytecode)
|
||||
ID3D10Blob_Release(bytecode);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
strcpy(skip_constants_buffer, skip_constants_string);
|
||||
|
||||
if (!(skip_constants = parse_skip_constants_string(skip_constants_buffer, &skip_constants_count)))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, skip_constants_buffer);
|
||||
if (bytecode)
|
||||
ID3D10Blob_Release(bytecode);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
read_dword(&ptr, &offset);
|
||||
TRACE("Offset: %x\n", offset);
|
||||
|
||||
hr = d3dx9_parse_effect(base, ptr, data_size, offset);
|
||||
hr = d3dx9_parse_effect(base, ptr, data_size, offset, skip_constants, skip_constants_count);
|
||||
if (bytecode)
|
||||
ID3D10Blob_Release(bytecode);
|
||||
if (hr != D3D_OK)
|
||||
{
|
||||
FIXME("Failed to parse effect.\n");
|
||||
HeapFree(GetProcessHeap(), 0, skip_constants_buffer);
|
||||
HeapFree(GetProcessHeap(), 0, skip_constants);
|
||||
return hr;
|
||||
}
|
||||
|
||||
for (i = 0; i < skip_constants_count; ++i)
|
||||
{
|
||||
struct d3dx_parameter *param;
|
||||
param = get_parameter_by_name(base, NULL, skip_constants[i]);
|
||||
if (param)
|
||||
{
|
||||
for (j = 0; j < base->technique_count; ++j)
|
||||
{
|
||||
if (is_parameter_used(param, &base->techniques[j]))
|
||||
{
|
||||
WARN("skip_constants parameter %s is used in technique %u.\n",
|
||||
debugstr_a(skip_constants[i]), j);
|
||||
HeapFree(GetProcessHeap(), 0, skip_constants_buffer);
|
||||
HeapFree(GetProcessHeap(), 0, skip_constants);
|
||||
d3dx9_base_effect_cleanup(base);
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("skip_constants parameter %s not found.\n",
|
||||
debugstr_a(skip_constants[i]));
|
||||
}
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, skip_constants_buffer);
|
||||
HeapFree(GetProcessHeap(), 0, skip_constants);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, struct IDirect3DDevice9 *device,
|
||||
const char *data, SIZE_T data_size, const D3D_SHADER_MACRO *defines, ID3DInclude *include,
|
||||
UINT eflags, ID3DBlob **error_messages, struct ID3DXEffectPool *pool)
|
||||
UINT eflags, ID3DBlob **error_messages, struct ID3DXEffectPool *pool, const char *skip_constants)
|
||||
{
|
||||
HRESULT hr;
|
||||
struct d3dx_effect_pool *pool_impl = NULL;
|
||||
|
@ -6435,7 +6553,7 @@ static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, struct IDirect3
|
|||
effect->device = device;
|
||||
|
||||
if (FAILED(hr = d3dx9_base_effect_init(&effect->base_effect, data, data_size, defines, include,
|
||||
eflags, error_messages, effect, pool_impl)))
|
||||
eflags, error_messages, effect, pool_impl, skip_constants)))
|
||||
{
|
||||
FIXME("Failed to parse effect, hr %#x.\n", hr);
|
||||
free_effect(effect);
|
||||
|
@ -6477,15 +6595,12 @@ HRESULT WINAPI D3DXCreateEffectEx(struct IDirect3DDevice9 *device, const void *s
|
|||
if (!effect)
|
||||
return D3D_OK;
|
||||
|
||||
if (skip_constants)
|
||||
FIXME("skip_constants is not NULL, not supported yet.\n");
|
||||
|
||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
||||
if (!object)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, (const D3D_SHADER_MACRO *)defines,
|
||||
(ID3DInclude *)include, flags, (ID3DBlob **)compilation_errors, pool);
|
||||
(ID3DInclude *)include, flags, (ID3DBlob **)compilation_errors, pool, skip_constants);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create effect object.\n");
|
||||
|
@ -6522,7 +6637,7 @@ static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compil
|
|||
compiler->ref = 1;
|
||||
|
||||
if (FAILED(hr = d3dx9_base_effect_init(&compiler->base_effect, data, data_size, defines,
|
||||
include, eflags, error_messages, NULL, NULL)))
|
||||
include, eflags, error_messages, NULL, NULL, NULL)))
|
||||
{
|
||||
FIXME("Failed to parse effect, hr %#x.\n", hr);
|
||||
free_effect_compiler(compiler);
|
||||
|
|
|
@ -588,7 +588,8 @@ static unsigned int *parse_pres_ins(unsigned int *ptr, unsigned int count, struc
|
|||
return ptr;
|
||||
}
|
||||
|
||||
static HRESULT get_ctab_constant_desc(ID3DXConstantTable *ctab, D3DXHANDLE hc, D3DXCONSTANT_DESC *desc)
|
||||
static HRESULT get_ctab_constant_desc(ID3DXConstantTable *ctab, D3DXHANDLE hc, D3DXCONSTANT_DESC *desc,
|
||||
WORD *constantinfo_reserved)
|
||||
{
|
||||
const struct ctab_constant *constant = d3dx_shader_get_ctab_constant(ctab, hc);
|
||||
|
||||
|
@ -598,10 +599,13 @@ static HRESULT get_ctab_constant_desc(ID3DXConstantTable *ctab, D3DXHANDLE hc, D
|
|||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
*desc = constant->desc;
|
||||
if (constantinfo_reserved)
|
||||
*constantinfo_reserved = constant->constantinfo_reserved;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab *out, struct d3dx9_base_effect *base)
|
||||
static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab *out,
|
||||
struct d3dx9_base_effect *base, const char **skip_constants, unsigned int skip_constants_count)
|
||||
{
|
||||
ID3DXConstantTable *ctab;
|
||||
D3DXCONSTANT_DESC *cdesc;
|
||||
|
@ -609,7 +613,7 @@ static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab
|
|||
D3DXCONSTANTTABLE_DESC desc;
|
||||
HRESULT hr;
|
||||
D3DXHANDLE hc;
|
||||
unsigned int i;
|
||||
unsigned int i, j;
|
||||
|
||||
hr = D3DXGetShaderConstantTable(byte_code, &ctab);
|
||||
if (FAILED(hr) || !ctab)
|
||||
|
@ -621,7 +625,7 @@ static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab
|
|||
if (FAILED(hr = ID3DXConstantTable_GetDesc(ctab, &desc)))
|
||||
{
|
||||
FIXME("Could not get CTAB desc, hr %#x.\n", hr);
|
||||
goto err_out;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
out->inputs = cdesc = HeapAlloc(GetProcessHeap(), 0, sizeof(*cdesc) * desc.Constants);
|
||||
|
@ -629,47 +633,69 @@ static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab
|
|||
if (!cdesc || !inputs_param)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
goto err_out;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (i = 0; i < desc.Constants; ++i)
|
||||
{
|
||||
unsigned int index = out->input_count;
|
||||
WORD constantinfo_reserved;
|
||||
|
||||
hc = ID3DXConstantTable_GetConstant(ctab, NULL, i);
|
||||
if (!hc)
|
||||
{
|
||||
FIXME("Null constant handle.\n");
|
||||
goto err_out;
|
||||
goto cleanup;
|
||||
}
|
||||
if (FAILED(hr = get_ctab_constant_desc(ctab, hc, &cdesc[i])))
|
||||
goto err_out;
|
||||
inputs_param[i] = get_parameter_by_name(base, NULL, cdesc[i].Name);
|
||||
if (!inputs_param[i])
|
||||
if (FAILED(hr = get_ctab_constant_desc(ctab, hc, &cdesc[index], &constantinfo_reserved)))
|
||||
goto cleanup;
|
||||
inputs_param[index] = get_parameter_by_name(base, NULL, cdesc[index].Name);
|
||||
if (!inputs_param[index])
|
||||
{
|
||||
WARN("Could not find parameter %s in effect.\n", cdesc[i].Name);
|
||||
WARN("Could not find parameter %s in effect.\n", cdesc[index].Name);
|
||||
continue;
|
||||
}
|
||||
if (cdesc[i].Class == D3DXPC_OBJECT)
|
||||
if (cdesc[index].Class == D3DXPC_OBJECT)
|
||||
{
|
||||
TRACE("Object %s, parameter %p.\n", cdesc[i].Name, inputs_param[i]);
|
||||
if (cdesc[i].RegisterSet != D3DXRS_SAMPLER || inputs_param[i]->class != D3DXPC_OBJECT
|
||||
|| !is_param_type_sampler(inputs_param[i]->type))
|
||||
TRACE("Object %s, parameter %p.\n", cdesc[index].Name, inputs_param[index]);
|
||||
if (cdesc[index].RegisterSet != D3DXRS_SAMPLER || inputs_param[index]->class != D3DXPC_OBJECT
|
||||
|| !is_param_type_sampler(inputs_param[index]->type))
|
||||
{
|
||||
WARN("Unexpected object type, constant %s.\n", debugstr_a(cdesc[i].Name));
|
||||
WARN("Unexpected object type, constant %s.\n", debugstr_a(cdesc[index].Name));
|
||||
hr = D3DERR_INVALIDCALL;
|
||||
goto err_out;
|
||||
goto cleanup;
|
||||
}
|
||||
if (max(inputs_param[i]->element_count, 1) < cdesc[i].RegisterCount)
|
||||
if (max(inputs_param[index]->element_count, 1) < cdesc[index].RegisterCount)
|
||||
{
|
||||
WARN("Register count exceeds parameter size, constant %s.\n", debugstr_a(cdesc[i].Name));
|
||||
WARN("Register count exceeds parameter size, constant %s.\n", debugstr_a(cdesc[index].Name));
|
||||
hr = D3DERR_INVALIDCALL;
|
||||
goto err_out;
|
||||
goto cleanup;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (FAILED(hr = init_set_constants_param(out, ctab, hc, inputs_param[i])))
|
||||
goto err_out;
|
||||
|
||||
for (j = 0; j < skip_constants_count; ++j)
|
||||
{
|
||||
if (!strcmp(cdesc[index].Name, skip_constants[j]))
|
||||
{
|
||||
if (!constantinfo_reserved)
|
||||
{
|
||||
WARN("skip_constants parameter %s is not register bound.\n",
|
||||
cdesc[index].Name);
|
||||
hr = D3DERR_INVALIDCALL;
|
||||
goto cleanup;
|
||||
}
|
||||
TRACE("Skipping constant %s.\n", cdesc[index].Name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j < skip_constants_count)
|
||||
continue;
|
||||
++out->input_count;
|
||||
if (inputs_param[index]->class == D3DXPC_OBJECT)
|
||||
continue;
|
||||
if (FAILED(hr = init_set_constants_param(out, ctab, hc, inputs_param[index])))
|
||||
goto cleanup;
|
||||
}
|
||||
out->input_count = desc.Constants;
|
||||
if (out->const_set_count)
|
||||
{
|
||||
out->const_set = HeapReAlloc(GetProcessHeap(), 0, out->const_set,
|
||||
|
@ -678,11 +704,11 @@ static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab
|
|||
{
|
||||
ERR("Out of memory.\n");
|
||||
hr = E_OUTOFMEMORY;
|
||||
goto err_out;
|
||||
goto cleanup;
|
||||
}
|
||||
out->const_set_size = out->const_set_count;
|
||||
}
|
||||
err_out:
|
||||
cleanup:
|
||||
ID3DXConstantTable_Release(ctab);
|
||||
return hr;
|
||||
}
|
||||
|
@ -858,7 +884,7 @@ static HRESULT parse_preshader(struct d3dx_preshader *pres, unsigned int *ptr, u
|
|||
|
||||
saved_word = *ptr;
|
||||
*ptr = 0xfffe0000;
|
||||
hr = get_constants_desc(ptr, &pres->inputs, base);
|
||||
hr = get_constants_desc(ptr, &pres->inputs, base, NULL, 0);
|
||||
*ptr = saved_word;
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
@ -912,7 +938,8 @@ static HRESULT parse_preshader(struct d3dx_preshader *pres, unsigned int *ptr, u
|
|||
}
|
||||
|
||||
HRESULT d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_code, unsigned int byte_code_size,
|
||||
D3DXPARAMETER_TYPE type, struct d3dx_param_eval **peval_out, ULONG64 *version_counter)
|
||||
D3DXPARAMETER_TYPE type, struct d3dx_param_eval **peval_out, ULONG64 *version_counter,
|
||||
const char **skip_constants, unsigned int skip_constants_count)
|
||||
{
|
||||
struct d3dx_param_eval *peval;
|
||||
unsigned int *ptr;
|
||||
|
@ -963,9 +990,10 @@ HRESULT d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte
|
|||
}
|
||||
TRACE("Shader version %#x.\n", *ptr & 0xffff);
|
||||
|
||||
if (FAILED(ret = get_constants_desc(ptr, &peval->shader_inputs, base_effect)))
|
||||
if (FAILED(ret = get_constants_desc(ptr, &peval->shader_inputs, base_effect,
|
||||
skip_constants, skip_constants_count)))
|
||||
{
|
||||
FIXME("Could not get shader constant table, ret %#x.\n", ret);
|
||||
WARN("Could not get shader constant table, ret %#x.\n", ret);
|
||||
goto err_out;
|
||||
}
|
||||
update_table_sizes_consts(peval->pres.regs.table_sizes, &peval->shader_inputs);
|
||||
|
@ -1006,7 +1034,7 @@ HRESULT d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte
|
|||
return D3D_OK;
|
||||
|
||||
err_out:
|
||||
FIXME("Error creating parameter evaluator.\n");
|
||||
WARN("Error creating parameter evaluator.\n");
|
||||
d3dx_free_param_eval(peval);
|
||||
*peval_out = NULL;
|
||||
return ret;
|
||||
|
@ -1352,7 +1380,7 @@ static HRESULT init_set_constants_param(struct d3dx_const_tab *const_tab, ID3DXC
|
|||
enum pres_value_type table_type;
|
||||
HRESULT hr;
|
||||
|
||||
if (FAILED(get_ctab_constant_desc(ctab, hc, &desc)))
|
||||
if (FAILED(get_ctab_constant_desc(ctab, hc, &desc, NULL)))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
if (param->element_count)
|
||||
|
@ -1588,8 +1616,7 @@ static BOOL is_const_tab_input_dirty(struct d3dx_const_tab *ctab, ULONG64 update
|
|||
update_version = ctab->update_version;
|
||||
for (i = 0; i < ctab->input_count; ++i)
|
||||
{
|
||||
if (ctab->inputs_param[i]
|
||||
&& is_param_dirty(ctab->inputs_param[i], update_version))
|
||||
if (is_param_dirty(ctab->inputs_param[i], update_version))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
|
|
@ -2054,6 +2054,7 @@ HRESULT WINAPI D3DXGetShaderConstantTableEx(const DWORD *byte_code, DWORD flags,
|
|||
{
|
||||
object->constants[i].desc.RegisterCount = constant_info[i].RegisterCount;
|
||||
}
|
||||
object->constants[i].constantinfo_reserved = constant_info[i].Reserved;
|
||||
}
|
||||
|
||||
*constant_table = &object->ID3DXConstantTable_iface;
|
||||
|
|
|
@ -6920,25 +6920,17 @@ static void test_effect_skip_constants(IDirect3DDevice9 *device)
|
|||
|
||||
hr = D3DXCreateEffectEx(device, test_effect_skip_constants_blob, sizeof(test_effect_skip_constants_blob),
|
||||
NULL, NULL, "v3", 0, NULL, &effect, NULL);
|
||||
todo_wine
|
||||
ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
|
||||
if (SUCCEEDED(hr))
|
||||
effect->lpVtbl->Release(effect);
|
||||
hr = D3DXCreateEffectEx(device, test_effect_skip_constants_blob, sizeof(test_effect_skip_constants_blob),
|
||||
NULL, NULL, "v4", 0, NULL, &effect, NULL);
|
||||
todo_wine
|
||||
ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
|
||||
if (SUCCEEDED(hr))
|
||||
effect->lpVtbl->Release(effect);
|
||||
|
||||
hr = D3DXCreateEffectEx(device, test_effect_skip_constants_blob, sizeof(test_effect_skip_constants_blob),
|
||||
NULL, NULL, " v1#,.+-= &\t\nv2*/!\"'v5 v6[1]", 0, NULL, &effect, NULL);
|
||||
ok(hr == D3D_OK, "Got result %#x.\n", hr);
|
||||
|
||||
todo_wine
|
||||
ok(!effect->lpVtbl->IsParameterUsed(effect, "v1", "tech0"),
|
||||
"Unexpected IsParameterUsed result.\n");
|
||||
todo_wine
|
||||
ok(!effect->lpVtbl->IsParameterUsed(effect, "v2", "tech0"),
|
||||
"Unexpected IsParameterUsed result.\n");
|
||||
ok(effect->lpVtbl->IsParameterUsed(effect, "v3", "tech0"),
|
||||
|
@ -6970,11 +6962,11 @@ static void test_effect_skip_constants(IDirect3DDevice9 *device)
|
|||
fvect.x = 30.0f;
|
||||
test_effect_shared_parameters_compare_vconst(device, 0, &fvect, FALSE);
|
||||
for (i = 1; i < 4; ++i)
|
||||
test_effect_shared_parameters_compare_vconst(device, i, &fvect_filler, i > 1);
|
||||
test_effect_shared_parameters_compare_vconst(device, i, &fvect_filler, FALSE);
|
||||
fvect.x = 31.0f;
|
||||
test_effect_shared_parameters_compare_vconst(device, 4, &fvect, FALSE);
|
||||
for (i = 5; i < 256; ++i)
|
||||
test_effect_shared_parameters_compare_vconst(device, i, &fvect_filler, i < 7);
|
||||
test_effect_shared_parameters_compare_vconst(device, i, &fvect_filler, FALSE);
|
||||
|
||||
hr = effect->lpVtbl->EndPass(effect);
|
||||
ok(hr == D3D_OK, "Got result %#x.\n", hr);
|
||||
|
|
Loading…
Reference in New Issue