Fixes and missing changes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// The raw SPIR-V byte code.
|
||||
/// </summary>
|
||||
Raw = 0,
|
||||
SPIRV = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The raw WGSL shader code.
|
||||
/// </summary>
|
||||
WGSL = 1,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -135,5 +138,3 @@ struct SpirvShaderHeader
|
||||
/// </summary>
|
||||
SpirvShaderDescriptorInfo DescriptorInfo;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<WGPURequestDeviceCallbackInfo, DeviceUserData> 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<DeviceUserData*>(userdata1);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
bool HasStencil = false;
|
||||
bool ReadOnly = false;
|
||||
uint32 DepthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
|
||||
WGPUTextureFormat Format = WGPUTextureFormat_Undefined;
|
||||
GPUResourceViewPtrWebGPU Ptr;
|
||||
|
||||
public:
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -47,7 +47,7 @@ enum class FileAccess : uint32
|
||||
/// </summary>
|
||||
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<byte, HeapAllocation>& data);
|
||||
static bool ReadAllBytes(const StringView& path, DataContainer<byte>& 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<byte, HeapAllocation>& data);
|
||||
static bool WriteAllText(const StringView& path, const String& data, Encoding encoding);
|
||||
static bool WriteAllText(const StringView& path, const StringBuilder& data, Encoding encoding);
|
||||
|
||||
Reference in New Issue
Block a user