AronaCore/core/rhi/slang_handle.h

30 lines
1.1 KiB
C++

#pragma once
#include <map>
#include "slang-com-ptr.h"
#include <string>
class slang_handle
{
public:
Slang::ComPtr<slang::IModule> module;
Slang::ComPtr<slang::IComponentType> program;
Slang::ComPtr<slang::IEntryPoint> entry_point;
static constexpr int target_index = 0; // only one target
bool init_slang_module(const std::string& module_name, const std::string& entry_name);
[[nodiscard]] Slang::ComPtr<slang::IBlob> get_entry_point_code() const;
[[nodiscard]] const char* get_entry_point_name() const
{
slang::ProgramLayout* layout = program->getLayout(0);
const auto entry_reflection = layout->getEntryPointByIndex(entry_point_index_);
return entry_reflection->getName();
}
[[nodiscard]] SlangStage get_shader_type() const { return shader_type_; }
[[nodiscard]] std::map<std::string, slang::BindingType> get_binding_types() const;
[[nodiscard]] unsigned int get_bind_index(const char* param_name) const;
private:
int entry_point_index_ = -1;
SlangStage shader_type_ = SLANG_STAGE_NONE;
};