diff --git a/Source/Engine/Graphics/Textures/GPUSampler.cpp b/Source/Engine/Graphics/Textures/GPUSampler.cpp
index a57098c09..1d1f21b6d 100644
--- a/Source/Engine/Graphics/Textures/GPUSampler.cpp
+++ b/Source/Engine/Graphics/Textures/GPUSampler.cpp
@@ -19,7 +19,7 @@ void GPUSamplerDescription::Clear()
{
Platform::MemoryClear(this, sizeof(GPUSamplerDescription));
MaxMipLevel = MAX_float;
- MaxAnisotropy = 1.0f;
+ MaxAnisotropy = 1;
}
bool GPUSamplerDescription::Equals(const GPUSamplerDescription& other) const
diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUShaderVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUShaderVulkan.cpp
index 853fcf693..ab9a9288e 100644
--- a/Source/Engine/GraphicsDevice/Vulkan/GPUShaderVulkan.cpp
+++ b/Source/Engine/GraphicsDevice/Vulkan/GPUShaderVulkan.cpp
@@ -11,7 +11,6 @@
#include "Engine/Core/Log.h"
#include "Engine/Core/Types/DataContainer.h"
#include "Engine/Serialization/MemoryReadStream.h"
-#include "Engine/Graphics/PixelFormatExtensions.h"
#include "Engine/Profiler/ProfilerMemory.h"
#if PLATFORM_DESKTOP
@@ -109,7 +108,7 @@ GPUShaderProgram* GPUShaderVulkan::CreateGPUShaderProgram(ShaderStage type, cons
// Extract the SPIR-V bytecode
BytesContainer spirv;
- ASSERT(header->Type == SpirvShaderHeader::Types::Raw);
+ ASSERT(header->Type == SpirvShaderHeader::Types::SPIRV);
spirv.Link(bytecode);
// Create shader module from SPIR-V bytecode
diff --git a/Source/Engine/GraphicsDevice/Vulkan/Types.h b/Source/Engine/GraphicsDevice/Vulkan/Types.h
index 6a6384840..1bb45fae5 100644
--- a/Source/Engine/GraphicsDevice/Vulkan/Types.h
+++ b/Source/Engine/GraphicsDevice/Vulkan/Types.h
@@ -2,8 +2,6 @@
#pragma once
-#if COMPILE_WITH_VK_SHADER_COMPILER || GRAPHICS_API_VULKAN
-
#include "Engine/Graphics/PixelFormat.h"
#if GRAPHICS_API_VULKAN
@@ -122,7 +120,12 @@ struct SpirvShaderHeader
///
/// The raw SPIR-V byte code.
///
- Raw = 0,
+ SPIRV = 0,
+
+ ///
+ /// The raw WGSL shader code.
+ ///
+ WGSL = 1,
};
///
@@ -135,5 +138,3 @@ struct SpirvShaderHeader
///
SpirvShaderDescriptorInfo DescriptorInfo;
};
-
-#endif
diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp b/Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp
index 7d3971051..48f5c0fc6 100644
--- a/Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp
+++ b/Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp
@@ -440,6 +440,14 @@ void GPUContextWebGPU::Flush()
return;
PROFILE_CPU();
+ // End existing pass (if any)
+ if (_renderPass)
+ {
+ wgpuRenderPassEncoderEnd(_renderPass);
+ wgpuRenderPassEncoderRelease(_renderPass);
+ }
+
+ // End commands recording
WGPUCommandBufferDescriptor commandBufferDesc = WGPU_COMMAND_BUFFER_DESCRIPTOR_INIT;
WGPUCommandBuffer commandBuffer = wgpuCommandEncoderFinish(Encoder, &commandBufferDesc);
wgpuCommandEncoderRelease(Encoder);
@@ -706,7 +714,7 @@ void GPUContextWebGPU::OnDrawCall()
colorAttachment.clearValue = { clear.RGBA[0], clear.RGBA[1], clear.RGBA[2], clear.RGBA[3] };
}
_pipelineKey.MultiSampleCount = (int32)renderTarget->GetMSAA();
- _pipelineKey.RenderTargetFormats[i] = RenderToolsWebGPU::ToTextureFormat(renderTarget->GetFormat());
+ _pipelineKey.RenderTargetFormats[i] = renderTarget->Format;
}
if (_depthStencil)
{
@@ -738,7 +746,7 @@ void GPUContextWebGPU::OnDrawCall()
depthStencilAttachment.stencilClearValue = clear.Stencil;
}
}
- _pipelineKey.DepthStencilFormat = RenderToolsWebGPU::ToTextureFormat(_depthStencil->GetFormat());
+ _pipelineKey.DepthStencilFormat = _depthStencil->Format;
}
else
{
@@ -752,9 +760,7 @@ void GPUContextWebGPU::OnDrawCall()
// Apply pending state
if (_stencilRef != 0)
- {
wgpuRenderPassEncoderSetStencilReference(_renderPass, _stencilRef);
- }
auto scissorRect = _scissorRect;
// TODO: skip calling this if scissorRect is default (0, 0, attachment width, attachment height)
wgpuRenderPassEncoderSetScissorRect(_renderPass, (uint32_t)scissorRect.GetX(), (uint32_t)scissorRect.GetY(), (uint32_t)scissorRect.GetWidth(), (uint32_t)scissorRect.GetHeight());
@@ -780,7 +786,7 @@ void GPUContextWebGPU::OnDrawCall()
wgpuRenderPassEncoderSetPipeline(_renderPass, pipeline);
RENDER_STAT_PS_STATE_CHANGE();
}
- if (_indexBufferDirty)
+ if (_indexBufferDirty && _indexBuffer.Buffer)
{
_indexBufferDirty = false;
wgpuRenderPassEncoderSetIndexBuffer(_renderPass, _indexBuffer.Buffer, _indexBuffer32Bit ? WGPUIndexFormat_Uint32 : WGPUIndexFormat_Uint16, _indexBuffer.Offset, _indexBuffer.Size);
diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUDeviceWebGPU.cpp b/Source/Engine/GraphicsDevice/WebGPU/GPUDeviceWebGPU.cpp
index 130c8d789..772335a66 100644
--- a/Source/Engine/GraphicsDevice/WebGPU/GPUDeviceWebGPU.cpp
+++ b/Source/Engine/GraphicsDevice/WebGPU/GPUDeviceWebGPU.cpp
@@ -39,7 +39,6 @@ GPUVertexLayoutWebGPU::GPUVertexLayoutWebGPU(GPUDeviceWebGPU* device, const Elem
dst.nextInChain = nullptr;
dst.format = RenderToolsWebGPU::ToVertexFormat(src.Format);
dst.offset = src.Offset;
- dst.shaderLocation = src.Slot;
if (src.PerInstance)
Layout.stepMode = WGPUVertexStepMode_Instance;
}
@@ -360,10 +359,8 @@ bool GPUDeviceWebGPU::Init()
WGPUDevice Device = nullptr;
};
AsyncCallbackWebGPU deviceRequest(WGPU_REQUEST_DEVICE_CALLBACK_INFO_INIT);
-#if GPU_ENABLE_RESOURCE_NAMING
deviceDesc.label = WEBGPU_STR("Flax Device");
deviceDesc.defaultQueue.label = WEBGPU_STR("Flax Queue");
-#endif
deviceRequest.Info.callback = [](WGPURequestDeviceStatus status, WGPUDevice device, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2)
{
DeviceUserData& userData = *reinterpret_cast(userdata1);
diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUSwapChainWebGPU.cpp b/Source/Engine/GraphicsDevice/WebGPU/GPUSwapChainWebGPU.cpp
index b99bdd8e6..bc2aefbdb 100644
--- a/Source/Engine/GraphicsDevice/WebGPU/GPUSwapChainWebGPU.cpp
+++ b/Source/Engine/GraphicsDevice/WebGPU/GPUSwapChainWebGPU.cpp
@@ -87,9 +87,11 @@ void GPUSwapChainWebGPU::Present(bool vsync)
// Release the texture
auto surfaceTexture = _surfaceView.Texture;
- ASSERT(surfaceTexture);
- _surfaceView.Release();
- wgpuTextureRelease(surfaceTexture);
+ if (surfaceTexture)
+ {
+ _surfaceView.Release();
+ wgpuTextureRelease(surfaceTexture);
+ }
// Base
GPUSwapChain::Present(vsync);
diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUTextureWebGPU.cpp b/Source/Engine/GraphicsDevice/WebGPU/GPUTextureWebGPU.cpp
index 695c72d31..97eaba742 100644
--- a/Source/Engine/GraphicsDevice/WebGPU/GPUTextureWebGPU.cpp
+++ b/Source/Engine/GraphicsDevice/WebGPU/GPUTextureWebGPU.cpp
@@ -19,6 +19,7 @@ void GPUTextureViewWebGPU::Create(WGPUTexture texture, WGPUTextureViewDescriptor
LOG(Error, "Failed to create a view for texture '{}'", GetParent() ? GetParent()->GetName() : StringView::Empty);
#endif
}
+ Format = desc ? desc->format : wgpuTextureGetFormat(texture);
}
void GPUTextureViewWebGPU::Release()
@@ -178,18 +179,22 @@ void GPUTextureWebGPU::InitHandles()
// Init per slice views
_handlesPerSlice.Resize(Depth(), false);
- viewDesc.dimension = WGPUTextureViewDimension_2D;
+ //viewDesc.dimension = WGPUTextureViewDimension_2DArray;
if (_desc.HasPerSliceViews() && IsRenderTarget())
{
for (int32 sliceIndex = 0; sliceIndex < Depth(); sliceIndex++)
{
+ //viewDesc.baseArrayLayer = sliceIndex;
+ //viewDesc.arrayLayerCount = 1;
auto& view = _handlesPerSlice[sliceIndex];
view.Init(this, format, msaa);
view.Create(Texture, &viewDesc);
view.DepthSlice = sliceIndex;
}
}
- viewDesc.dimension = _viewDimension;
+ //viewDesc.baseArrayLayer = 0;
+ //viewDesc.arrayLayerCount = MipLevels();
+ //viewDesc.dimension = _viewDimension;
}
else if (IsArray())
{
diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUTextureWebGPU.h b/Source/Engine/GraphicsDevice/WebGPU/GPUTextureWebGPU.h
index 0492f868d..732aa113c 100644
--- a/Source/Engine/GraphicsDevice/WebGPU/GPUTextureWebGPU.h
+++ b/Source/Engine/GraphicsDevice/WebGPU/GPUTextureWebGPU.h
@@ -34,6 +34,7 @@ public:
bool HasStencil = false;
bool ReadOnly = false;
uint32 DepthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
+ WGPUTextureFormat Format = WGPUTextureFormat_Undefined;
GPUResourceViewPtrWebGPU Ptr;
public:
diff --git a/Source/Engine/Platform/Base/FileBase.cpp b/Source/Engine/Platform/Base/FileBase.cpp
index 74ffcb0c8..7f8042891 100644
--- a/Source/Engine/Platform/Base/FileBase.cpp
+++ b/Source/Engine/Platform/Base/FileBase.cpp
@@ -8,7 +8,7 @@
#include "Engine/Core/Log.h"
#include "Engine/Profiler/ProfilerCPU.h"
-bool FileBase::ReadAllBytes(const StringView& path, byte* data, int32 length)
+bool FileBase::ReadAllBytes(const StringView& path, void* data, int32 length)
{
PROFILE_CPU_NAMED("File::ReadAllBytes");
ZoneText(*path, path.Length());
@@ -232,7 +232,7 @@ bool FileBase::ReadAllText(const StringView& path, StringAnsi& data)
return false;
}
-bool FileBase::WriteAllBytes(const StringView& path, const byte* data, int32 length)
+bool FileBase::WriteAllBytes(const StringView& path, const void* data, int32 length)
{
PROFILE_CPU_NAMED("File::WriteAllBytes");
ZoneText(*path, path.Length());
diff --git a/Source/Engine/Platform/Base/FileBase.h b/Source/Engine/Platform/Base/FileBase.h
index 879c1076b..11f4e1299 100644
--- a/Source/Engine/Platform/Base/FileBase.h
+++ b/Source/Engine/Platform/Base/FileBase.h
@@ -47,7 +47,7 @@ enum class FileAccess : uint32
///
enum class FileShare : uint32
{
- // Prevents any operations on the file file it's opened.
+ // Prevents any operations on the file it's opened.
None = 0x00000000,
// Allows read operations on a file.
Read = 0x00000001,
@@ -130,12 +130,12 @@ public:
virtual bool IsOpened() const = 0;
public:
- static bool ReadAllBytes(const StringView& path, byte* data, int32 length);
+ static bool ReadAllBytes(const StringView& path, void* data, int32 length);
static bool ReadAllBytes(const StringView& path, Array& data);
static bool ReadAllBytes(const StringView& path, DataContainer& data);
static bool ReadAllText(const StringView& path, String& data);
static bool ReadAllText(const StringView& path, StringAnsi& data);
- static bool WriteAllBytes(const StringView& path, const byte* data, int32 length);
+ static bool WriteAllBytes(const StringView& path, const void* data, int32 length);
static bool WriteAllBytes(const StringView& path, const Array& data);
static bool WriteAllText(const StringView& path, const String& data, Encoding encoding);
static bool WriteAllText(const StringView& path, const StringBuilder& data, Encoding encoding);