-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add WebGPU pipeline and shader implementations
Additionally some small maintenance changes were done such as: - `psl::meta::library` to handle obvious error cases of missing files. - Logging initializer now no longer returns a bool as there's no false return to begin with. - Fixed an issue on windows when running clang-format on WSL - Reading a file in debug no longer causes an assert to be hit as an empty return is a valid return for the function.
- Loading branch information
Showing
25 changed files
with
631 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
#include "core/defines.hpp" | ||
#include "core/fwd/resource/resource.hpp" | ||
|
||
|
||
namespace core::iwgpu { | ||
class shader; | ||
} // namespace core::iwgpu | ||
|
||
namespace core::meta { | ||
class shader; | ||
} | ||
namespace core::resource { | ||
template <> | ||
struct resource_traits<core::iwgpu::shader> { | ||
using meta_type = core::meta::shader; | ||
}; | ||
} // namespace core::resource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
#pragma once | ||
#include "core/gfx/types.hpp" | ||
#include "iwgpu.hpp" | ||
|
||
namespace core::gfx::conversion { | ||
constexpr wgpu::ShaderStage to_wgpu(core::gfx::shader_stage stage) noexcept { | ||
switch(stage) { | ||
case core::gfx::shader_stage::vertex: | ||
return wgpu::ShaderStage::Vertex; | ||
case core::gfx::shader_stage::fragment: | ||
return wgpu::ShaderStage::Fragment; | ||
case core::gfx::shader_stage::compute: | ||
return wgpu::ShaderStage::Compute; | ||
default: | ||
return wgpu::ShaderStage::None; | ||
} | ||
} | ||
constexpr core::gfx::shader_stage to_gfx(wgpu::ShaderStage stage) noexcept { | ||
switch(stage) { | ||
case wgpu::ShaderStage::Vertex: | ||
return core::gfx::shader_stage::vertex; | ||
case wgpu::ShaderStage::Fragment: | ||
return core::gfx::shader_stage::fragment; | ||
case wgpu::ShaderStage::Compute: | ||
return core::gfx::shader_stage::compute; | ||
default: | ||
return core::gfx::shader_stage {0}; | ||
} | ||
} | ||
|
||
constexpr core::gfx::vertex_input_rate to_gfx(wgpu::VertexStepMode mode) noexcept { | ||
switch(mode) { | ||
case wgpu::VertexStepMode::Vertex: | ||
return core::gfx::vertex_input_rate::vertex; | ||
case wgpu::VertexStepMode::Instance: | ||
return core::gfx::vertex_input_rate::instance; | ||
default: | ||
return core::gfx::vertex_input_rate {0}; | ||
} | ||
} | ||
|
||
constexpr wgpu::VertexStepMode to_wgpu(core::gfx::vertex_input_rate rate) noexcept { | ||
switch(rate) { | ||
case core::gfx::vertex_input_rate::vertex: | ||
return wgpu::VertexStepMode::Vertex; | ||
case core::gfx::vertex_input_rate::instance: | ||
return wgpu::VertexStepMode::Instance; | ||
default: | ||
return wgpu::VertexStepMode::Vertex; | ||
} | ||
} | ||
|
||
constexpr core::gfx::format_t to_gfx(wgpu::VertexFormat format) noexcept { | ||
switch(format) { | ||
case wgpu::VertexFormat::Float32: | ||
return core::gfx::format_t::r32_sfloat; | ||
case wgpu::VertexFormat::Float32x2: | ||
return core::gfx::format_t::r32g32_sfloat; | ||
case wgpu::VertexFormat::Float32x3: | ||
return core::gfx::format_t::r32g32b32_sfloat; | ||
case wgpu::VertexFormat::Float32x4: | ||
return core::gfx::format_t::r32g32b32a32_sfloat; | ||
case wgpu::VertexFormat::Uint32: | ||
return core::gfx::format_t::r32_uint; | ||
case wgpu::VertexFormat::Uint32x2: | ||
return core::gfx::format_t::r32g32_uint; | ||
case wgpu::VertexFormat::Uint32x3: | ||
return core::gfx::format_t::r32g32b32_uint; | ||
case wgpu::VertexFormat::Uint32x4: | ||
return core::gfx::format_t::r32g32b32a32_uint; | ||
case wgpu::VertexFormat::Sint32: | ||
return core::gfx::format_t::r32_sint; | ||
case wgpu::VertexFormat::Sint32x2: | ||
return core::gfx::format_t::r32g32_sint; | ||
case wgpu::VertexFormat::Sint32x3: | ||
return core::gfx::format_t::r32g32b32_sint; | ||
case wgpu::VertexFormat::Sint32x4: | ||
return core::gfx::format_t::r32g32b32a32_sint; | ||
case wgpu::VertexFormat::Sint16x2: | ||
return core::gfx::format_t::r16g16_sint; | ||
case wgpu::VertexFormat::Sint16x4: | ||
return core::gfx::format_t::r16g16b16a16_sint; | ||
case wgpu::VertexFormat::Sint8x2: | ||
return core::gfx::format_t::r8g8_sint; | ||
case wgpu::VertexFormat::Sint8x4: | ||
return core::gfx::format_t::r8g8b8a8_sint; | ||
case wgpu::VertexFormat::Uint16x2: | ||
return core::gfx::format_t::r16g16_uint; | ||
case wgpu::VertexFormat::Uint16x4: | ||
return core::gfx::format_t::r16g16b16a16_uint; | ||
case wgpu::VertexFormat::Uint8x2: | ||
return core::gfx::format_t::r8g8_uint; | ||
case wgpu::VertexFormat::Uint8x4: | ||
return core::gfx::format_t::r8g8b8a8_uint; | ||
case wgpu::VertexFormat::Unorm8x2: | ||
return core::gfx::format_t::r8g8_unorm; | ||
case wgpu::VertexFormat::Unorm8x4: | ||
return core::gfx::format_t::r8g8b8a8_unorm; | ||
case wgpu::VertexFormat::Unorm10_10_10_2: | ||
return core::gfx::format_t::a2r10g10b10_unorm_pack32; | ||
case wgpu::VertexFormat::Snorm8x2: | ||
return core::gfx::format_t::r8g8_snorm; | ||
case wgpu::VertexFormat::Snorm8x4: | ||
return core::gfx::format_t::r8g8b8a8_snorm; | ||
case wgpu::VertexFormat::Snorm16x2: | ||
return core::gfx::format_t::r16g16_snorm; | ||
case wgpu::VertexFormat::Snorm16x4: | ||
return core::gfx::format_t::r16g16b16a16_snorm; | ||
case wgpu::VertexFormat::Unorm16x2: | ||
return core::gfx::format_t::r16g16_unorm; | ||
case wgpu::VertexFormat::Unorm16x4: | ||
return core::gfx::format_t::r16g16b16a16_unorm; | ||
default: | ||
return core::gfx::format_t::undefined; | ||
} | ||
} | ||
|
||
constexpr wgpu::VertexFormat to_wgpu(core::gfx::format_t format) noexcept { | ||
switch(format) { | ||
case core::gfx::format_t::r32_sfloat: | ||
return wgpu::VertexFormat::Float32; | ||
case core::gfx::format_t::r32g32_sfloat: | ||
return wgpu::VertexFormat::Float32x2; | ||
case core::gfx::format_t::r32g32b32_sfloat: | ||
return wgpu::VertexFormat::Float32x3; | ||
case core::gfx::format_t::r32g32b32a32_sfloat: | ||
return wgpu::VertexFormat::Float32x4; | ||
case core::gfx::format_t::r32_uint: | ||
return wgpu::VertexFormat::Uint32; | ||
case core::gfx::format_t::r32g32_uint: | ||
return wgpu::VertexFormat::Uint32x2; | ||
case core::gfx::format_t::r32g32b32_uint: | ||
return wgpu::VertexFormat::Uint32x3; | ||
case core::gfx::format_t::r32g32b32a32_uint: | ||
return wgpu::VertexFormat::Uint32x4; | ||
case core::gfx::format_t::r32_sint: | ||
return wgpu::VertexFormat::Sint32; | ||
case core::gfx::format_t::r32g32_sint: | ||
return wgpu::VertexFormat::Sint32x2; | ||
case core::gfx::format_t::r32g32b32_sint: | ||
return wgpu::VertexFormat::Sint32x3; | ||
case core::gfx::format_t::r32g32b32a32_sint: | ||
return wgpu::VertexFormat::Sint32x4; | ||
case core::gfx::format_t::r16g16_sint: | ||
return wgpu::VertexFormat::Sint16x2; | ||
case core::gfx::format_t::r16g16b16a16_sint: | ||
return wgpu::VertexFormat::Sint16x4; | ||
case core::gfx::format_t::r8g8_sint: | ||
return wgpu::VertexFormat::Sint8x2; | ||
case core::gfx::format_t::r8g8b8a8_sint: | ||
return wgpu::VertexFormat::Sint8x4; | ||
case core::gfx::format_t::r16g16_uint: | ||
return wgpu::VertexFormat::Uint16x2; | ||
case core::gfx::format_t::r16g16b16a16_uint: | ||
return wgpu::VertexFormat::Uint16x4; | ||
case core::gfx::format_t::r8g8_uint: | ||
return wgpu::VertexFormat::Uint8x2; | ||
case core::gfx::format_t::r8g8b8a8_uint: | ||
return wgpu::VertexFormat::Uint8x4; | ||
case core::gfx::format_t::r8g8_unorm: | ||
return wgpu::VertexFormat::Unorm8x2; | ||
case core::gfx::format_t::r8g8b8a8_unorm: | ||
return wgpu::VertexFormat::Unorm8x4; | ||
case core::gfx::format_t::a2r10g10b10_unorm_pack32: | ||
return wgpu::VertexFormat::Unorm10_10_10_2; | ||
case core::gfx::format_t::r8g8_snorm: | ||
return wgpu::VertexFormat::Snorm8x2; | ||
case core::gfx::format_t::r8g8b8a8_snorm: | ||
return wgpu::VertexFormat::Snorm8x4; | ||
case core::gfx::format_t::r16g16_snorm: | ||
return wgpu::VertexFormat::Snorm16x2; | ||
case core::gfx::format_t::r16g16b16a16_snorm: | ||
return wgpu::VertexFormat::Snorm16x4; | ||
case core::gfx::format_t::r16g16_unorm: | ||
return wgpu::VertexFormat::Unorm16x2; | ||
case core::gfx::format_t::r16g16b16a16_unorm: | ||
return wgpu::VertexFormat::Unorm16x4; | ||
default: | ||
return wgpu::VertexFormat::Undefined; | ||
} | ||
} | ||
} // namespace core::gfx::conversion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
#include "core/fwd/resource/resource.hpp" | ||
#include "core/wgpu/iwgpu.hpp" | ||
|
||
namespace core::data { | ||
class material_t; | ||
} // namespace core::data | ||
|
||
namespace core::iwgpu { | ||
class context; | ||
class pipeline { | ||
public: | ||
pipeline(core::resource::cache_t& cache, | ||
const core::resource::metadata& metaData, | ||
psl::meta::file* metaFile, | ||
core::resource::handle<core::iwgpu::context> context, | ||
core::resource::handle<core::data::material_t> data); | ||
~pipeline(); | ||
|
||
private: | ||
core::resource::cache_t& m_Cache; | ||
core::resource::handle<core::iwgpu::context> m_Context; | ||
psl::meta::file* m_Meta; | ||
const psl::UID m_UID; | ||
}; | ||
} // namespace core::iwgpu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
#include "core/resource/handle.hpp" | ||
#include "core/resource/resource.hpp" | ||
#include "core/wgpu/iwgpu.hpp" | ||
|
||
|
||
namespace core::data { | ||
class material_t; | ||
} | ||
|
||
namespace core::iwgpu { | ||
class context; | ||
class pipeline; | ||
class pipeline_cache { | ||
public: | ||
pipeline_cache(core::resource::cache_t& cache, | ||
const core::resource::metadata& metaData, | ||
psl::meta::file* metaFile, | ||
core::resource::handle<core::iwgpu::context> context); | ||
|
||
~pipeline_cache(); | ||
|
||
core::resource::handle<pipeline> get(core::resource::handle<core::data::material_t> data); | ||
|
||
private: | ||
core::resource::handle<core::iwgpu::context> m_Context; | ||
}; | ||
} // namespace core::iwgpu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include "core/fwd/wgpu/shader.hpp" | ||
#include "core/resource/resource.hpp" | ||
#include "core/wgpu/iwgpu.hpp" | ||
|
||
namespace core::iwgpu { | ||
class context; | ||
|
||
class shader { | ||
public: | ||
shader(core::resource::cache_t& cache, | ||
const core::resource::metadata& metaData, | ||
core::meta::shader* metaFile, | ||
core::resource::handle<core::iwgpu::context> context); | ||
~shader(); | ||
shader(const shader&) = delete; | ||
shader(shader&&) = delete; | ||
shader& operator=(const shader&) = delete; | ||
shader& operator=(shader&&) = delete; | ||
|
||
core::meta::shader* meta() const noexcept; | ||
|
||
wgpu::ShaderModule module() const noexcept { return m_Shader; } | ||
|
||
private: | ||
core::resource::handle<core::iwgpu::context> m_Context; | ||
core::resource::cache_t& m_Cache; | ||
core::meta::shader* m_Meta; | ||
wgpu::ShaderModule m_Shader; | ||
const psl::UID m_UID; | ||
}; | ||
} // namespace core::iwgpu |
Oops, something went wrong.