spirv: Support OpenGL uniform buffers and change bindings

This commit is contained in:
ReinUsesLisp 2021-05-23 03:58:11 -03:00 committed by ameerj
parent d5d6778ba5
commit 48a17298d7
6 changed files with 168 additions and 58 deletions

View file

@ -17,6 +17,14 @@ namespace Shader::Backend::SPIRV {
using Sirit::Id;
struct Bindings {
u32 unified{};
u32 uniform_buffer{};
u32 storage_buffer{};
u32 texture{};
u32 image{};
};
class VectorTypes {
public:
void Define(Sirit::Module& sirit_ctx, Id base_type, std::string_view name);
@ -62,6 +70,7 @@ struct UniformDefinitions {
Id U32{};
Id F32{};
Id U32x2{};
Id U32x4{};
};
struct StorageTypeDefinition {
@ -101,11 +110,14 @@ struct GenericElementInfo {
class EmitContext final : public Sirit::Module {
public:
explicit EmitContext(const Profile& profile, IR::Program& program, u32& binding);
explicit EmitContext(const Profile& profile, IR::Program& program, Bindings& binding);
~EmitContext();
[[nodiscard]] Id Def(const IR::Value& value);
[[nodiscard]] Id BitOffset8(const IR::Value& offset);
[[nodiscard]] Id BitOffset16(const IR::Value& offset);
Id Const(u32 value) {
return Constant(U32[1], value);
}
@ -139,6 +151,7 @@ public:
Id U64{};
VectorTypes F32;
VectorTypes U32;
VectorTypes S32;
VectorTypes F16;
VectorTypes F64;