From a52846b045a645b0bb64c198438052b15cd86f13 Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Thu, 26 Jan 2017 12:02:31 +0100 Subject: [PATCH] Fix warnings in spirv_hlsl.cpp --- spirv_hlsl.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/spirv_hlsl.cpp b/spirv_hlsl.cpp index 34acec53..d01df21f 100644 --- a/spirv_hlsl.cpp +++ b/spirv_hlsl.cpp @@ -26,8 +26,8 @@ namespace { struct VariableComparator { - VariableComparator(const std::vector &meta) - : meta(meta) + VariableComparator(const std::vector &m) + : meta(m) { } @@ -137,8 +137,6 @@ string CompilerHLSL::type_to_glsl(const SPIRType &type) void CompilerHLSL::emit_header() { - auto &execution = get_entry_point(); - for (auto &header : header_lines) statement(header); @@ -151,7 +149,6 @@ void CompilerHLSL::emit_header() void CompilerHLSL::emit_interface_block_globally(const SPIRVariable &var) { auto &execution = get_entry_point(); - auto &type = get(var.basetype); add_resource_name(var.self); @@ -204,15 +201,11 @@ void CompilerHLSL::emit_interface_block_in_struct(const SPIRVariable &var, uint3 { for (int i = 0; i < 4; ++i) { - char name[101]; - strcpy(name, m.alias.c_str()); - strcat(name, "_"); - size_t length = strlen(name); - sprintf(&name[length], "%d", i); - name[length + 1] = 0; + std::stringstream name; + name << m.alias << "_" << i; SPIRType newtype = type; newtype.columns = 1; - statement(variable_decl(newtype, name), " : ", binding, binding_number++, ";"); + statement(variable_decl(newtype, name.str()), " : ", binding, binding_number++, ";"); } --binding_number; } @@ -479,7 +472,7 @@ void CompilerHLSL::emit_buffer_block(const SPIRVariable &var) end_scope_decl(); } -void CompilerHLSL::emit_push_constant_block(const SPIRVariable &var) +void CompilerHLSL::emit_push_constant_block(const SPIRVariable &) { statement("constant block"); } @@ -561,8 +554,8 @@ void CompilerHLSL::emit_hlsl_entry_point() continue; auto &m = meta[var.self].decoration; - auto &type = get(var.basetype); - if (type.vecsize == 4 && type.columns == 4) + auto &mtype = get(var.basetype); + if (mtype.vecsize == 4 && mtype.columns == 4) { statement(m.alias, "[0] = input.", m.alias, "_0;"); statement(m.alias, "[1] = input.", m.alias, "_1;"); @@ -939,7 +932,6 @@ void CompilerHLSL::emit_binary_func_op_transpose_all(uint32_t result_type, uint3 void CompilerHLSL::emit_uniform(const SPIRVariable &var) { - auto &type = get(var.basetype); add_resource_name(var.self); statement("uniform ", variable_decl(var), ";"); } @@ -981,7 +973,6 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) { auto ops = stream(instruction); auto opcode = static_cast(instruction.op); - uint32_t length = instruction.length; #define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op) #define BOP_CAST(op, type, skip_cast) emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, skip_cast)