Removed WebGPU. (#3198)

This commit is contained in:
Бранимир Караџић 2023-11-09 17:15:22 -08:00 committed by GitHub
parent 67107e5511
commit 49c0e49527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 7 additions and 10733 deletions

View File

@ -1,144 +0,0 @@
// Copyright 2017 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef DAWN_ENUM_CLASS_BITMASKS_H_
#define DAWN_ENUM_CLASS_BITMASKS_H_
#include <type_traits>
namespace wgpu {
template <typename T>
struct IsDawnBitmask {
static constexpr bool enable = false;
};
template <typename T, typename Enable = void>
struct LowerBitmask {
static constexpr bool enable = false;
};
template <typename T>
struct LowerBitmask<T, typename std::enable_if<IsDawnBitmask<T>::enable>::type> {
static constexpr bool enable = true;
using type = T;
constexpr static T Lower(T t) {
return t;
}
};
template <typename T>
struct BoolConvertible {
using Integral = typename std::underlying_type<T>::type;
constexpr BoolConvertible(Integral value) : value(value) {
}
constexpr operator bool() const {
return value != 0;
}
constexpr operator T() const {
return static_cast<T>(value);
}
Integral value;
};
template <typename T>
struct LowerBitmask<BoolConvertible<T>> {
static constexpr bool enable = true;
using type = T;
static constexpr type Lower(BoolConvertible<T> t) {
return t;
}
};
template <typename T1,
typename T2,
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename std::underlying_type<T>::type;
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
}
template <typename T1,
typename T2,
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename std::underlying_type<T>::type;
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
}
template <typename T1,
typename T2,
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename std::underlying_type<T>::type;
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
}
template <typename T1>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename std::underlying_type<T>::type;
return ~static_cast<Integral>(LowerBitmask<T1>::Lower(t));
}
template <typename T,
typename T2,
typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr T& operator&=(T& l, T2 right) {
T r = LowerBitmask<T2>::Lower(right);
l = l & r;
return l;
}
template <typename T,
typename T2,
typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr T& operator|=(T& l, T2 right) {
T r = LowerBitmask<T2>::Lower(right);
l = l | r;
return l;
}
template <typename T,
typename T2,
typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr T& operator^=(T& l, T2 right) {
T r = LowerBitmask<T2>::Lower(right);
l = l ^ r;
return l;
}
template <typename T>
constexpr bool HasZeroOrOneBits(T value) {
using Integral = typename std::underlying_type<T>::type;
return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
}
} // namespace wgpu
#endif // DAWN_ENUM_CLASS_BITMASKS_H_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,3 @@ src/renderer_mtl.* @attilaz
# Vulkan
src/renderer_vk.* @rinthel @pezcode
# WebGPU
src/renderer_webgpu.* @hugoam

View File

@ -43,7 +43,6 @@ Supported rendering backends:
* Vulkan
* WebGL 1.0
* WebGL 2.0
* WebGPU/Dawn (experimental)
Supported platforms:

View File

@ -1414,11 +1414,6 @@ public static class bgfx
/// </summary>
Vulkan,
/// <summary>
/// WebGPU
/// </summary>
WebGPU,
Count
}

View File

@ -1411,11 +1411,6 @@ public static partial class bgfx
/// </summary>
Vulkan,
/// <summary>
/// WebGPU
/// </summary>
WebGPU,
Count
}

View File

@ -14,7 +14,7 @@ extern(C++, "bgfx") package final abstract class Fatal{
}
extern(C++, "bgfx") package final abstract class RendererType{
enum Enum{
noop,agc,direct3D11,direct3D12,gnm,metal,nvn,openGLES,openGL,vulkan,webGPU,count
noop,agc,direct3D11,direct3D12,gnm,metal,nvn,openGLES,openGL,vulkan,count
}
}
extern(C++, "bgfx") package final abstract class Access{

View File

@ -10,7 +10,7 @@ import bindbc.bgfx.config;
import bindbc.common.types: va_list;
static import bgfx.fakeenum;
enum uint apiVersion = 123;
enum uint apiVersion = 124;
alias ViewID = ushort;
deprecated("Please use `ViewID` instead.") alias ViewId = ushort;
@ -600,7 +600,6 @@ enum RendererType: bgfx.fakeenum.RendererType.Enum{
openGLES = bgfx.fakeenum.RendererType.Enum.openGLES,
openGL = bgfx.fakeenum.RendererType.Enum.openGL,
vulkan = bgfx.fakeenum.RendererType.Enum.vulkan,
webGPU = bgfx.fakeenum.RendererType.Enum.webGPU,
count = bgfx.fakeenum.RendererType.Enum.count,
}

View File

@ -864,9 +864,6 @@ pub const RendererType = enum(c_int) {
/// Vulkan
Vulkan,
/// WebGPU
WebGPU,
Count
};

View File

@ -28,7 +28,6 @@ Supported rendering backends
- Vulkan
- WebGL 1.0
- WebGL 2.0
- WebGPU/Dawn (experimental)
Supported Platforms
~~~~~~~~~~~~~~~~~~~

View File

@ -114,7 +114,6 @@ static bgfx::ShaderHandle loadShader(bx::FileReaderI* _reader, const char* _name
case bgfx::RendererType::OpenGL: shaderPath = "shaders/glsl/"; break;
case bgfx::RendererType::OpenGLES: shaderPath = "shaders/essl/"; break;
case bgfx::RendererType::Vulkan: shaderPath = "shaders/spirv/"; break;
case bgfx::RendererType::WebGPU: shaderPath = "shaders/spirv/"; break;
case bgfx::RendererType::Count:
BX_ASSERT(false, "You should not be here!");

View File

@ -61,7 +61,6 @@ namespace bgfx
OpenGLES, //!< OpenGL ES 2.0+
OpenGL, //!< OpenGL 2.1+
Vulkan, //!< Vulkan
WebGPU, //!< WebGPU
Count
};

View File

@ -90,7 +90,6 @@ typedef enum bgfx_renderer_type
BGFX_RENDERER_TYPE_OPENGLES, /** ( 7) OpenGL ES 2.0+ */
BGFX_RENDERER_TYPE_OPENGL, /** ( 8) OpenGL 2.1+ */
BGFX_RENDERER_TYPE_VULKAN, /** ( 9) Vulkan */
BGFX_RENDERER_TYPE_WEBGPU, /** (10) WebGPU */
BGFX_RENDERER_TYPE_COUNT

View File

@ -15,7 +15,7 @@
#ifndef BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_API_VERSION UINT32_C(123)
#define BGFX_API_VERSION UINT32_C(124)
/**
* Color RGB/alpha/depth write. When it's not specified write will be disabled.

View File

@ -105,7 +105,6 @@
BGFX_EMBEDDED_SHADER_ESSL (bgfx::RendererType::OpenGLES, _name) \
BGFX_EMBEDDED_SHADER_GLSL (bgfx::RendererType::OpenGL, _name) \
BGFX_EMBEDDED_SHADER_SPIRV(bgfx::RendererType::Vulkan, _name) \
BGFX_EMBEDDED_SHADER_SPIRV(bgfx::RendererType::WebGPU, _name) \
{ bgfx::RendererType::Noop, (const uint8_t*)"VSH\x5\x0\x0\x0\x0\x0\x0", 10 }, \
{ bgfx::RendererType::Count, NULL, 0 } \
} \

View File

@ -1,7 +1,7 @@
-- vim: syntax=lua
-- bgfx interface
version(123)
version(124)
typedef "bool"
typedef "char"
@ -466,7 +466,6 @@ enum.RendererType { comment = "Renderer types:" }
.OpenGLES --- OpenGL ES 2.0+
.OpenGL --- OpenGL 2.1+
.Vulkan --- Vulkan
.WebGPU --- WebGPU
()
--- Access mode enum.

View File

@ -185,44 +185,6 @@ function bgfxProjectBase(_kind, _defines)
path.join(BGFX_DIR, "src/renderer_nvn.h"),
})
if _OPTIONS["with-webgpu"] then
defines {
"BGFX_CONFIG_RENDERER_WEBGPU=1",
"BGFX_CONFIG_DEBUG_ANNOTATION=0", -- does not work
}
local generator = "out/Cmake"
configuration { "wasm*" }
defines {
"BGFX_CONFIG_RENDERER_OPENGL=0",
"BGFX_CONFIG_RENDERER_OPENGLES=0",
}
configuration { "not wasm*" }
includedirs {
path.join(DAWN_DIR, "src/include"),
path.join(DAWN_DIR, "third_party/vulkan-deps/vulkan-headers/src/include"),
path.join(DAWN_DIR, generator, "gen/src/include"),
}
files {
path.join(DAWN_DIR, generator, "gen/src/dawn/webgpu_cpp.cpp"),
}
configuration { "vs*" }
defines {
"NTDDI_VERSION=NTDDI_WIN10_RS2",
-- We can't say `=_WIN32_WINNT_WIN10` here because some files do
-- `#if WINVER < 0x0600` without including windows.h before,
-- and then _WIN32_WINNT_WIN10 isn't yet known to be 0x0A00.
"_WIN32_WINNT=0x0A00",
"WINVER=0x0A00",
}
configuration {}
end
if _OPTIONS["with-amalgamated"] then
excludes {
path.join(BGFX_DIR, "src/bgfx.cpp"),
@ -292,59 +254,3 @@ function bgfxProject(_name, _kind, _defines)
copyLib()
end
if _OPTIONS["with-webgpu"] then
function usesWebGPU()
configuration { "wasm*" }
linkoptions {
"-s USE_WEBGPU=1",
}
configuration { "not wasm*" }
local generator = "out/Cmake"
includedirs {
path.join(DAWN_DIR, "src/include"),
path.join(DAWN_DIR, generator, "gen/src/include"),
}
libdirs {
path.join(DAWN_DIR, generator),
path.join(DAWN_DIR, generator, "src/common/Debug"),
path.join(DAWN_DIR, generator, "src/dawn/Debug"),
path.join(DAWN_DIR, generator, "src/dawn_native/Debug"),
path.join(DAWN_DIR, generator, "src/dawn_platform/Debug"),
path.join(DAWN_DIR, generator, "third_party/tint/src/Debug"),
path.join(DAWN_DIR, generator, "third_party/vulkan-deps/spirv-tools/src/source/Debug"),
path.join(DAWN_DIR, generator, "third_party/vulkan-deps/spirv-tools/src/source/opt/Debug"),
path.join(DAWN_DIR, generator, "third_party/vulkan-deps/spirv-cross/src/Debug"),
}
links {
-- shared
--"dawn_proc_shared",
--"dawn_native_shared",
--"shaderc_spvc_shared",
-- static
"dawn_common",
"dawn_proc",
"dawn_native",
"dawn_platform",
----"shaderc",
"tint",
"SPIRV-Tools",
"SPIRV-Tools-opt",
"spirv-cross-cored",
"spirv-cross-hlsld",
"spirv-cross-glsld",
"spirv-cross-msld",
--"spirv-cross-reflectd",
}
removeflags {
"FatalWarnings",
}
configuration {}
end
end

View File

@ -50,11 +50,6 @@ newoption {
description = "Enable building examples.",
}
newoption {
trigger = "with-webgpu",
description = "Enable webgpu experimental renderer.",
}
newaction {
trigger = "idl",
description = "Generate bgfx interface source code",
@ -179,23 +174,6 @@ if not os.isdir(BX_DIR) or not os.isdir(BIMG_DIR) then
os.exit()
end
if _OPTIONS["with-webgpu"] then
DAWN_DIR = os.getenv("DAWN_DIR")
if not DAWN_DIR then
DAWN_DIR = path.getabsolute(path.join(BGFX_DIR, "../dawn"))
end
if not os.isdir(DAWN_DIR) and "wasm*" ~= _OPTIONS["gcc"] then
print("Dawn not found at \"" .. DAWN_DIR .. "\". git clone https://dawn.googlesource.com/dawn?")
print("For more info see: https://bkaradzic.github.io/bgfx/build.html")
os.exit()
end
_OPTIONS["with-windows"] = "10.0"
end
dofile (path.join(BX_DIR, "scripts/toolchain.lua"))
if not toolchain(BGFX_BUILD_DIR, BGFX_THIRD_PARTY_DIR) then
return -- no action specified
@ -248,10 +226,6 @@ function exampleProjectDefaults()
using_bx()
if _OPTIONS["with-webgpu"] then
usesWebGPU()
end
if _OPTIONS["with-sdl"] then
defines { "ENTRY_CONFIG_USE_SDL=1" }
links { "SDL2" }

View File

@ -560,7 +560,6 @@ project "shaderc"
path.join(BIMG_DIR, "include"),
path.join(BGFX_DIR, "include"),
path.join(BGFX_DIR, "3rdparty/webgpu/include"),
path.join(BGFX_DIR, "3rdparty/dxsdk/include"),
FCPP_DIR,

View File

@ -18,7 +18,6 @@
#include "renderer_noop.cpp"
#include "renderer_nvn.cpp"
#include "renderer_vk.cpp"
#include "renderer_webgpu.cpp"
#include "shader.cpp"
#include "shader_dxbc.cpp"
#include "shader_spirv.cpp"

View File

@ -2623,7 +2623,6 @@ namespace bgfx
BGFX_RENDERER_CONTEXT(nvn);
BGFX_RENDERER_CONTEXT(gl);
BGFX_RENDERER_CONTEXT(vk);
BGFX_RENDERER_CONTEXT(webgpu);
#undef BGFX_RENDERER_CONTEXT
@ -2651,7 +2650,6 @@ namespace bgfx
{ gl::rendererCreate, gl::rendererDestroy, BGFX_RENDERER_OPENGL_NAME, !!BGFX_CONFIG_RENDERER_OPENGLES }, // OpenGLES
{ gl::rendererCreate, gl::rendererDestroy, BGFX_RENDERER_OPENGL_NAME, !!BGFX_CONFIG_RENDERER_OPENGL }, // OpenGL
{ vk::rendererCreate, vk::rendererDestroy, BGFX_RENDERER_VULKAN_NAME, !!BGFX_CONFIG_RENDERER_VULKAN }, // Vulkan
{ webgpu::rendererCreate, webgpu::rendererDestroy, BGFX_RENDERER_WEBGPU_NAME, !!BGFX_CONFIG_RENDERER_WEBGPU }, // WebGPU
};
BX_STATIC_ASSERT(BX_COUNTOF(s_rendererCreator) == RendererType::Count);

View File

@ -242,7 +242,6 @@ namespace stl = std;
#define BGFX_RENDERER_METAL_NAME "Metal"
#define BGFX_RENDERER_NVN_NAME "NVN"
#define BGFX_RENDERER_VULKAN_NAME "Vulkan"
#define BGFX_RENDERER_WEBGPU_NAME "WebGPU"
#if BGFX_CONFIG_RENDERER_OPENGL
# if BGFX_CONFIG_RENDERER_OPENGL >= 31 && BGFX_CONFIG_RENDERER_OPENGL <= 33

View File

@ -27,8 +27,7 @@
&& !defined(BGFX_CONFIG_RENDERER_NVN) \
&& !defined(BGFX_CONFIG_RENDERER_OPENGL) \
&& !defined(BGFX_CONFIG_RENDERER_OPENGLES) \
&& !defined(BGFX_CONFIG_RENDERER_VULKAN) \
&& !defined(BGFX_CONFIG_RENDERER_WEBGPU)
&& !defined(BGFX_CONFIG_RENDERER_VULKAN)
# ifndef BGFX_CONFIG_RENDERER_AGC
# define BGFX_CONFIG_RENDERER_AGC (0 \
@ -110,10 +109,6 @@
? 1 : 0)
# endif // BGFX_CONFIG_RENDERER_VULKAN
# ifndef BGFX_CONFIG_RENDERER_WEBGPU
# define BGFX_CONFIG_RENDERER_WEBGPU 0
# endif // BGFX_CONFIG_RENDERER_WEBGPU
#else
# ifndef BGFX_CONFIG_RENDERER_AGC
# define BGFX_CONFIG_RENDERER_AGC 0
@ -150,10 +145,6 @@
# ifndef BGFX_CONFIG_RENDERER_VULKAN
# define BGFX_CONFIG_RENDERER_VULKAN 0
# endif // BGFX_CONFIG_RENDERER_VULKAN
# ifndef BGFX_CONFIG_RENDERER_WEBGPU
# define BGFX_CONFIG_RENDERER_WEBGPU 0
# endif // BGFX_CONFIG_RENDERER_VULKAN
#endif // !defined...
#if BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 21

File diff suppressed because it is too large Load Diff

View File

@ -1,570 +0,0 @@
/*
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/
#ifndef BGFX_RENDERER_WEBGPU_H_HEADER_GUARD
#define BGFX_RENDERER_WEBGPU_H_HEADER_GUARD
#include "bgfx_p.h"
#if BGFX_CONFIG_RENDERER_WEBGPU
#if !BX_PLATFORM_EMSCRIPTEN
# include <dawn/webgpu_cpp.h>
# include <dawn/dawn_wsi.h>
#else
# include <webgpu/webgpu_cpp.h>
#endif // !BX_PLATFORM_EMSCRIPTEN
#define BGFX_WEBGPU_PROFILER_BEGIN(_view, _abgr) \
BX_MACRO_BLOCK_BEGIN \
BGFX_PROFILER_BEGIN(s_viewName[view], _abgr); \
BX_MACRO_BLOCK_END
#define BGFX_WEBGPU_PROFILER_BEGIN_LITERAL(_name, _abgr) \
BX_MACRO_BLOCK_BEGIN \
BGFX_PROFILER_BEGIN_LITERAL("" # _name, _abgr); \
BX_MACRO_BLOCK_END
#define BGFX_WEBGPU_PROFILER_END() \
BX_MACRO_BLOCK_BEGIN \
BGFX_PROFILER_END(); \
BX_MACRO_BLOCK_END
#define WEBGPU_NUM_UNIFORM_BUFFERS 8
namespace bgfx { namespace webgpu
{
template <typename Ty>
class StateCacheT
{
public:
void add(uint64_t _id, Ty _item)
{
invalidate(_id);
m_hashMap.insert(stl::make_pair(_id, _item));
}
Ty find(uint64_t _id)
{
typename HashMap::iterator it = m_hashMap.find(_id);
if(it != m_hashMap.end())
{
return it->second;
}
return NULL;
}
void invalidate(uint64_t _id)
{
typename HashMap::iterator it = m_hashMap.find(_id);
if(it != m_hashMap.end())
{
release(it->second);
m_hashMap.erase(it);
}
}
void invalidate()
{
for(typename HashMap::iterator it = m_hashMap.begin(), itEnd = m_hashMap.end(); it != itEnd; ++it)
{
release(it->second);
}
m_hashMap.clear();
}
uint32_t getCount() const
{
return uint32_t(m_hashMap.size());
}
private:
typedef stl::unordered_map<uint64_t, Ty> HashMap;
HashMap m_hashMap;
};
struct BufferWgpu
{
void create(uint32_t _size, void* _data, uint16_t _flags, uint16_t _stride = 0, bool _vertex = false);
void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false);
void destroy()
{
m_ptr.Destroy();
if(NULL != m_dynamic)
{
bx::deleteObject(g_allocator, m_dynamic);
m_dynamic = NULL;
}
}
uint32_t m_size;
uint16_t m_flags = BGFX_BUFFER_NONE;
bool m_vertex;
String m_label;
wgpu::Buffer m_ptr;
uint8_t* m_dynamic = NULL;
};
struct IndexBufferWgpu : public BufferWgpu
{
void create(uint32_t _size, void* _data, uint16_t _flags);
wgpu::IndexFormat m_format;
};
struct VertexBufferWgpu : public BufferWgpu
{
void create(uint32_t _size, void* _data, VertexLayoutHandle _declHandle, uint16_t _flags);
VertexLayoutHandle m_layoutHandle;
};
struct BindInfo
{
uint32_t m_index = UINT32_MAX;
uint32_t m_binding = UINT32_MAX;
UniformHandle m_uniform = BGFX_INVALID_HANDLE;
};
struct ShaderWgpu
{
void create(ShaderHandle _handle, const Memory* _mem);
void destroy()
{
if (NULL != m_constantBuffer)
{
UniformBuffer::destroy(m_constantBuffer);
m_constantBuffer = NULL;
}
m_module = NULL;
}
const char* name() const { return getName(m_handle); }
ShaderHandle m_handle;
String m_label;
wgpu::ShaderStage m_stage;
wgpu::ShaderModule m_module;
uint32_t* m_code = NULL;
size_t m_codeSize = 0;
UniformBuffer* m_constantBuffer = NULL;
PredefinedUniform m_predefined[PredefinedUniform::Count];
uint16_t m_attrMask[Attrib::Count];
uint8_t m_attrRemap[Attrib::Count];
uint32_t m_hash = 0;
uint16_t m_numUniforms = 0;
uint16_t m_size = 0;
uint16_t m_gpuSize = 0;
uint8_t m_numPredefined = 0;
uint8_t m_numAttrs = 0;
BindInfo m_bindInfo[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
wgpu::BindGroupLayoutEntry m_samplers[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
wgpu::BindGroupLayoutEntry m_textures[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
uint8_t m_numSamplers = 0;
wgpu::BindGroupLayoutEntry m_buffers[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
uint32_t m_numBuffers = 0;
};
struct PipelineStateWgpu;
struct ProgramWgpu
{
void create(const ShaderWgpu* _vsh, const ShaderWgpu* _fsh);
void destroy();
const ShaderWgpu* m_vsh = NULL;
const ShaderWgpu* m_fsh = NULL;
PredefinedUniform m_predefined[PredefinedUniform::Count * 2];
uint8_t m_numPredefined;
PipelineStateWgpu* m_computePS = NULL;
wgpu::BindGroupLayout m_bindGroupLayout;
uint16_t m_gpuSize = 0;
uint32_t m_numUniforms;
uint32_t m_bindGroupLayoutHash;
BindInfo m_bindInfo[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
wgpu::BindGroupLayoutEntry m_samplers[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
wgpu::BindGroupLayoutEntry m_textures[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
uint32_t m_numSamplers = 0;
wgpu::BindGroupLayoutEntry m_buffers[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
uint32_t m_numBuffers = 0;
};
constexpr size_t kMaxVertexInputs = 16;
constexpr size_t kMaxVertexAttributes = 16;
constexpr size_t kMaxColorAttachments = BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS;
constexpr uint32_t kMinBufferOffsetAlignment = 256;
struct RenderPassDescriptor
{
RenderPassDescriptor();
wgpu::RenderPassDescriptor desc;
wgpu::RenderPassColorAttachment colorAttachments[kMaxColorAttachments];
wgpu::RenderPassDepthStencilAttachment depthStencilAttachment;
};
struct VertexStateDescriptor
{
VertexStateDescriptor();
wgpu::VertexState desc;
wgpu::VertexBufferLayoutDescriptor buffers[kMaxVertexInputs];
wgpu::VertexAttributeDescriptor attributes[kMaxVertexAttributes];
};
struct RenderPipelineDescriptor
{
RenderPipelineDescriptor();
wgpu::RenderPipelineDescriptor2 desc;
wgpu::FragmentState fragment;
wgpu::DepthStencilState depthStencil;
wgpu::ColorTargetState targets[kMaxColorAttachments];
wgpu::BlendState blends[kMaxColorAttachments];
};
struct BindingsWgpu
{
uint32_t numEntries = 0;
wgpu::BindGroupEntry m_entries[2 + BGFX_CONFIG_MAX_TEXTURE_SAMPLERS*3];
};
struct BindStateWgpu
{
void clear();
uint32_t numOffset;
wgpu::BindGroup m_bindGroup;
};
struct RenderPassStateWgpu
{
RenderPassDescriptor m_rpd;
};
struct PipelineStateWgpu
{
RenderPipelineDescriptor m_rpd;
wgpu::PipelineLayout m_layout;
wgpu::RenderPipeline m_rps;
wgpu::ComputePipeline m_cps;
};
void release(RenderPassStateWgpu* _ptr)
{
bx::deleteObject(g_allocator, _ptr);
}
void release(PipelineStateWgpu* _ptr)
{
bx::deleteObject(g_allocator, _ptr);
}
class StagingBufferWgpu
{
public:
void create(uint32_t _size, bool mapped);
void map();
void unmap();
void destroy();
void mapped(void* _data);
wgpu::Buffer m_buffer;
void* m_data = NULL;
uint64_t m_size = 0;
};
class ScratchBufferWgpu
{
public:
void create(uint32_t _size); // , uint32_t _maxBindGroups);
void destroy();
void begin();
uint32_t write(void* data, uint64_t _size, uint64_t _offset);
uint32_t write(void* data, uint64_t _size);
void submit();
void release();
StagingBufferWgpu* m_staging = NULL;
wgpu::Buffer m_buffer;
uint32_t m_offset;
uint32_t m_size;
uint8_t m_stagingIndex = 0;
};
class BindStateCacheWgpu
{
public:
void create(); // , uint32_t _maxBindGroups);
void destroy();
void reset();
BindStateWgpu m_bindStates[1024] = {};
uint32_t m_currentBindState;
//uint32_t m_maxBindStates;
};
struct ReadbackWgpu
{
void create(TextureHandle _texture) { m_texture = _texture; }
void destroy()
{
m_buffer.Destroy();
}
void readback(void const* data)
{
bx::memCopy(m_data, data, m_size);
m_buffer.Unmap();
m_mapped = false;
}
TextureHandle m_texture;
wgpu::Buffer m_buffer;
uint32_t m_mip = 0;
bool m_mapped = false;
void* m_data = NULL;
size_t m_size = 0;
};
struct TextureWgpu
{
enum Enum
{
Texture2D,
Texture3D,
TextureCube,
};
void create(TextureHandle _handle, const Memory* _mem, uint64_t _flags, uint8_t _skip);
void destroy()
{
m_ptr.Destroy();
}
void update(
uint8_t _side
, uint8_t _mip
, const Rect& _rect
, uint16_t _z
, uint16_t _depth
, uint16_t _pitch
, const Memory* _mem
);
TextureHandle m_handle;
String m_label;
wgpu::TextureView m_view;
wgpu::TextureView getTextureMipLevel(int _mip);
wgpu::Texture m_ptr;
wgpu::Texture m_ptrMsaa;
wgpu::TextureView m_ptrMips[14] = {};
wgpu::Sampler m_sampler;
uint64_t m_flags = 0;
uint32_t m_width = 0;
uint32_t m_height = 0;
uint32_t m_depth = 0;
uint8_t m_type;
TextureFormat::Enum m_requestedFormat;
TextureFormat::Enum m_textureFormat;
uint8_t m_numMips = 0;
uint8_t m_numLayers;
uint32_t m_numSides;
uint8_t m_sampleCount;
ReadbackWgpu m_readback;
};
struct SamplerStateWgpu
{
wgpu::Sampler m_sampler;
};
void release(SamplerStateWgpu* _ptr)
{
bx::deleteObject(g_allocator, _ptr);
}
struct FrameBufferWgpu;
struct SwapChainWgpu
{
void init(wgpu::Device _device, void* _nwh, uint32_t _width, uint32_t _height);
void resize(FrameBufferWgpu& _frameBuffer, uint32_t _width, uint32_t _height, uint32_t _flags);
void flip();
wgpu::TextureView current();
#if !BX_PLATFORM_EMSCRIPTEN
DawnSwapChainImplementation m_impl;
#endif
wgpu::SwapChain m_swapChain;
wgpu::TextureView m_drawable;
wgpu::Texture m_backBufferColorMsaa;
wgpu::Texture m_backBufferDepth;
wgpu::TextureFormat m_colorFormat;
wgpu::TextureFormat m_depthFormat;
uint32_t m_maxAnisotropy = 0;
uint8_t m_sampleCount;
};
struct FrameBufferWgpu
{
void create(uint8_t _num, const Attachment* _attachment);
bool create(
uint16_t _denseIdx
, void* _nwh
, uint32_t _width
, uint32_t _height
, TextureFormat::Enum _format
, TextureFormat::Enum _depthFormat
);
void postReset();
uint16_t destroy();
SwapChainWgpu* m_swapChain = NULL;
void* m_nwh = NULL;
uint32_t m_width;
uint32_t m_height;
uint16_t m_denseIdx = UINT16_MAX;
uint32_t m_pixelFormatHash = 0;
TextureHandle m_colorHandle[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS - 1];
TextureHandle m_depthHandle = { kInvalidHandle };
Attachment m_colorAttachment[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS - 1];
Attachment m_depthAttachment;
uint8_t m_num = 0; // number of color handles
};
struct CommandQueueWgpu
{
void init(wgpu::Queue _queue);
void shutdown();
void beginRender();
void beginStaging();
void kick(bool _endFrame, bool _waitForFinish = false);
void finish(bool _finishAll = false);
void release(wgpu::Buffer _buffer);
void consume();
#if BGFX_CONFIG_MULTITHREADED
//bx::Semaphore m_framesSemaphore;
#endif
wgpu::Queue m_queue;
wgpu::CommandEncoder m_stagingEncoder;
wgpu::CommandEncoder m_renderEncoder;
int m_releaseWriteIndex = 0;
int m_releaseReadIndex = 0;
typedef stl::vector<wgpu::Buffer> ResourceArray;
ResourceArray m_release[BGFX_CONFIG_MAX_FRAME_LATENCY];
};
struct TimerQueryWgpu
{
TimerQueryWgpu()
: m_control(4)
{
}
void init();
void shutdown();
uint32_t begin(uint32_t _resultIdx, uint32_t _frameNum);
void end(uint32_t _idx);
void addHandlers(wgpu::CommandBuffer& _commandBuffer);
bool get();
struct Result
{
void reset()
{
m_begin = 0;
m_end = 0;
m_pending = 0;
m_frameNum = 0;
}
uint64_t m_begin;
uint64_t m_end;
uint32_t m_pending;
uint32_t m_frameNum; // TODO: implement (currently stays 0)
};
uint64_t m_begin;
uint64_t m_end;
uint64_t m_elapsed;
uint64_t m_frequency;
Result m_result[4 * 2];
bx::RingBufferControl m_control;
};
struct OcclusionQueryWgpu
{
OcclusionQueryWgpu()
: m_control(BX_COUNTOF(m_query))
{
}
void postReset();
void preReset();
void begin(wgpu::RenderPassEncoder& _rce, Frame* _render, OcclusionQueryHandle _handle);
void end(wgpu::RenderPassEncoder& _rce);
void resolve(Frame* _render, bool _wait = false);
void invalidate(OcclusionQueryHandle _handle);
struct Query
{
OcclusionQueryHandle m_handle;
};
wgpu::Buffer m_buffer;
Query m_query[BGFX_CONFIG_MAX_OCCLUSION_QUERIES];
bx::RingBufferControl m_control;
};
} /* namespace webgpu */ } // namespace bgfx
#endif // BGFX_CONFIG_RENDERER_WEBGPU
#endif // BGFX_RENDERER_WEBGPU_H_HEADER_GUARD

View File

@ -9,5 +9,5 @@
*
*/
#define BGFX_REV_NUMBER 8604
#define BGFX_REV_SHA1 "f14c14a48554de4e66a4b2334f623d988c06f36d"
#define BGFX_REV_NUMBER 8615
#define BGFX_REV_SHA1 "67107e5511ee09896643d0850574ae1485fa44c9"

View File

@ -44,7 +44,6 @@ namespace bgfx
&s_attribTypeSizeGl, // OpenGLES
&s_attribTypeSizeGl, // OpenGL
&s_attribTypeSizeD3D1x, // Vulkan
&s_attribTypeSizeD3D1x, // WebGPU
&s_attribTypeSizeD3D1x, // Count
};
BX_STATIC_ASSERT(BX_COUNTOF(s_attribTypeSize) == RendererType::Count+1);

View File

@ -17,7 +17,6 @@ BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wshadow") // warning: declaration of 'u
#include <ResourceLimits.h>
#include <SPIRV/SPVRemapper.h>
#include <SPIRV/GlslangToSpv.h>
#include <webgpu/webgpu_cpp.h>
#define SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
#include <spirv_msl.hpp>
#include <spirv_reflect.hpp>