78 lines
1.8 KiB
C++
78 lines
1.8 KiB
C++
// Copyright (c) 2024 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#pragma once
|
|
#include "dawn.hpp"
|
|
#include "slang.h"
|
|
#include "slang-com-ptr.h"
|
|
|
|
using namespace slang;
|
|
using namespace Slang;
|
|
|
|
namespace Dawn {
|
|
class ShaderData;
|
|
|
|
enum class ShaderStructureType {
|
|
STRUCT,
|
|
ARRAY,
|
|
VARIABLE,
|
|
RESOURCE
|
|
};
|
|
|
|
struct ShaderStructure :
|
|
public std::enable_shared_from_this<ShaderStructure>
|
|
{
|
|
public:
|
|
std::string name;
|
|
ShaderStructureType type;
|
|
|
|
// Shared properties
|
|
size_t start;
|
|
size_t alignment;
|
|
size_t size;
|
|
|
|
// Struct properties
|
|
std::vector<std::shared_ptr<struct ShaderStructure>> members;
|
|
|
|
// Array properties
|
|
size_t length;
|
|
|
|
/**
|
|
* Constructs the ShaderStructure object
|
|
*
|
|
* @param reflection Reflection data to construct the structure from.
|
|
* @param start Offset to start at.
|
|
*/
|
|
ShaderStructure(
|
|
TypeLayoutReflection *typeLayout,
|
|
const std::string name,
|
|
const size_t start
|
|
);
|
|
|
|
/**
|
|
* Gets a member of this structure by name.
|
|
*
|
|
* @param name Name of the member to get.
|
|
* @return The member structure.
|
|
*/
|
|
std::shared_ptr<ShaderStructure> getStructMember(const std::string &name);
|
|
|
|
/**
|
|
* Gets a member of this array structure by index.
|
|
*
|
|
* @param index Index of the member to get.
|
|
* @return The member structure.
|
|
*/
|
|
std::shared_ptr<ShaderStructure> getArrayMember(size_t index);
|
|
|
|
/**
|
|
* Creates data for a shader that matches this structure.
|
|
*
|
|
* @param name Name of the member to get.
|
|
* @return The member structure.
|
|
*/
|
|
std::shared_ptr<ShaderData> createData();
|
|
};
|
|
} |