d3dx9: Fail effect creation when parameter evaluator creation fails.

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:
Paul Gofman 2017-07-11 14:26:57 +03:00 committed by Alexandre Julliard
parent f4131cbe97
commit 518b2f27cf
3 changed files with 32 additions and 20 deletions

View File

@ -345,7 +345,7 @@ struct d3dx_parameter *get_parameter_by_name(struct d3dx9_base_effect *base,
: device->lpVtbl->method(device, args))
#define SET_D3D_STATE(base_effect, args...) SET_D3D_STATE_(base_effect->manager, base_effect->device, args)
void d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_code,
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;
void d3dx_free_param_eval(struct d3dx_param_eval *peval) DECLSPEC_HIDDEN;

View File

@ -5966,8 +5966,10 @@ static HRESULT d3dx9_parse_array_selector(struct d3dx9_base_effect *base, struct
if (string_size % sizeof(DWORD))
FIXME("Unaligned string_size %u.\n", string_size);
d3dx_create_param_eval(base, (DWORD *)(ptr + string_size) + 1, object->size - (string_size + sizeof(DWORD)),
D3DXPT_INT, &param->param_eval, get_version_counter_ptr(base));
if (FAILED(ret = d3dx_create_param_eval(base, (DWORD *)(ptr + string_size) + 1,
object->size - (string_size + sizeof(DWORD)), D3DXPT_INT, &param->param_eval,
get_version_counter_ptr(base))))
return ret;
ret = D3D_OK;
param = param->u.referenced_param;
if (param->type == D3DXPT_VERTEXSHADER || param->type == D3DXPT_PIXELSHADER)
@ -5985,8 +5987,9 @@ 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];
d3dx_create_param_eval(base, object->data, object->size, param->type,
&param->members[i].param_eval, get_version_counter_ptr(base));
if (FAILED(ret = d3dx_create_param_eval(base, object->data, object->size, param->type,
&param->members[i].param_eval, get_version_counter_ptr(base))))
break;
}
}
}
@ -6099,8 +6102,9 @@ static HRESULT d3dx9_parse_resource(struct d3dx9_base_effect *base, const char *
{
if (FAILED(hr = d3dx9_create_object(base, object)))
return hr;
d3dx_create_param_eval(base, object->data, object->size, param->type,
&param->param_eval, get_version_counter_ptr(base));
if (FAILED(hr = d3dx_create_param_eval(base, object->data, object->size, param->type,
&param->param_eval, get_version_counter_ptr(base))))
return hr;
}
break;
@ -6111,8 +6115,9 @@ static HRESULT d3dx9_parse_resource(struct d3dx9_base_effect *base, const char *
state->type = ST_FXLC;
if (FAILED(hr = d3dx9_copy_data(base, param->object_id, ptr)))
return hr;
d3dx_create_param_eval(base, object->data, object->size, param->type,
&param->param_eval, get_version_counter_ptr(base));
if (FAILED(hr = d3dx_create_param_eval(base, object->data, object->size, param->type,
&param->param_eval, get_version_counter_ptr(base))))
return hr;
break;
default:
@ -6138,8 +6143,11 @@ static HRESULT d3dx9_parse_resource(struct d3dx9_base_effect *base, const char *
struct d3dx_object *refobj = &base->objects[refpar->object_id];
if (!refpar->param_eval)
d3dx_create_param_eval(base, refobj->data, refobj->size,
refpar->type, &refpar->param_eval, get_version_counter_ptr(base));
{
if (FAILED(hr = d3dx_create_param_eval(base, refobj->data, refobj->size,
refpar->type, &refpar->param_eval, get_version_counter_ptr(base))))
return hr;
}
}
}
else

View File

@ -919,15 +919,15 @@ static HRESULT parse_preshader(struct d3dx_preshader *pres, unsigned int *ptr, u
return D3D_OK;
}
void d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_code, unsigned int byte_code_size,
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)
{
struct d3dx_param_eval *peval;
unsigned int *ptr;
HRESULT hr;
unsigned int i;
BOOL shader;
unsigned int count, pres_size;
HRESULT ret;
TRACE("base_effect %p, byte_code %p, byte_code_size %u, type %u, peval_out %p.\n",
base_effect, byte_code, byte_code_size, type, peval_out);
@ -936,13 +936,15 @@ void d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_co
if (!byte_code || !count)
{
*peval_out = NULL;
return;
return D3D_OK;
}
peval = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*peval));
if (!peval)
{
ret = E_OUTOFMEMORY;
goto err_out;
}
peval->version_counter = version_counter;
peval->param_type = type;
@ -964,13 +966,14 @@ void d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_co
if ((*ptr & 0xfffe0000) != 0xfffe0000)
{
FIXME("Invalid shader signature %#x.\n", *ptr);
ret = D3DXERR_INVALIDDATA;
goto err_out;
}
TRACE("Shader version %#x.\n", *ptr & 0xffff);
if (FAILED(hr = get_constants_desc(ptr, &peval->shader_inputs, base_effect)))
if (FAILED(ret = get_constants_desc(ptr, &peval->shader_inputs, base_effect)))
{
FIXME("Could not get shader constant table, hr %#x.\n", hr);
FIXME("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);
@ -983,7 +986,7 @@ void d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_co
pres_size = count;
}
if (ptr && FAILED(parse_preshader(&peval->pres, ptr, pres_size, base_effect)))
if (ptr && FAILED(ret = parse_preshader(&peval->pres, ptr, pres_size, base_effect)))
{
FIXME("Failed parsing preshader, byte code for analysis follows.\n");
dump_bytecode(byte_code, byte_code_size);
@ -992,7 +995,7 @@ void d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_co
for (i = PRES_REGTAB_FIRST_SHADER; i < PRES_REGTAB_COUNT; ++i)
{
if (FAILED(regstore_alloc_table(&peval->pres.regs, i)))
if (FAILED(ret = regstore_alloc_table(&peval->pres.regs, i)))
goto err_out;
}
@ -1008,12 +1011,13 @@ void d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_co
}
*peval_out = peval;
TRACE("Created parameter evaluator %p.\n", *peval_out);
return;
return D3D_OK;
err_out:
FIXME("Error creating parameter evaluator.\n");
d3dx_free_param_eval(peval);
*peval_out = NULL;
return ret;
}
static void d3dx_free_const_tab(struct d3dx_const_tab *ctab)