mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-30 23:33:17 +00:00
Merge pull request #287 from polybiusproxy/dev
gnmdriver: Implement shader functions
This commit is contained in:
commit
c49afb4c17
8 changed files with 216 additions and 60 deletions
|
@ -837,7 +837,15 @@ struct Liverpool {
|
|||
ShaderProgram ps_program;
|
||||
INSERT_PADDING_WORDS(0x2C);
|
||||
ShaderProgram vs_program;
|
||||
INSERT_PADDING_WORDS(0x2E00 - 0x2C4C - 16);
|
||||
INSERT_PADDING_WORDS(0x2C);
|
||||
ShaderProgram gs_program;
|
||||
INSERT_PADDING_WORDS(0x2C);
|
||||
ShaderProgram es_program;
|
||||
INSERT_PADDING_WORDS(0x2C);
|
||||
ShaderProgram hs_program;
|
||||
INSERT_PADDING_WORDS(0x2C);
|
||||
ShaderProgram ls_program;
|
||||
INSERT_PADDING_WORDS(0xA4);
|
||||
ComputeProgram cs_program;
|
||||
INSERT_PADDING_WORDS(0xA008 - 0x2E00 - 80 - 3 - 5);
|
||||
DepthRenderControl depth_render_control;
|
||||
|
@ -916,12 +924,19 @@ struct Liverpool {
|
|||
const ShaderProgram* ProgramForStage(u32 index) const {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return &vs_program;
|
||||
case 4:
|
||||
return &ps_program;
|
||||
default:
|
||||
return nullptr;
|
||||
case 1:
|
||||
return &vs_program;
|
||||
case 2:
|
||||
return &gs_program;
|
||||
case 3:
|
||||
return &es_program;
|
||||
case 4:
|
||||
return &hs_program;
|
||||
case 5:
|
||||
return &ls_program;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1026,6 +1041,10 @@ private:
|
|||
static_assert(GFX6_3D_REG_INDEX(ps_program) == 0x2C08);
|
||||
static_assert(GFX6_3D_REG_INDEX(vs_program) == 0x2C48);
|
||||
static_assert(GFX6_3D_REG_INDEX(vs_program.user_data) == 0x2C4C);
|
||||
static_assert(GFX6_3D_REG_INDEX(gs_program) == 0x2C88);
|
||||
static_assert(GFX6_3D_REG_INDEX(es_program) == 0x2CC8);
|
||||
static_assert(GFX6_3D_REG_INDEX(hs_program) == 0x2D08);
|
||||
static_assert(GFX6_3D_REG_INDEX(ls_program) == 0x2D48);
|
||||
static_assert(GFX6_3D_REG_INDEX(cs_program) == 0x2E00);
|
||||
static_assert(GFX6_3D_REG_INDEX(cs_program.dim_z) == 0x2E03);
|
||||
static_assert(GFX6_3D_REG_INDEX(cs_program.address_lo) == 0x2E0C);
|
||||
|
|
|
@ -48,7 +48,7 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
|
|||
|
||||
boost::container::static_vector<vk::VertexInputBindingDescription, 32> bindings;
|
||||
boost::container::static_vector<vk::VertexInputAttributeDescription, 32> attributes;
|
||||
const auto& vs_info = stages[0];
|
||||
const auto& vs_info = stages[u32(Shader::Stage::Vertex)];
|
||||
for (const auto& input : vs_info.vs_inputs) {
|
||||
if (input.instance_step_rate == Shader::Info::VsInput::InstanceIdType::OverStepRate0 ||
|
||||
input.instance_step_rate == Shader::Info::VsInput::InstanceIdType::OverStepRate1) {
|
||||
|
@ -179,20 +179,21 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
|
|||
.maxDepthBounds = key.depth_bounds_max,
|
||||
};
|
||||
|
||||
u32 shader_count = 1;
|
||||
u32 shader_count{};
|
||||
auto stage = u32(Shader::Stage::Vertex);
|
||||
std::array<vk::PipelineShaderStageCreateInfo, MaxShaderStages> shader_stages;
|
||||
shader_stages[0] = vk::PipelineShaderStageCreateInfo{
|
||||
shader_stages[shader_count++] = vk::PipelineShaderStageCreateInfo{
|
||||
.stage = vk::ShaderStageFlagBits::eVertex,
|
||||
.module = modules[0],
|
||||
.module = modules[stage],
|
||||
.pName = "main",
|
||||
};
|
||||
if (modules[4]) {
|
||||
shader_stages[1] = vk::PipelineShaderStageCreateInfo{
|
||||
stage = u32(Shader::Stage::Fragment);
|
||||
if (modules[stage]) {
|
||||
shader_stages[shader_count++] = vk::PipelineShaderStageCreateInfo{
|
||||
.stage = vk::ShaderStageFlagBits::eFragment,
|
||||
.module = modules[4],
|
||||
.module = modules[stage],
|
||||
.pName = "main",
|
||||
};
|
||||
++shader_count;
|
||||
}
|
||||
|
||||
const auto it = std::ranges::find(key.color_formats, vk::Format::eUndefined);
|
||||
|
@ -411,7 +412,7 @@ void GraphicsPipeline::BindResources(Core::MemoryManager* memory, StreamBuffer&
|
|||
}
|
||||
|
||||
void GraphicsPipeline::BindVertexBuffers(StreamBuffer& staging) const {
|
||||
const auto& vs_info = stages[0];
|
||||
const auto& vs_info = stages[u32(Shader::Stage::Vertex)];
|
||||
if (vs_info.vs_inputs.empty()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
bool IsEmbeddedVs() const noexcept {
|
||||
static constexpr size_t EmbeddedVsHash = 0x9b2da5cf47f8c29f;
|
||||
return key.stage_hashes[0] == EmbeddedVsHash;
|
||||
return key.stage_hashes[u32(Shader::Stage::Vertex)] == EmbeddedVsHash;
|
||||
}
|
||||
|
||||
auto GetWriteMasks() const {
|
||||
|
|
|
@ -256,6 +256,12 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline() {
|
|||
block_pool.ReleaseContents();
|
||||
inst_pool.ReleaseContents();
|
||||
|
||||
if (stage != Shader::Stage::Compute && stage != Shader::Stage::Fragment &&
|
||||
stage != Shader::Stage::Vertex) {
|
||||
LOG_ERROR(Render_Vulkan, "Unsupported shader stage {}. PL creation skipped.", stage);
|
||||
return {};
|
||||
}
|
||||
|
||||
// Recompile shader to IR.
|
||||
try {
|
||||
LOG_INFO(Render_Vulkan, "Compiling {} shader {:#x}", stage, hash);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue