From 9393018d7393d5583049c374e9fa252ceda9b29d Mon Sep 17 00:00:00 2001 From: boykopovar Date: Fri, 18 Sep 2026 19:54:11 +0300 Subject: [PATCH] feat(shader): add spirv buffer format header --- .../SpirvBackend/SpirvBufferFormat.hpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvBufferFormat.hpp diff --git a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvBufferFormat.hpp b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvBufferFormat.hpp new file mode 100644 index 000000000..ee5741eec --- /dev/null +++ b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvBufferFormat.hpp @@ -0,0 +1,30 @@ +#ifndef CORE_SHADER_RECOMPILIER_SPIRVBACKEND_INCLUDE_SPIRVBACKEND_SPIRVBUFFERFORMAT_HPP +#define CORE_SHADER_RECOMPILIER_SPIRVBACKEND_INCLUDE_SPIRVBACKEND_SPIRVBUFFERFORMAT_HPP + +#include "IntermediateRepresentation/IrMetadata/BufferFormat.hpp" +#include "SpirvBackend/SpirvEmitterState.hpp" +#include + +namespace ShaderRecompiler { + +enum class SpirvFormattedSourceKind { + Memory, + Zero, + One +}; + +struct SpirvFormattedSource { + SpirvFormattedSourceKind kind = SpirvFormattedSourceKind::Zero; + std::uint32_t component = 0; +}; + +[[nodiscard]] IrBufferFormat DecodeTBufferFormat(std::uint32_t dataFormat, std::uint32_t numberFormat); +[[nodiscard]] SpirvFormatComponentType GetFormatComponentType(IrBufferFormat format); +[[nodiscard]] SpirvBufferFormatInfo GetFormatInfo(IrBufferFormat format); +[[nodiscard]] SpirvFormattedSource ResolveFormattedSource(const SpirvBufferFormatInfo& info, std::uint32_t selector); +[[nodiscard]] std::uint32_t FormattedConstantBits(const SpirvBufferFormatInfo& info, SpirvFormattedSourceKind kind); +[[nodiscard]] std::uint32_t GetFormatComponentByteOffset(const SpirvBufferFormatInfo& info, std::uint32_t component); + +} + +#endif