continue working on input less

This commit is contained in:
Vincent Lejeune
2016-01-18 20:42:20 +01:00
parent d9f4b4b600
commit 73a4555c9d
4 changed files with 25 additions and 13 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ private:
RSXVertexProgram vertex_program; RSXVertexProgram vertex_program;
RSXFragmentProgram fragment_program; RSXFragmentProgram fragment_program;
PipelineStateObjectCache m_pso_cache; PipelineStateObjectCache m_pso_cache;
std::tuple<ComPtr<ID3D12PipelineState>, std::vector<size_t>, size_t> m_current_pso; std::tuple<ComPtr<ID3D12PipelineState>, size_t, size_t> m_current_pso;
struct struct
{ {
+8 -8
View File
@@ -75,7 +75,7 @@ public:
ComPtr<ID3DBlob> bytecode; ComPtr<ID3DBlob> bytecode;
// For debugging // For debugging
std::string content; std::string content;
std::vector<size_t> vertex_shader_inputs; size_t vertex_shader_input_count;
std::vector<size_t> FragmentConstantOffsetCache; std::vector<size_t> FragmentConstantOffsetCache;
size_t m_textureCount; size_t m_textureCount;
@@ -104,7 +104,7 @@ struct D3D12Traits
{ {
using vertex_program_type = Shader; using vertex_program_type = Shader;
using fragment_program_type = Shader; using fragment_program_type = Shader;
using pipeline_storage_type = std::tuple<ComPtr<ID3D12PipelineState>, std::vector<size_t>, size_t>; using pipeline_storage_type = std::tuple<ComPtr<ID3D12PipelineState>, size_t, size_t>;
using pipeline_properties = D3D12PipelineProperties; using pipeline_properties = D3D12PipelineProperties;
static static
@@ -140,15 +140,15 @@ struct D3D12Traits
D3D12VertexProgramDecompiler VS(RSXVP); D3D12VertexProgramDecompiler VS(RSXVP);
std::string shaderCode = VS.Decompile(); std::string shaderCode = VS.Decompile();
vertexProgramData.Compile(shaderCode, Shader::SHADER_TYPE::SHADER_TYPE_VERTEX); vertexProgramData.Compile(shaderCode, Shader::SHADER_TYPE::SHADER_TYPE_VERTEX);
vertexProgramData.vertex_shader_inputs = VS.input_slots; vertexProgramData.vertex_shader_input_count = RSXVP.rsx_vertex_inputs.size();
fs::file(fs::get_config_dir() + "VertexProgram" + std::to_string(ID) + ".hlsl", fom::rewrite).write(shaderCode); fs::file(fs::get_config_dir() + "VertexProgram" + std::to_string(ID) + ".hlsl", fom::rewrite).write(shaderCode);
vertexProgramData.id = (u32)ID; vertexProgramData.id = (u32)ID;
} }
static static
pipeline_storage_type build_pipeline( pipeline_storage_type build_pipeline(
const vertex_program_type &vertexProgramData, const fragment_program_type &fragmentProgramData, const pipeline_properties &pipelineProperties, const vertex_program_type &vertexProgramData, const fragment_program_type &fragmentProgramData, const pipeline_properties &pipelineProperties,
ID3D12Device *device, gsl::span<ComPtr<ID3D12RootSignature>, 17, 16> root_signatures) ID3D12Device *device, gsl::span<ComPtr<ID3D12RootSignature>, 17, 16> root_signatures)
{ {
std::tuple<ID3D12PipelineState *, std::vector<size_t>, size_t> result = {}; std::tuple<ID3D12PipelineState *, std::vector<size_t>, size_t> result = {};
D3D12_GRAPHICS_PIPELINE_STATE_DESC graphicPipelineStateDesc = {}; D3D12_GRAPHICS_PIPELINE_STATE_DESC graphicPipelineStateDesc = {};
@@ -163,7 +163,7 @@ struct D3D12Traits
graphicPipelineStateDesc.PS.BytecodeLength = fragmentProgramData.bytecode->GetBufferSize(); graphicPipelineStateDesc.PS.BytecodeLength = fragmentProgramData.bytecode->GetBufferSize();
graphicPipelineStateDesc.PS.pShaderBytecode = fragmentProgramData.bytecode->GetBufferPointer(); graphicPipelineStateDesc.PS.pShaderBytecode = fragmentProgramData.bytecode->GetBufferPointer();
graphicPipelineStateDesc.pRootSignature = root_signatures[fragmentProgramData.m_textureCount][vertexProgramData.vertex_shader_inputs.size() - 1].Get(); graphicPipelineStateDesc.pRootSignature = root_signatures[fragmentProgramData.m_textureCount][vertexProgramData.vertex_shader_input_count - 1].Get();
graphicPipelineStateDesc.BlendState = pipelineProperties.Blend; graphicPipelineStateDesc.BlendState = pipelineProperties.Blend;
graphicPipelineStateDesc.DepthStencilState = pipelineProperties.DepthStencil; graphicPipelineStateDesc.DepthStencilState = pipelineProperties.DepthStencil;
@@ -186,7 +186,7 @@ struct D3D12Traits
std::wstring name = L"PSO_" + std::to_wstring(vertexProgramData.id) + L"_" + std::to_wstring(fragmentProgramData.id); std::wstring name = L"PSO_" + std::to_wstring(vertexProgramData.id) + L"_" + std::to_wstring(fragmentProgramData.id);
pso->SetName(name.c_str()); pso->SetName(name.c_str());
return std::make_tuple(pso, vertexProgramData.vertex_shader_inputs, fragmentProgramData.m_textureCount); return std::make_tuple(pso, vertexProgramData.vertex_shader_input_count, fragmentProgramData.m_textureCount);
} }
}; };
@@ -60,7 +60,6 @@ void D3D12VertexProgramDecompiler::insertInputs(std::stringstream & OS, const st
for (const ParamItem &PI : PT.items) for (const ParamItem &PI : PT.items)
{ {
input_data.push_back(std::make_tuple(PI.location, PI.name)); input_data.push_back(std::make_tuple(PI.location, PI.name));
input_slots.push_back(PI.location);
} }
} }
@@ -169,7 +168,19 @@ void D3D12VertexProgramDecompiler::insertMainStart(std::stringstream & OS)
for (const ParamType PT : m_parr.params[PF_PARAM_IN]) for (const ParamType PT : m_parr.params[PF_PARAM_IN])
{ {
for (const ParamItem &PI : PT.items) for (const ParamItem &PI : PT.items)
OS << " " << PT.type << " " << PI.name << " = " << PI.name << "_buffer.Load(vertex_id);" << std::endl; {
for (const auto &real_input : rsx_vertex_program.rsx_vertex_inputs)
{
if (real_input.location != PI.location)
continue;
if (!real_input.is_array)
{
OS << " " << PT.type << " " << PI.name << " = " << PI.name << "_buffer.Load(0);\n";
continue;
}
OS << " " << PT.type << " " << PI.name << " = " << PI.name << "_buffer.Load(vertex_id);\n";
}
}
} }
} }
@@ -189,7 +200,7 @@ void D3D12VertexProgramDecompiler::insertMainEnd(std::stringstream & OS)
} }
D3D12VertexProgramDecompiler::D3D12VertexProgramDecompiler(const RSXVertexProgram &prog) : D3D12VertexProgramDecompiler::D3D12VertexProgramDecompiler(const RSXVertexProgram &prog) :
VertexProgramDecompiler(prog) VertexProgramDecompiler(prog), rsx_vertex_program(prog)
{ {
} }
#endif #endif
@@ -18,7 +18,8 @@ protected:
virtual void insertOutputs(std::stringstream &OS, const std::vector<ParamType> &outputs); virtual void insertOutputs(std::stringstream &OS, const std::vector<ParamType> &outputs);
virtual void insertMainStart(std::stringstream &OS); virtual void insertMainStart(std::stringstream &OS);
virtual void insertMainEnd(std::stringstream &OS); virtual void insertMainEnd(std::stringstream &OS);
const RSXVertexProgram &rsx_vertex_program;
public: public:
std::vector<size_t> input_slots;
D3D12VertexProgramDecompiler(const RSXVertexProgram &prog); D3D12VertexProgramDecompiler(const RSXVertexProgram &prog);
}; };