Commit e6961f6e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

d3dcompiler: Use return value in read_dword.

Fixes warnings like on clang with MSVC target, where enums may be signed: dlls/d3dcompiler_43/reflection.c:1160:22: warning: passing 'D3D_PRIMITIVE *' (aka 'enum D3D_PRIMITIVE *') to parameter of type 'DWORD *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign] Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarMatteo Bruni <mbruni@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent e8ccb28c
......@@ -1163,10 +1163,12 @@ HRESULT dxbc_parse(const char *data, SIZE_T data_size, struct dxbc *dxbc) DECLSP
HRESULT dxbc_add_section(struct dxbc *dxbc, DWORD tag, const char *data, DWORD data_size) DECLSPEC_HIDDEN;
HRESULT dxbc_init(struct dxbc *dxbc, unsigned int size) DECLSPEC_HIDDEN;
static inline void read_dword(const char **ptr, DWORD *d)
static inline DWORD read_dword(const char **ptr)
{
memcpy(d, *ptr, sizeof(*d));
*ptr += sizeof(*d);
DWORD r;
memcpy(&r, *ptr, sizeof(r));
*ptr += sizeof(r);
return r;
}
static inline void write_dword(char **ptr, DWORD d)
......
......@@ -1092,78 +1092,78 @@ static HRESULT d3dcompiler_parse_stat(struct d3dcompiler_shader_reflection *r, c
TRACE("Size %u\n", size);
read_dword(&ptr, &r->instruction_count);
r->instruction_count = read_dword(&ptr);
TRACE("InstructionCount: %u\n", r->instruction_count);
read_dword(&ptr, &r->temp_register_count);
r->temp_register_count = read_dword(&ptr);
TRACE("TempRegisterCount: %u\n", r->temp_register_count);
skip_dword_unknown(&ptr, 1);
read_dword(&ptr, &r->dcl_count);
r->dcl_count = read_dword(&ptr);
TRACE("DclCount: %u\n", r->dcl_count);
read_dword(&ptr, &r->float_instruction_count);
r->float_instruction_count = read_dword(&ptr);
TRACE("FloatInstructionCount: %u\n", r->float_instruction_count);
read_dword(&ptr, &r->int_instruction_count);
r->int_instruction_count = read_dword(&ptr);
TRACE("IntInstructionCount: %u\n", r->int_instruction_count);
read_dword(&ptr, &r->uint_instruction_count);
r->uint_instruction_count = read_dword(&ptr);
TRACE("UintInstructionCount: %u\n", r->uint_instruction_count);
read_dword(&ptr, &r->static_flow_control_count);
r->static_flow_control_count = read_dword(&ptr);
TRACE("StaticFlowControlCount: %u\n", r->static_flow_control_count);
read_dword(&ptr, &r->dynamic_flow_control_count);
r->dynamic_flow_control_count = read_dword(&ptr);
TRACE("DynamicFlowControlCount: %u\n", r->dynamic_flow_control_count);
skip_dword_unknown(&ptr, 1);
read_dword(&ptr, &r->temp_array_count);
r->temp_array_count = read_dword(&ptr);
TRACE("TempArrayCount: %u\n", r->temp_array_count);
read_dword(&ptr, &r->array_instruction_count);
r->array_instruction_count = read_dword(&ptr);
TRACE("ArrayInstructionCount: %u\n", r->array_instruction_count);
read_dword(&ptr, &r->cut_instruction_count);
r->cut_instruction_count = read_dword(&ptr);
TRACE("CutInstructionCount: %u\n", r->cut_instruction_count);
read_dword(&ptr, &r->emit_instruction_count);
r->emit_instruction_count = read_dword(&ptr);
TRACE("EmitInstructionCount: %u\n", r->emit_instruction_count);
read_dword(&ptr, &r->texture_normal_instructions);
r->texture_normal_instructions = read_dword(&ptr);
TRACE("TextureNormalInstructions: %u\n", r->texture_normal_instructions);
read_dword(&ptr, &r->texture_load_instructions);
r->texture_load_instructions = read_dword(&ptr);
TRACE("TextureLoadInstructions: %u\n", r->texture_load_instructions);
read_dword(&ptr, &r->texture_comp_instructions);
r->texture_comp_instructions = read_dword(&ptr);
TRACE("TextureCompInstructions: %u\n", r->texture_comp_instructions);
read_dword(&ptr, &r->texture_bias_instructions);
r->texture_bias_instructions = read_dword(&ptr);
TRACE("TextureBiasInstructions: %u\n", r->texture_bias_instructions);
read_dword(&ptr, &r->texture_gradient_instructions);
r->texture_gradient_instructions = read_dword(&ptr);
TRACE("TextureGradientInstructions: %u\n", r->texture_gradient_instructions);
read_dword(&ptr, &r->mov_instruction_count);
r->mov_instruction_count = read_dword(&ptr);
TRACE("MovInstructionCount: %u\n", r->mov_instruction_count);
skip_dword_unknown(&ptr, 1);
read_dword(&ptr, &r->conversion_instruction_count);
r->conversion_instruction_count = read_dword(&ptr);
TRACE("ConversionInstructionCount: %u\n", r->conversion_instruction_count);
skip_dword_unknown(&ptr, 1);
read_dword(&ptr, &r->input_primitive);
r->input_primitive = read_dword(&ptr);
TRACE("InputPrimitive: %x\n", r->input_primitive);
read_dword(&ptr, &r->gs_output_topology);
r->gs_output_topology = read_dword(&ptr);
TRACE("GSOutputTopology: %x\n", r->gs_output_topology);
read_dword(&ptr, &r->gs_max_output_vertex_count);
r->gs_max_output_vertex_count = read_dword(&ptr);
TRACE("GSMaxOutputVertexCount: %u\n", r->gs_max_output_vertex_count);
skip_dword_unknown(&ptr, 2);
......@@ -1178,16 +1178,16 @@ static HRESULT d3dcompiler_parse_stat(struct d3dcompiler_shader_reflection *r, c
skip_dword_unknown(&ptr, 1);
read_dword(&ptr, &r->c_control_points);
r->c_control_points = read_dword(&ptr);
TRACE("cControlPoints: %u\n", r->c_control_points);
read_dword(&ptr, &r->hs_output_primitive);
r->hs_output_primitive = read_dword(&ptr);
TRACE("HSOutputPrimitive: %x\n", r->hs_output_primitive);
read_dword(&ptr, &r->hs_prtitioning);
r->hs_prtitioning = read_dword(&ptr);
TRACE("HSPartitioning: %x\n", r->hs_prtitioning);
read_dword(&ptr, &r->tessellator_domain);
r->tessellator_domain = read_dword(&ptr);
TRACE("TessellatorDomain: %x\n", r->tessellator_domain);
skip_dword_unknown(&ptr, 3);
......@@ -1205,7 +1205,7 @@ static HRESULT d3dcompiler_parse_type_members(struct d3dcompiler_shader_reflecti
{
DWORD offset;
read_dword(ptr, &offset);
offset = read_dword(ptr);
if (!copy_name(data + offset, &member->name))
{
ERR("Failed to copy name.\n");
......@@ -1213,7 +1213,7 @@ static HRESULT d3dcompiler_parse_type_members(struct d3dcompiler_shader_reflecti
}
TRACE("Member name: %s.\n", debugstr_a(member->name));
read_dword(ptr, &offset);
offset = read_dword(ptr);
TRACE("Member type offset: %x\n", offset);
member->type = get_reflection_type(ref, data, offset);
......@@ -1224,7 +1224,7 @@ static HRESULT d3dcompiler_parse_type_members(struct d3dcompiler_shader_reflecti
return E_FAIL;
}
read_dword(ptr, &member->offset);
member->offset = read_dword(ptr);
TRACE("Member offset %x\n", member->offset);
return S_OK;
......@@ -1242,23 +1242,23 @@ static HRESULT d3dcompiler_parse_type(struct d3dcompiler_shader_reflection_type
desc = &type->desc;
read_dword(&ptr, &temp);
temp = read_dword(&ptr);
desc->Class = temp & 0xffff;
desc->Type = temp >> 16;
TRACE("Class %s, Type %s\n", debug_d3dcompiler_shader_variable_class(desc->Class),
debug_d3dcompiler_shader_variable_type(desc->Type));
read_dword(&ptr, &temp);
temp = read_dword(&ptr);
desc->Rows = temp & 0xffff;
desc->Columns = temp >> 16;
TRACE("Rows %u, Columns %u\n", desc->Rows, desc->Columns);
read_dword(&ptr, &temp);
temp = read_dword(&ptr);
desc->Elements = temp & 0xffff;
desc->Members = temp >> 16;
TRACE("Elements %u, Members %u\n", desc->Elements, desc->Members);
read_dword(&ptr, &member_offset);
member_offset = read_dword(&ptr);
TRACE("Member Offset %u\n", member_offset);
if ((type->reflection->target & D3DCOMPILER_SHADER_TARGET_VERSION_MASK) >= 0x500)
......@@ -1288,7 +1288,7 @@ static HRESULT d3dcompiler_parse_type(struct d3dcompiler_shader_reflection_type
if ((type->reflection->target & D3DCOMPILER_SHADER_TARGET_VERSION_MASK) >= 0x500)
{
read_dword(&ptr, &offset);
offset = read_dword(&ptr);
if (!copy_name(data + offset, &type->name))
{
ERR("Failed to copy name.\n");
......@@ -1375,7 +1375,7 @@ static HRESULT d3dcompiler_parse_variables(struct d3dcompiler_shader_reflection_
v->ID3D10ShaderReflectionVariable_iface.lpVtbl = &d3d10_shader_reflection_variable_vtbl;
v->constant_buffer = cb;
read_dword(&ptr, &offset);
offset = read_dword(&ptr);
if (!copy_name(data + offset, &v->name))
{
ERR("Failed to copy name.\n");
......@@ -1384,16 +1384,16 @@ static HRESULT d3dcompiler_parse_variables(struct d3dcompiler_shader_reflection_
}
TRACE("Variable name: %s.\n", debugstr_a(v->name));
read_dword(&ptr, &v->start_offset);
v->start_offset = read_dword(&ptr);
TRACE("Variable offset: %u\n", v->start_offset);
read_dword(&ptr, &v->size);
v->size = read_dword(&ptr);
TRACE("Variable size: %u\n", v->size);
read_dword(&ptr, &v->flags);
v->flags = read_dword(&ptr);
TRACE("Variable flags: %u\n", v->flags);
read_dword(&ptr, &offset);
offset = read_dword(&ptr);
TRACE("Variable type offset: %x\n", offset);
v->type = get_reflection_type(cb->reflection, data, offset);
if (!v->type)
......@@ -1403,7 +1403,7 @@ static HRESULT d3dcompiler_parse_variables(struct d3dcompiler_shader_reflection_
goto err_out;
}
read_dword(&ptr, &offset);
offset = read_dword(&ptr);
TRACE("Variable default value offset: %x\n", offset);
if (!copy_value(data + offset, &v->default_value, offset ? v->size : 0))
{
......@@ -1443,19 +1443,19 @@ static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, c
TRACE("Size %u\n", size);
read_dword(&ptr, &r->constant_buffer_count);
r->constant_buffer_count = read_dword(&ptr);
TRACE("Constant buffer count: %u\n", r->constant_buffer_count);
read_dword(&ptr, &cbuffer_offset);
cbuffer_offset = read_dword(&ptr);
TRACE("Constant buffer offset: %#x\n", cbuffer_offset);
read_dword(&ptr, &r->bound_resource_count);
r->bound_resource_count = read_dword(&ptr);
TRACE("Bound resource count: %u\n", r->bound_resource_count);
read_dword(&ptr, &resource_offset);
resource_offset = read_dword(&ptr);
TRACE("Bound resource offset: %#x\n", resource_offset);
read_dword(&ptr, &r->target);
r->target = read_dword(&ptr);
TRACE("Target: %#x\n", r->target);
target_version = r->target & D3DCOMPILER_SHADER_TARGET_VERSION_MASK;
......@@ -1468,10 +1468,10 @@ static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, c
}
#endif
read_dword(&ptr, &r->flags);
r->flags = read_dword(&ptr);
TRACE("Flags: %u\n", r->flags);
read_dword(&ptr, &creator_offset);
creator_offset = read_dword(&ptr);
TRACE("Creator at offset %#x.\n", creator_offset);
if (!copy_name(data + creator_offset, &creator))
......@@ -1515,36 +1515,36 @@ static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, c
{
D3D12_SHADER_INPUT_BIND_DESC *desc = &bound_resources[i];
read_dword(&ptr, &offset);
offset = read_dword(&ptr);
desc->Name = string_data + (offset - string_data_offset);
TRACE("Input bind Name: %s\n", debugstr_a(desc->Name));
read_dword(&ptr, &desc->Type);
desc->Type = read_dword(&ptr);
TRACE("Input bind Type: %#x\n", desc->Type);
read_dword(&ptr, &desc->ReturnType);
desc->ReturnType = read_dword(&ptr);
TRACE("Input bind ReturnType: %#x\n", desc->ReturnType);
read_dword(&ptr, &desc->Dimension);
desc->Dimension = read_dword(&ptr);
TRACE("Input bind Dimension: %#x\n", desc->Dimension);
read_dword(&ptr, &desc->NumSamples);
desc->NumSamples = read_dword(&ptr);
TRACE("Input bind NumSamples: %u\n", desc->NumSamples);
read_dword(&ptr, &desc->BindPoint);
desc->BindPoint = read_dword(&ptr);
TRACE("Input bind BindPoint: %u\n", desc->BindPoint);
read_dword(&ptr, &desc->BindCount);
desc->BindCount = read_dword(&ptr);
TRACE("Input bind BindCount: %u\n", desc->BindCount);
read_dword(&ptr, &desc->uFlags);
desc->uFlags = read_dword(&ptr);
TRACE("Input bind uFlags: %u\n", desc->uFlags);
if (target_version >= 0x501)
{
read_dword(&ptr, &desc->Space);
desc->Space = read_dword(&ptr);
TRACE("Input bind Space %u.\n", desc->Space);
read_dword(&ptr, &desc->uID);
desc->uID = read_dword(&ptr);
TRACE("Input bind uID %u.\n", desc->uID);
}
else
......@@ -1574,7 +1574,7 @@ static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, c
cb->ID3D10ShaderReflectionConstantBuffer_iface.lpVtbl = &d3d10_shader_reflection_constant_buffer_vtbl;
cb->reflection = r;
read_dword(&ptr, &offset);
offset = read_dword(&ptr);
if (!copy_name(data + offset, &cb->name))
{
ERR("Failed to copy name.\n");
......@@ -1583,10 +1583,10 @@ static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, c
}
TRACE("Name: %s.\n", debugstr_a(cb->name));
read_dword(&ptr, &cb->variable_count);
cb->variable_count = read_dword(&ptr);
TRACE("Variable count: %u\n", cb->variable_count);
read_dword(&ptr, &offset);
offset = read_dword(&ptr);
TRACE("Variable offset: %x\n", offset);
hr = d3dcompiler_parse_variables(cb, data, data_size, data + offset);
......@@ -1596,13 +1596,13 @@ static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, c
goto err_out;
}
read_dword(&ptr, &cb->size);
cb->size = read_dword(&ptr);
TRACE("Cbuffer size: %u\n", cb->size);
read_dword(&ptr, &cb->flags);
cb->flags = read_dword(&ptr);
TRACE("Cbuffer flags: %u\n", cb->flags);
read_dword(&ptr, &cb->type);
cb->type = read_dword(&ptr);
TRACE("Cbuffer type: %#x\n", cb->type);
}
}
......@@ -1656,7 +1656,7 @@ static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *
break;
}
read_dword(&ptr, &count);
count = read_dword(&ptr);
TRACE("%u elements\n", count);
skip_dword_unknown(&ptr, 1);
......@@ -1692,20 +1692,20 @@ static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *
#endif
if (element_size == D3DCOMPILER_SIGNATURE_ELEMENT_SIZE7)
{
read_dword(&ptr, &d[i].Stream);
d[i].Stream = read_dword(&ptr);
}
else
{
d[i].Stream = 0;
}
read_dword(&ptr, &name_offset);
name_offset = read_dword(&ptr);
d[i].SemanticName = string_data + (name_offset - string_data_offset);
read_dword(&ptr, &d[i].SemanticIndex);
read_dword(&ptr, &d[i].SystemValueType);
read_dword(&ptr, &d[i].ComponentType);
read_dword(&ptr, &d[i].Register);
read_dword(&ptr, &mask);
d[i].SemanticIndex = read_dword(&ptr);
d[i].SystemValueType = read_dword(&ptr);
d[i].ComponentType = read_dword(&ptr);
d[i].Register = read_dword(&ptr);
mask = read_dword(&ptr);
d[i].ReadWriteMask = (mask >> 8) & 0xff;
d[i].Mask = mask & 0xff;
......@@ -1737,7 +1737,7 @@ static HRESULT d3dcompiler_parse_shdr(struct d3dcompiler_shader_reflection *r, c
{
const char *ptr = data;
read_dword(&ptr, &r->version);
r->version = read_dword(&ptr);
TRACE("Shader version: %u\n", r->version);
/* todo: Check if anything else is needed from the shdr or shex blob. */
......
......@@ -515,7 +515,7 @@ void skip_dword_unknown(const char **ptr, unsigned int count)
FIXME("Skipping %u unknown DWORDs:\n", count);
for (i = 0; i < count; ++i)
{
read_dword(ptr, &d);
d = read_dword(ptr);
FIXME("\t0x%08x\n", d);
}
}
......@@ -587,7 +587,7 @@ HRESULT dxbc_parse(const char *data, SIZE_T data_size, struct dxbc *dxbc)
return E_FAIL;
}
read_dword(&ptr, &tag);
tag = read_dword(&ptr);
TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
if (tag != TAG_DXBC)
......@@ -601,7 +601,7 @@ HRESULT dxbc_parse(const char *data, SIZE_T data_size, struct dxbc *dxbc)
skip_dword_unknown(&ptr, 1);
read_dword(&ptr, &total_size);
total_size = read_dword(&ptr);
TRACE("total size: %#x\n", total_size);
if (data_size != total_size)
......@@ -610,7 +610,7 @@ HRESULT dxbc_parse(const char *data, SIZE_T data_size, struct dxbc *dxbc)
return D3DERR_INVALIDCALL;
}
read_dword(&ptr, &chunk_count);
chunk_count = read_dword(&ptr);
TRACE("chunk count: %#x\n", chunk_count);
hr = dxbc_init(dxbc, chunk_count);
......@@ -626,13 +626,13 @@ HRESULT dxbc_parse(const char *data, SIZE_T data_size, struct dxbc *dxbc)
const char *chunk_ptr;
DWORD chunk_offset;
read_dword(&ptr, &chunk_offset);
chunk_offset = read_dword(&ptr);
TRACE("chunk %u at offset %#x\n", i, chunk_offset);
chunk_ptr = data + chunk_offset;
read_dword(&chunk_ptr, &chunk_tag);
read_dword(&chunk_ptr, &chunk_size);
chunk_tag = read_dword(&chunk_ptr);
chunk_size = read_dword(&chunk_ptr);
hr = dxbc_add_section(dxbc, chunk_tag, chunk_ptr, chunk_size);
if (FAILED(hr))
......
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