Skip to content

Commit

Permalink
refactor: refactor shader interface
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyAndNotDown committed Apr 14, 2024
1 parent 9dd7024 commit 085320c
Show file tree
Hide file tree
Showing 7 changed files with 517 additions and 312 deletions.
10 changes: 6 additions & 4 deletions Engine/Source/RHI/Include/RHI/Pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ namespace RHI {
uint8_t location;

GlslVertexBinding();
GlslVertexBinding(uint8_t inLocation);
explicit GlslVertexBinding(uint8_t inLocation);
};

using PlatformVertexBinding = std::variant<HlslVertexBinding, GlslVertexBinding>;

template <typename Derived>
struct VertexAttributeBase {
VertexFormat format;
Expand All @@ -44,14 +46,14 @@ namespace RHI {
};

struct VertexAttribute : public VertexAttributeBase<VertexAttribute> {
std::variant<HlslVertexBinding, GlslVertexBinding> platformBinding;
PlatformVertexBinding platformBinding;

explicit VertexAttribute(
const std::variant<HlslVertexBinding, GlslVertexBinding>& inPlatformBinding = {},
const PlatformVertexBinding& inPlatformBinding = {},
VertexFormat inFormat = VertexFormat::max,
size_t inOffset = 0);

VertexAttribute& SetPlatformBinding(std::variant<HlslVertexBinding, GlslVertexBinding> inPlatformBinding);
VertexAttribute& SetPlatformBinding(PlatformVertexBinding inPlatformBinding);
};

template <typename Derived>
Expand Down
4 changes: 2 additions & 2 deletions Engine/Source/RHI/Src/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ namespace RHI {
{
}

VertexAttribute::VertexAttribute(const std::variant<HlslVertexBinding, GlslVertexBinding>& inPlatformBinding, VertexFormat inFormat, size_t inOffset)
VertexAttribute::VertexAttribute(const PlatformVertexBinding& inPlatformBinding, VertexFormat inFormat, size_t inOffset)
: VertexAttributeBase<VertexAttribute>(inFormat, inOffset)
, platformBinding(inPlatformBinding)
{
}

VertexAttribute& VertexAttribute::SetPlatformBinding(std::variant<HlslVertexBinding, GlslVertexBinding> inPlatformBinding)
VertexAttribute& VertexAttribute::SetPlatformBinding(PlatformVertexBinding inPlatformBinding)
{
platformBinding = inPlatformBinding;
return *this;
Expand Down
Loading

0 comments on commit 085320c

Please sign in to comment.