[D3D12] Build and code format fixes

This commit is contained in:
Triang3l 2018-07-24 15:14:16 +03:00
parent 87aecfa1b8
commit c0ff73a588
4 changed files with 33 additions and 33 deletions

View File

@ -16,7 +16,7 @@
#include "xenia/gpu/gpu_flags.h" #include "xenia/gpu/gpu_flags.h"
DEFINE_bool(d3d12_shader_disasm, true, DEFINE_bool(d3d12_shader_disasm, true,
"Disassemble translated shaders after compilation."); "Disassemble translated shaders after compilation.");
namespace xe { namespace xe {
namespace gpu { namespace gpu {
@ -52,11 +52,10 @@ bool D3D12Shader::Prepare() {
// TODO(Triang3l): Choose the appropriate optimization level based on compile // TODO(Triang3l): Choose the appropriate optimization level based on compile
// time and how invariance is handled in vertex shaders. // time and how invariance is handled in vertex shaders.
ID3DBlob* error_blob = nullptr; ID3DBlob* error_blob = nullptr;
bool compiled = bool compiled = SUCCEEDED(
SUCCEEDED(D3DCompile(translated_binary_.data(), translated_binary_.size(), D3DCompile(translated_binary_.data(), translated_binary_.size(), nullptr,
nullptr, nullptr, nullptr, "main", target, nullptr, nullptr, "main", target,
D3DCOMPILE_OPTIMIZATION_LEVEL0, 0, &blob_, D3DCOMPILE_OPTIMIZATION_LEVEL0, 0, &blob_, &error_blob));
&error_blob));
if (!compiled) { if (!compiled) {
XELOGE("%s shader %.16llX compilation failed!", target, ucode_data_hash()); XELOGE("%s shader %.16llX compilation failed!", target, ucode_data_hash());
@ -65,14 +64,16 @@ bool D3D12Shader::Prepare() {
if (compiled) { if (compiled) {
XELOGW("%s shader %.16llX compiled with warnings!", target, XELOGW("%s shader %.16llX compiled with warnings!", target,
ucode_data_hash()); ucode_data_hash());
XELOGW("%s", reinterpret_cast<const char*>(error_blob->GetBufferPointer())); XELOGW("%s",
reinterpret_cast<const char*>(error_blob->GetBufferPointer()));
XELOGW("HLSL source:"); XELOGW("HLSL source:");
// The buffer isn't terminated. // The buffer isn't terminated.
translated_binary_.push_back(0); translated_binary_.push_back(0);
XELOGW("%s", reinterpret_cast<const char*>(translated_binary_.data())); XELOGW("%s", reinterpret_cast<const char*>(translated_binary_.data()));
translated_binary_.pop_back(); translated_binary_.pop_back();
} else { } else {
XELOGE("%s", reinterpret_cast<const char*>(error_blob->GetBufferPointer())); XELOGE("%s",
reinterpret_cast<const char*>(error_blob->GetBufferPointer()));
XELOGE("HLSL source:"); XELOGE("HLSL source:");
translated_binary_.push_back(0); translated_binary_.push_back(0);
XELOGE("%s", reinterpret_cast<const char*>(translated_binary_.data())); XELOGE("%s", reinterpret_cast<const char*>(translated_binary_.data()));

View File

@ -13,6 +13,7 @@
#include "xenia/base/assert.h" #include "xenia/base/assert.h"
#include "xenia/base/logging.h" #include "xenia/base/logging.h"
#include "xenia/base/profiling.h"
#include "xenia/gpu/gpu_flags.h" #include "xenia/gpu/gpu_flags.h"
#include "xenia/gpu/hlsl_shader_translator.h" #include "xenia/gpu/hlsl_shader_translator.h"
@ -28,9 +29,7 @@ PipelineCache::PipelineCache(RegisterFile* register_file,
PipelineCache::~PipelineCache() { Shutdown(); } PipelineCache::~PipelineCache() { Shutdown(); }
void PipelineCache::Shutdown() { void PipelineCache::Shutdown() { ClearCache(); }
ClearCache();
}
D3D12Shader* PipelineCache::LoadShader(ShaderType shader_type, D3D12Shader* PipelineCache::LoadShader(ShaderType shader_type,
uint32_t guest_address, uint32_t guest_address,
@ -47,8 +46,8 @@ D3D12Shader* PipelineCache::LoadShader(ShaderType shader_type,
// Always create the shader and stash it away. // Always create the shader and stash it away.
// We need to track it even if it fails translation so we know not to try // We need to track it even if it fails translation so we know not to try
// again. // again.
D3D12Shader* shader = new D3D12Shader(shader_type, data_hash, host_address, D3D12Shader* shader =
dword_count); new D3D12Shader(shader_type, data_hash, host_address, dword_count);
shader_map_.insert({data_hash, shader}); shader_map_.insert({data_hash, shader});
return shader; return shader;

View File

@ -165,23 +165,23 @@ std::vector<uint8_t> HlslShaderTranslator::CompleteTranslation() {
// Common declarations. // Common declarations.
source.Append( source.Append(
"cbuffer xe_system_constants : register(b0) {\n" "cbuffer xe_system_constants : register(b0) {\n"
" float2 xe_viewport_inv_scale;\n" " float2 xe_viewport_inv_scale;\n"
" uint xe_vertex_index_endian;\n" " uint xe_vertex_index_endian;\n"
" uint xe_textures_are_3d;\n" " uint xe_textures_are_3d;\n"
"};\n" "};\n"
"\n" "\n"
"struct XeFloatConstantPage {\n" "struct XeFloatConstantPage {\n"
" float4 c[16];\n" " float4 c[16];\n"
"};\n" "};\n"
"ConstantBuffer<XeFloatConstantPage> " "ConstantBuffer<XeFloatConstantPage> "
"xe_float_constants[16] : register(b1);\n" "xe_float_constants[16] : register(b1);\n"
"\n" "\n"
"cbuffer xe_loop_bool_constants : register(b17) {\n" "cbuffer xe_loop_bool_constants : register(b17) {\n"
" uint xe_bool_constants[8];\n" " uint xe_bool_constants[8];\n"
" uint xe_loop_constants[32];\n" " uint xe_loop_constants[32];\n"
"};\n" "};\n"
"\n"); "\n");
if (is_vertex_shader()) { if (is_vertex_shader()) {
// Vertex fetching, output and prologue. // Vertex fetching, output and prologue.
@ -307,8 +307,8 @@ std::vector<uint8_t> HlslShaderTranslator::CompleteTranslation() {
// Epilogue. // Epilogue.
if (!cf_wrote_pc_) { if (!cf_wrote_pc_) {
source.Append( source.Append(
" xe_pc = 0xFFFFu;\n" " xe_pc = 0xFFFFu;\n"
" break;\n"); " break;\n");
} }
source.Append( source.Append(
" default:\n" " default:\n"

View File

@ -13,9 +13,9 @@
// This must be included before D3D and DXGI for things like NOMINMAX. // This must be included before D3D and DXGI for things like NOMINMAX.
#include "xenia/base/platform_win.h" #include "xenia/base/platform_win.h"
#include <dxgi1_4.h>
#include <d3d12.h> #include <d3d12.h>
#include <d3dcompiler.h> #include <d3dcompiler.h>
#include <dxgi1_4.h>
#define XELOGD3D XELOGI #define XELOGD3D XELOGI