From e77e4891dcba2366b456f825016c92a0f7e7688d Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sat, 10 Sep 2022 20:29:47 +0100 Subject: [PATCH] Tidy up Maxwell 3D regs a bit --- .../cpp/skyline/gpu/descriptor_allocator.cpp | 8 +++---- .../maxwell_3d/constant_buffers.cpp | 4 ++-- .../maxwell_3d/constant_buffers.h | 6 ++--- .../interconnect/maxwell_3d/maxwell_3d.cpp | 2 +- .../gpu/interconnect/maxwell_3d/maxwell_3d.h | 2 +- .../skyline/soc/gm20b/engines/maxwell/types.h | 21 +++-------------- .../skyline/soc/gm20b/engines/maxwell_3d.cpp | 23 ++----------------- .../skyline/soc/gm20b/engines/maxwell_3d.h | 4 ++-- 8 files changed, 18 insertions(+), 52 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/descriptor_allocator.cpp b/app/src/main/cpp/skyline/gpu/descriptor_allocator.cpp index f89060b7..a22fae6c 100644 --- a/app/src/main/cpp/skyline/gpu/descriptor_allocator.cpp +++ b/app/src/main/cpp/skyline/gpu/descriptor_allocator.cpp @@ -19,19 +19,19 @@ namespace skyline::gpu { using DescriptorSizes = std::array; constexpr DescriptorSizes BaseDescriptorSizes{ vk::DescriptorPoolSize{ - .descriptorCount = maxwell3d::PipelineStageConstantBufferCount, + .descriptorCount = maxwell3d::ShaderStageConstantBufferCount, .type = vk::DescriptorType::eUniformBuffer, }, vk::DescriptorPoolSize{ - .descriptorCount = maxwell3d::PipelineStageCount * 5, + .descriptorCount = maxwell3d::ShaderStageCount * 5, .type = vk::DescriptorType::eStorageBuffer, }, vk::DescriptorPoolSize{ - .descriptorCount = maxwell3d::PipelineStageCount * 5, + .descriptorCount = maxwell3d::ShaderStageCount * 5, .type = vk::DescriptorType::eCombinedImageSampler, }, vk::DescriptorPoolSize{ - .descriptorCount = maxwell3d::PipelineStageCount, + .descriptorCount = maxwell3d::ShaderStageCount, .type = vk::DescriptorType::eStorageImage, }, vk::DescriptorPoolSize{ diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp index 9f207f82..0dff81ba 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp @@ -70,12 +70,12 @@ namespace skyline::gpu::interconnect::maxwell3d { } } - void ConstantBuffers::Bind(InterconnectContext &ctx, engine::PipelineStage stage, size_t index) { + void ConstantBuffers::Bind(InterconnectContext &ctx, engine::ShaderStage stage, size_t index) { auto &view{*selectorState.UpdateGet(ctx).view}; boundConstantBuffers[static_cast(stage)][index] = {view}; } - void ConstantBuffers::Unbind(engine::PipelineStage stage, size_t index) { + void ConstantBuffers::Unbind(engine::ShaderStage stage, size_t index) { boundConstantBuffers[static_cast(stage)][index] = {}; } } \ No newline at end of file diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.h b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.h index bb61bc73..f754b6f7 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.h @@ -48,7 +48,7 @@ namespace skyline::gpu::interconnect::maxwell3d { dirty::ManualDirtyState selectorState; public: - std::array, engine::PipelineStageCount> boundConstantBuffers; + std::array, engine::ShaderStageCount> boundConstantBuffers; ConstantBuffers(DirtyManager &manager, const ConstantBufferSelectorState::EngineRegisters &constantBufferSelectorRegisters); @@ -56,8 +56,8 @@ namespace skyline::gpu::interconnect::maxwell3d { void Load(InterconnectContext &ctx, span data, u32 offset); - void Bind(InterconnectContext &ctx, engine::PipelineStage stage, size_t index); + void Bind(InterconnectContext &ctx, engine::ShaderStage stage, size_t index); - void Unbind(engine::PipelineStage stage, size_t index); + void Unbind(engine::ShaderStage stage, size_t index); }; } diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp index 2cb8ef07..1d6325dc 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp @@ -79,7 +79,7 @@ namespace skyline::gpu::interconnect::maxwell3d { constantBuffers.Load(ctx, data, offset); } - void Maxwell3D::BindConstantBuffer(engine::PipelineStage stage, u32 index, bool enable) { + void Maxwell3D::BindConstantBuffer(engine::ShaderStage stage, u32 index, bool enable) { if (enable) constantBuffers.Bind(ctx, stage, index); else diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.h b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.h index 7230adf8..39692189 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.h @@ -58,7 +58,7 @@ namespace skyline::gpu::interconnect::maxwell3d { /** * @brief Binds the constant buffer selector to the given pipeline stage */ - void BindConstantBuffer(engine::PipelineStage stage, u32 index, bool enable); + void BindConstantBuffer(engine::ShaderStage stage, u32 index, bool enable); void Clear(engine::ClearSurface &clearSurface); diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell/types.h b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell/types.h index 411fd407..3f01faab 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell/types.h +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell/types.h @@ -823,19 +823,18 @@ namespace skyline::soc::gm20b::engine::maxwell3d::type { }; static_assert(sizeof(SemaphoreInfo) == sizeof(u32)); - constexpr static size_t PipelineStageCount{5}; //!< Amount of pipeline stages on Maxwell 3D + constexpr static size_t ShaderStageCount{5}; //!< Amount of pipeline stages on Maxwell 3D /** * @brief All the pipeline stages that Maxwell3D supports for draws */ - enum class PipelineStage { + enum class ShaderStage { Vertex = 0, TessellationControl = 1, TessellationEvaluation = 2, Geometry = 3, Fragment = 4, }; - static_assert(static_cast(PipelineStage::Fragment) + 1 == PipelineStageCount); struct ConstantBufferSelector { u32 size : 17; @@ -864,24 +863,10 @@ namespace skyline::soc::gm20b::engine::maxwell3d::type { }; static_assert(sizeof(BindlessTexture) == sizeof(u32)); - constexpr static size_t PipelineStageConstantBufferCount{18}; //!< Maximum amount of constant buffers that can be bound to a single pipeline stage + constexpr static size_t ShaderStageConstantBufferCount{18}; //!< Maximum amount of constant buffers that can be bound to a single pipeline stage constexpr static size_t PipelineCount{6}; //!< Amount of shader stages on Maxwell 3D - /** - * @brief All the shader programs stages that Maxwell3D supports for draws - * @note As opposed to pipeline stages, there are two shader programs for the vertex stage - */ - enum class ShaderStage { - VertexA = 0, - VertexB = 1, - TessellationControl = 2, - TessellationEvaluation = 3, - Geometry = 4, - Fragment = 5, - }; - static_assert(static_cast(ShaderStage::Fragment) + 1 == ShaderStageCount); - /** * @brief The arguments to set a shader program for a pipeline stage */ diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp index 6cfd97e4..e3c1a2a6 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp @@ -153,25 +153,6 @@ namespace skyline::soc::gm20b::engine::maxwell3d { if (!redundant) { dirtyManager.MarkDirty(method); - - switch (method) { - - ENGINE_CASE(primitiveRestartEnable, { - interconnect.directState.inputAssembly.SetPrimitiveRestart(primitiveRestartEnable != 0); - }) - - - ENGINE_CASE(tessellationParameters, { - interconnect.directState.tessellation.SetParameters(tessellationParameters); - }) - - ENGINE_CASE(patchSize, { - interconnect.directState.tessellation.SetPatchControlPoints(patchSize); - }) - - default: - break; - } } switch (method) { @@ -275,11 +256,11 @@ namespace skyline::soc::gm20b::engine::maxwell3d { #define PIPELINE_CALLBACKS(z, idx, data) \ ENGINE_ARRAY_STRUCT_CASE(bindGroups, idx, constantBuffer, { \ - interconnect.BindConstantBuffer(static_cast(idx), constantBuffer.shaderSlot, constantBuffer.valid); \ + interconnect.BindConstantBuffer(static_cast(idx), constantBuffer.shaderSlot, constantBuffer.valid); \ }) BOOST_PP_REPEAT(5, PIPELINE_CALLBACKS, 0) - static_assert(type::PipelineStageCount == 5 && type::PipelineStageCount < BOOST_PP_LIMIT_REPEAT); + static_assert(type::ShaderStageCount == 5 && type::ShaderStageCount < BOOST_PP_LIMIT_REPEAT); #undef PIPELINE_CALLBACKS default: break; diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.h b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.h index e7b7478b..d5606e30 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.h +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.h @@ -224,7 +224,7 @@ namespace skyline::soc::gm20b::engine::maxwell3d { Register<0x544, u32> clipDistanceEnable; Register<0x545, u32> sampleCounterEnable; - Register<0x546, float> pointSpriteSize; + Register<0x546, float> pointSize; Register<0x547, u32> zCullStatCountersEnable; Register<0x548, u32> pointSpriteEnable; Register<0x54A, u32> shaderExceptions; @@ -357,7 +357,7 @@ namespace skyline::soc::gm20b::engine::maxwell3d { }; Register<0x8E3, LoadConstantBuffer> loadConstantBuffer; - Register<0x900, std::array> bindGroups; //!< Binds constant buffers to pipeline stages + Register<0x900, std::array> bindGroups; //!< Binds constant buffers to pipeline stages Register<0x982, type::BindlessTexture> bindlessTexture; //!< The index of the constant buffer containing bindless texture descriptors