// Copyright (c) Wojciech Figat. All rights reserved. #pragma once #if GRAPHICS_API_WEBGPU #include "Engine/Graphics/Shaders/GPUShaderProgram.h" #include "Engine/GraphicsDevice/Vulkan/Types.h" #include /// /// Shaders base class for Web GPU backend. /// template class GPUShaderProgramWebGPU : public BaseType { public: GPUShaderProgramWebGPU(const GPUShaderProgramInitializer& initializer, const SpirvShaderDescriptorInfo& descriptorInfo, WGPUShaderModule shaderModule) : DescriptorInfo(descriptorInfo) , ShaderModule(shaderModule) { BaseType::Init(initializer); } ~GPUShaderProgramWebGPU() { wgpuShaderModuleRelease(ShaderModule); } public: SpirvShaderDescriptorInfo DescriptorInfo; WGPUShaderModule ShaderModule; public: // [BaseType] uint32 GetBufferSize() const override { return 0; } void* GetBufferHandle() const override { return ShaderModule; } }; /// /// Vertex Shader for Web GPU backend. /// class GPUShaderProgramVSWebGPU : public GPUShaderProgramWebGPU { public: GPUShaderProgramVSWebGPU(const GPUShaderProgramInitializer& initializer, GPUVertexLayout* inputLayout, GPUVertexLayout* vertexLayout, const SpirvShaderDescriptorInfo& descriptorInfo, WGPUShaderModule shaderModule) : GPUShaderProgramWebGPU(initializer, descriptorInfo, shaderModule) { InputLayout = inputLayout; Layout = vertexLayout; } }; /// /// Pixel Shader for Web GPU backend. /// class GPUShaderProgramPSWebGPU : public GPUShaderProgramWebGPU { public: GPUShaderProgramPSWebGPU(const GPUShaderProgramInitializer& initializer, const SpirvShaderDescriptorInfo& descriptorInfo, WGPUShaderModule shaderModule) : GPUShaderProgramWebGPU(initializer, descriptorInfo, shaderModule) { } }; #endif