diff options
| -rw-r--r-- | src/video_core/command_processor.cpp | 11 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 24 | ||||
| -rw-r--r-- | src/video_core/shader/shader_interpreter.cpp | 2 |
3 files changed, 19 insertions, 18 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 54721561e..33414258a 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -234,7 +234,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 234 | 234 | ||
| 235 | const auto& index_info = regs.index_array; | 235 | const auto& index_info = regs.index_array; |
| 236 | const u8* index_address_8 = Memory::GetPhysicalPointer(base_address + index_info.offset); | 236 | const u8* index_address_8 = Memory::GetPhysicalPointer(base_address + index_info.offset); |
| 237 | const u16* index_address_16 = (u16*)index_address_8; | 237 | const u16* index_address_16 = reinterpret_cast<const u16*>(index_address_8); |
| 238 | bool index_u16 = index_info.format != 0; | 238 | bool index_u16 = index_info.format != 0; |
| 239 | 239 | ||
| 240 | #if PICA_DUMP_GEOMETRY | 240 | #if PICA_DUMP_GEOMETRY |
| @@ -345,10 +345,11 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 345 | : (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? 2 : 1); | 345 | : (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? 2 : 1); |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata : | 348 | const float srcval = |
| 349 | (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata : | 349 | (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *reinterpret_cast<const s8*>(srcdata) : |
| 350 | (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? *(s16*)srcdata : | 350 | (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *reinterpret_cast<const u8*>(srcdata) : |
| 351 | *(float*)srcdata; | 351 | (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? *reinterpret_cast<const s16*>(srcdata) : |
| 352 | *reinterpret_cast<const float*>(srcdata); | ||
| 352 | 353 | ||
| 353 | input.attr[i][comp] = float24::FromFloat32(srcval); | 354 | input.attr[i][comp] = float24::FromFloat32(srcval); |
| 354 | LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08x + 0x%04x: %f", | 355 | LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08x + 0x%04x: %f", |
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 271e81ca1..bac6d69c7 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -117,13 +117,13 @@ void GeometryDumper::Dump() { | |||
| 117 | void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, const Shader::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes) | 117 | void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, const Shader::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes) |
| 118 | { | 118 | { |
| 119 | struct StuffToWrite { | 119 | struct StuffToWrite { |
| 120 | u8* pointer; | 120 | const u8* pointer; |
| 121 | u32 size; | 121 | u32 size; |
| 122 | }; | 122 | }; |
| 123 | std::vector<StuffToWrite> writing_queue; | 123 | std::vector<StuffToWrite> writing_queue; |
| 124 | u32 write_offset = 0; | 124 | u32 write_offset = 0; |
| 125 | 125 | ||
| 126 | auto QueueForWriting = [&writing_queue,&write_offset](u8* pointer, u32 size) { | 126 | auto QueueForWriting = [&writing_queue,&write_offset](const u8* pointer, u32 size) { |
| 127 | writing_queue.push_back({pointer, size}); | 127 | writing_queue.push_back({pointer, size}); |
| 128 | u32 old_write_offset = write_offset; | 128 | u32 old_write_offset = write_offset; |
| 129 | write_offset += size; | 129 | write_offset += size; |
| @@ -228,27 +228,27 @@ void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, c | |||
| 228 | DVLPHeader dvlp{ DVLPHeader::MAGIC_WORD }; | 228 | DVLPHeader dvlp{ DVLPHeader::MAGIC_WORD }; |
| 229 | DVLEHeader dvle{ DVLEHeader::MAGIC_WORD }; | 229 | DVLEHeader dvle{ DVLEHeader::MAGIC_WORD }; |
| 230 | 230 | ||
| 231 | QueueForWriting((u8*)&dvlb, sizeof(dvlb)); | 231 | QueueForWriting(reinterpret_cast<const u8*>(&dvlb), sizeof(dvlb)); |
| 232 | u32 dvlp_offset = QueueForWriting((u8*)&dvlp, sizeof(dvlp)); | 232 | u32 dvlp_offset = QueueForWriting(reinterpret_cast<const u8*>(&dvlp), sizeof(dvlp)); |
| 233 | dvlb.dvle_offset = QueueForWriting((u8*)&dvle, sizeof(dvle)); | 233 | dvlb.dvle_offset = QueueForWriting(reinterpret_cast<const u8*>(&dvle), sizeof(dvle)); |
| 234 | 234 | ||
| 235 | // TODO: Reduce the amount of binary code written to relevant portions | 235 | // TODO: Reduce the amount of binary code written to relevant portions |
| 236 | dvlp.binary_offset = write_offset - dvlp_offset; | 236 | dvlp.binary_offset = write_offset - dvlp_offset; |
| 237 | dvlp.binary_size_words = setup.program_code.size(); | 237 | dvlp.binary_size_words = setup.program_code.size(); |
| 238 | QueueForWriting((u8*)setup.program_code.data(), setup.program_code.size() * sizeof(u32)); | 238 | QueueForWriting(reinterpret_cast<const u8*>(setup.program_code.data()), setup.program_code.size() * sizeof(u32)); |
| 239 | 239 | ||
| 240 | dvlp.swizzle_info_offset = write_offset - dvlp_offset; | 240 | dvlp.swizzle_info_offset = write_offset - dvlp_offset; |
| 241 | dvlp.swizzle_info_num_entries = setup.swizzle_data.size(); | 241 | dvlp.swizzle_info_num_entries = setup.swizzle_data.size(); |
| 242 | u32 dummy = 0; | 242 | u32 dummy = 0; |
| 243 | for (unsigned int i = 0; i < setup.swizzle_data.size(); ++i) { | 243 | for (unsigned int i = 0; i < setup.swizzle_data.size(); ++i) { |
| 244 | QueueForWriting((u8*)&setup.swizzle_data[i], sizeof(setup.swizzle_data[i])); | 244 | QueueForWriting(reinterpret_cast<const u8*>(&setup.swizzle_data[i]), sizeof(setup.swizzle_data[i])); |
| 245 | QueueForWriting((u8*)&dummy, sizeof(dummy)); | 245 | QueueForWriting(reinterpret_cast<const u8*>(&dummy), sizeof(dummy)); |
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | dvle.main_offset_words = config.main_offset; | 248 | dvle.main_offset_words = config.main_offset; |
| 249 | dvle.output_register_table_offset = write_offset - dvlb.dvle_offset; | 249 | dvle.output_register_table_offset = write_offset - dvlb.dvle_offset; |
| 250 | dvle.output_register_table_size = static_cast<u32>(output_info_table.size()); | 250 | dvle.output_register_table_size = static_cast<u32>(output_info_table.size()); |
| 251 | QueueForWriting((u8*)output_info_table.data(), static_cast<u32>(output_info_table.size() * sizeof(OutputRegisterInfo))); | 251 | QueueForWriting(reinterpret_cast<const u8*>(output_info_table.data()), static_cast<u32>(output_info_table.size() * sizeof(OutputRegisterInfo))); |
| 252 | 252 | ||
| 253 | // TODO: Create a label table for "main" | 253 | // TODO: Create a label table for "main" |
| 254 | 254 | ||
| @@ -292,14 +292,14 @@ void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, c | |||
| 292 | dvle.constant_table_offset = write_offset - dvlb.dvle_offset; | 292 | dvle.constant_table_offset = write_offset - dvlb.dvle_offset; |
| 293 | dvle.constant_table_size = constant_table.size(); | 293 | dvle.constant_table_size = constant_table.size(); |
| 294 | for (const auto& constant : constant_table) { | 294 | for (const auto& constant : constant_table) { |
| 295 | QueueForWriting((uint8_t*)&constant, sizeof(constant)); | 295 | QueueForWriting(reinterpret_cast<const u8*>(&constant), sizeof(constant)); |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | // Write data to file | 298 | // Write data to file |
| 299 | std::ofstream file(filename, std::ios_base::out | std::ios_base::binary); | 299 | std::ofstream file(filename, std::ios_base::out | std::ios_base::binary); |
| 300 | 300 | ||
| 301 | for (auto& chunk : writing_queue) { | 301 | for (const auto& chunk : writing_queue) { |
| 302 | file.write((char*)chunk.pointer, chunk.size); | 302 | file.write(reinterpret_cast<const char*>(chunk.pointer), chunk.size); |
| 303 | } | 303 | } |
| 304 | } | 304 | } |
| 305 | 305 | ||
diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index 295a2466b..02e1a1cb1 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp | |||
| @@ -409,7 +409,7 @@ void RunInterpreter(UnitState<Debug>& state) { | |||
| 409 | { | 409 | { |
| 410 | if ((instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MAD) || | 410 | if ((instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MAD) || |
| 411 | (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI)) { | 411 | (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI)) { |
| 412 | const SwizzlePattern& swizzle = *(SwizzlePattern*)&swizzle_data[instr.mad.operand_desc_id]; | 412 | const SwizzlePattern& swizzle = *reinterpret_cast<const SwizzlePattern*>(&swizzle_data[instr.mad.operand_desc_id]); |
| 413 | 413 | ||
| 414 | bool is_inverted = (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI); | 414 | bool is_inverted = (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI); |
| 415 | 415 | ||