diff --git a/bindings/bf/bgfx.bf b/bindings/bf/bgfx.bf
index 4b6ce0b42..675614a4c 100644
--- a/bindings/bf/bgfx.bf
+++ b/bindings/bf/bgfx.bf
@@ -1095,55 +1095,60 @@ public static class bgfx
///
RendererMultithreaded = 0x0000000000000800,
+ ///
+ /// 16-bit floats are supported in shaders.
+ ///
+ ShaderF16 = 0x0000000000001000,
+
///
/// Multiple windows are supported.
///
- SwapChain = 0x0000000000001000,
+ SwapChain = 0x0000000000002000,
///
/// Cubemap texture array is supported.
///
- TextureCubeArray = 0x0000000000002000,
+ TextureCubeArray = 0x0000000000004000,
///
/// CPU direct access to GPU texture memory.
///
- TextureDirectAccess = 0x0000000000004000,
+ TextureDirectAccess = 0x0000000000008000,
///
/// External texture is supported.
///
- TextureExternal = 0x0000000000008000,
+ TextureExternal = 0x0000000000010000,
///
/// External shared texture is supported.
///
- TextureExternalShared = 0x0000000000010000,
+ TextureExternalShared = 0x0000000000020000,
///
/// Transparent back buffer supported.
///
- TransparentBackbuffer = 0x0000000000020000,
+ TransparentBackbuffer = 0x0000000000040000,
///
/// Variable Rate Shading
///
- VariableRateShading = 0x0000000000040000,
+ VariableRateShading = 0x0000000000080000,
///
/// Vertex attribute 10_10_10_2 is supported.
///
- VertexAttribUint10 = 0x0000000000080000,
+ VertexAttribUint10 = 0x0000000000100000,
///
/// Hardware video decode is supported.
///
- VideoDecode = 0x0000000000100000,
+ VideoDecode = 0x0000000000200000,
///
/// Viewport layer is available in vertex shader.
///
- ViewportLayerArray = 0x0000000000200000,
+ ViewportLayerArray = 0x0000000000400000,
}
[AllowDuplicates]
diff --git a/bindings/c3/bgfx.c3 b/bindings/c3/bgfx.c3
index a8e590277..9c902d365 100644
--- a/bindings/c3/bgfx.c3
+++ b/bindings/c3/bgfx.c3
@@ -699,35 +699,38 @@ constdef CapsFlags : inline ulong
// Renderer is on separate thread.
RENDERERMULTITHREADED = 0x0000000000000800,
+ // 16-bit floats are supported in shaders.
+ SHADERF16 = 0x0000000000001000,
+
// Multiple windows are supported.
- SWAPCHAIN = 0x0000000000001000,
+ SWAPCHAIN = 0x0000000000002000,
// Cubemap texture array is supported.
- TEXTURECUBEARRAY = 0x0000000000002000,
+ TEXTURECUBEARRAY = 0x0000000000004000,
// CPU direct access to GPU texture memory.
- TEXTUREDIRECTACCESS = 0x0000000000004000,
+ TEXTUREDIRECTACCESS = 0x0000000000008000,
// External texture is supported.
- TEXTUREEXTERNAL = 0x0000000000008000,
+ TEXTUREEXTERNAL = 0x0000000000010000,
// External shared texture is supported.
- TEXTUREEXTERNALSHARED = 0x0000000000010000,
+ TEXTUREEXTERNALSHARED = 0x0000000000020000,
// Transparent back buffer supported.
- TRANSPARENTBACKBUFFER = 0x0000000000020000,
+ TRANSPARENTBACKBUFFER = 0x0000000000040000,
// Variable Rate Shading
- VARIABLERATESHADING = 0x0000000000040000,
+ VARIABLERATESHADING = 0x0000000000080000,
// Vertex attribute 10_10_10_2 is supported.
- VERTEXATTRIBUINT10 = 0x0000000000080000,
+ VERTEXATTRIBUINT10 = 0x0000000000100000,
// Hardware video decode is supported.
- VIDEODECODE = 0x0000000000100000,
+ VIDEODECODE = 0x0000000000200000,
// Viewport layer is available in vertex shader.
- VIEWPORTLAYERARRAY = 0x0000000000200000,
+ VIEWPORTLAYERARRAY = 0x0000000000400000,
}
constdef CapsFormatFlags : inline uint
diff --git a/bindings/cs/bgfx.cs b/bindings/cs/bgfx.cs
index 3725c65f4..603814f32 100644
--- a/bindings/cs/bgfx.cs
+++ b/bindings/cs/bgfx.cs
@@ -1094,55 +1094,60 @@ public static partial class bgfx
///
RendererMultithreaded = 0x0000000000000800,
+ ///
+ /// 16-bit floats are supported in shaders.
+ ///
+ ShaderF16 = 0x0000000000001000,
+
///
/// Multiple windows are supported.
///
- SwapChain = 0x0000000000001000,
+ SwapChain = 0x0000000000002000,
///
/// Cubemap texture array is supported.
///
- TextureCubeArray = 0x0000000000002000,
+ TextureCubeArray = 0x0000000000004000,
///
/// CPU direct access to GPU texture memory.
///
- TextureDirectAccess = 0x0000000000004000,
+ TextureDirectAccess = 0x0000000000008000,
///
/// External texture is supported.
///
- TextureExternal = 0x0000000000008000,
+ TextureExternal = 0x0000000000010000,
///
/// External shared texture is supported.
///
- TextureExternalShared = 0x0000000000010000,
+ TextureExternalShared = 0x0000000000020000,
///
/// Transparent back buffer supported.
///
- TransparentBackbuffer = 0x0000000000020000,
+ TransparentBackbuffer = 0x0000000000040000,
///
/// Variable Rate Shading
///
- VariableRateShading = 0x0000000000040000,
+ VariableRateShading = 0x0000000000080000,
///
/// Vertex attribute 10_10_10_2 is supported.
///
- VertexAttribUint10 = 0x0000000000080000,
+ VertexAttribUint10 = 0x0000000000100000,
///
/// Hardware video decode is supported.
///
- VideoDecode = 0x0000000000100000,
+ VideoDecode = 0x0000000000200000,
///
/// Viewport layer is available in vertex shader.
///
- ViewportLayerArray = 0x0000000000200000,
+ ViewportLayerArray = 0x0000000000400000,
}
[Flags]
diff --git a/bindings/d/package.d b/bindings/d/package.d
index 935b9cf96..7266dda91 100644
--- a/bindings/d/package.d
+++ b/bindings/d/package.d
@@ -9,7 +9,7 @@ import bindbc.common.types: c_int64, c_uint64, va_list;
import bindbc.bgfx.config;
static import bgfx.impl;
-enum uint apiVersion = 163;
+enum uint apiVersion = 164;
alias ViewID = ushort;
@@ -541,16 +541,17 @@ enum CapFlags: CapFlags_{
index32 = 0x0000_0000_0000_0200, ///32-bit indices are supported.
primitiveID = 0x0000_0000_0000_0400, ///PrimitiveID is available in fragment shader.
rendererMultithreaded = 0x0000_0000_0000_0800, ///Renderer is on separate thread.
- swapChain = 0x0000_0000_0000_1000, ///Multiple windows are supported.
- textureCubeArray = 0x0000_0000_0000_2000, ///Cubemap texture array is supported.
- textureDirectAccess = 0x0000_0000_0000_4000, ///CPU direct access to GPU texture memory.
- textureExternal = 0x0000_0000_0000_8000, ///External texture is supported.
- textureExternalShared = 0x0000_0000_0001_0000, ///External shared texture is supported.
- transparentBackbuffer = 0x0000_0000_0002_0000, ///Transparent back buffer supported.
- variableRateShading = 0x0000_0000_0004_0000, ///Variable Rate Shading
- vertexAttribUint10 = 0x0000_0000_0008_0000, ///Vertex attribute 10_10_10_2 is supported.
- videoDecode = 0x0000_0000_0010_0000, ///Hardware video decode is supported.
- viewportLayerArray = 0x0000_0000_0020_0000, ///Viewport layer is available in vertex shader.
+ shaderF16 = 0x0000_0000_0000_1000, ///16-bit floats are supported in shaders.
+ swapChain = 0x0000_0000_0000_2000, ///Multiple windows are supported.
+ textureCubeArray = 0x0000_0000_0000_4000, ///Cubemap texture array is supported.
+ textureDirectAccess = 0x0000_0000_0000_8000, ///CPU direct access to GPU texture memory.
+ textureExternal = 0x0000_0000_0001_0000, ///External texture is supported.
+ textureExternalShared = 0x0000_0000_0002_0000, ///External shared texture is supported.
+ transparentBackbuffer = 0x0000_0000_0004_0000, ///Transparent back buffer supported.
+ variableRateShading = 0x0000_0000_0008_0000, ///Variable Rate Shading
+ vertexAttribUint10 = 0x0000_0000_0010_0000, ///Vertex attribute 10_10_10_2 is supported.
+ videoDecode = 0x0000_0000_0020_0000, ///Hardware video decode is supported.
+ viewportLayerArray = 0x0000_0000_0040_0000, ///Viewport layer is available in vertex shader.
}
alias CapsFormat_ = uint;
diff --git a/bindings/py/bgfx.py b/bindings/py/bgfx.py
index 00039d4bf..56d23cae2 100644
--- a/bindings/py/bgfx.py
+++ b/bindings/py/bgfx.py
@@ -572,16 +572,17 @@ class CapsFlags(enum.IntFlag):
Index32 = 0x200
PrimitiveId = 0x400
RendererMultithreaded = 0x800
- SwapChain = 0x1000
- TextureCubeArray = 0x2000
- TextureDirectAccess = 0x4000
- TextureExternal = 0x8000
- TextureExternalShared = 0x10000
- TransparentBackbuffer = 0x20000
- VariableRateShading = 0x40000
- VertexAttribUint10 = 0x80000
- VideoDecode = 0x100000
- ViewportLayerArray = 0x200000
+ ShaderF16 = 0x1000
+ SwapChain = 0x2000
+ TextureCubeArray = 0x4000
+ TextureDirectAccess = 0x8000
+ TextureExternal = 0x10000
+ TextureExternalShared = 0x20000
+ TransparentBackbuffer = 0x40000
+ VariableRateShading = 0x80000
+ VertexAttribUint10 = 0x100000
+ VideoDecode = 0x200000
+ ViewportLayerArray = 0x400000
class CapsFormatFlags(enum.IntFlag):
TextureNone = 0x0
diff --git a/bindings/py/bgfx.pyi b/bindings/py/bgfx.pyi
index 1c1fa1dd2..47549f1bd 100644
--- a/bindings/py/bgfx.pyi
+++ b/bindings/py/bgfx.pyi
@@ -1056,26 +1056,28 @@ class CapsFlags(enum.IntFlag):
PrimitiveId = 0x400
# Renderer is on separate thread.
RendererMultithreaded = 0x800
+ # 16-bit floats are supported in shaders.
+ ShaderF16 = 0x1000
# Multiple windows are supported.
- SwapChain = 0x1000
+ SwapChain = 0x2000
# Cubemap texture array is supported.
- TextureCubeArray = 0x2000
+ TextureCubeArray = 0x4000
# CPU direct access to GPU texture memory.
- TextureDirectAccess = 0x4000
+ TextureDirectAccess = 0x8000
# External texture is supported.
- TextureExternal = 0x8000
+ TextureExternal = 0x10000
# External shared texture is supported.
- TextureExternalShared = 0x10000
+ TextureExternalShared = 0x20000
# Transparent back buffer supported.
- TransparentBackbuffer = 0x20000
+ TransparentBackbuffer = 0x40000
# Variable Rate Shading
- VariableRateShading = 0x40000
+ VariableRateShading = 0x80000
# Vertex attribute 10_10_10_2 is supported.
- VertexAttribUint10 = 0x80000
+ VertexAttribUint10 = 0x100000
# Hardware video decode is supported.
- VideoDecode = 0x100000
+ VideoDecode = 0x200000
# Viewport layer is available in vertex shader.
- ViewportLayerArray = 0x200000
+ ViewportLayerArray = 0x400000
class CapsFormatFlags(enum.IntFlag):
# Texture format is not supported.
diff --git a/bindings/zig/bgfx.zig b/bindings/zig/bgfx.zig
index 6deca0946..bfddde3e1 100644
--- a/bindings/zig/bgfx.zig
+++ b/bindings/zig/bgfx.zig
@@ -679,35 +679,38 @@ pub const CapsFlags_PrimitiveId: CapsFlags = 0x0000000000000400;
/// Renderer is on separate thread.
pub const CapsFlags_RendererMultithreaded: CapsFlags = 0x0000000000000800;
+/// 16-bit floats are supported in shaders.
+pub const CapsFlags_ShaderF16: CapsFlags = 0x0000000000001000;
+
/// Multiple windows are supported.
-pub const CapsFlags_SwapChain: CapsFlags = 0x0000000000001000;
+pub const CapsFlags_SwapChain: CapsFlags = 0x0000000000002000;
/// Cubemap texture array is supported.
-pub const CapsFlags_TextureCubeArray: CapsFlags = 0x0000000000002000;
+pub const CapsFlags_TextureCubeArray: CapsFlags = 0x0000000000004000;
/// CPU direct access to GPU texture memory.
-pub const CapsFlags_TextureDirectAccess: CapsFlags = 0x0000000000004000;
+pub const CapsFlags_TextureDirectAccess: CapsFlags = 0x0000000000008000;
/// External texture is supported.
-pub const CapsFlags_TextureExternal: CapsFlags = 0x0000000000008000;
+pub const CapsFlags_TextureExternal: CapsFlags = 0x0000000000010000;
/// External shared texture is supported.
-pub const CapsFlags_TextureExternalShared: CapsFlags = 0x0000000000010000;
+pub const CapsFlags_TextureExternalShared: CapsFlags = 0x0000000000020000;
/// Transparent back buffer supported.
-pub const CapsFlags_TransparentBackbuffer: CapsFlags = 0x0000000000020000;
+pub const CapsFlags_TransparentBackbuffer: CapsFlags = 0x0000000000040000;
/// Variable Rate Shading
-pub const CapsFlags_VariableRateShading: CapsFlags = 0x0000000000040000;
+pub const CapsFlags_VariableRateShading: CapsFlags = 0x0000000000080000;
/// Vertex attribute 10_10_10_2 is supported.
-pub const CapsFlags_VertexAttribUint10: CapsFlags = 0x0000000000080000;
+pub const CapsFlags_VertexAttribUint10: CapsFlags = 0x0000000000100000;
/// Hardware video decode is supported.
-pub const CapsFlags_VideoDecode: CapsFlags = 0x0000000000100000;
+pub const CapsFlags_VideoDecode: CapsFlags = 0x0000000000200000;
/// Viewport layer is available in vertex shader.
-pub const CapsFlags_ViewportLayerArray: CapsFlags = 0x0000000000200000;
+pub const CapsFlags_ViewportLayerArray: CapsFlags = 0x0000000000400000;
pub const CapsFormatFlags = u32;
/// Texture format is not supported.
diff --git a/docs/bgfx.rst b/docs/bgfx.rst
index 2fff5ee77..273129f6d 100644
--- a/docs/bgfx.rst
+++ b/docs/bgfx.rst
@@ -158,6 +158,7 @@ Individual capability flags.
.. doxygendefine:: BGFX_CAPS_INDEX32
.. doxygendefine:: BGFX_CAPS_PRIMITIVE_ID
.. doxygendefine:: BGFX_CAPS_RENDERER_MULTITHREADED
+.. doxygendefine:: BGFX_CAPS_SHADER_F16
.. doxygendefine:: BGFX_CAPS_SWAP_CHAIN
.. doxygendefine:: BGFX_CAPS_TEXTURE_CUBE_ARRAY
.. doxygendefine:: BGFX_CAPS_TEXTURE_DIRECT_ACCESS
diff --git a/include/bgfx/defines.h b/include/bgfx/defines.h
index b6ad8a6f5..e191857a2 100644
--- a/include/bgfx/defines.h
+++ b/include/bgfx/defines.h
@@ -15,7 +15,7 @@
#ifndef BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_DEFINES_H_HEADER_GUARD
-#define BGFX_API_VERSION UINT32_C(163)
+#define BGFX_API_VERSION UINT32_C(164)
/**
* Color RGB/alpha/depth write. When it's not specified write will be disabled.
@@ -487,16 +487,17 @@
#define BGFX_CAPS_INDEX32 UINT64_C(0x0000000000000200) //!< 32-bit indices are supported.
#define BGFX_CAPS_PRIMITIVE_ID UINT64_C(0x0000000000000400) //!< PrimitiveID is available in fragment shader.
#define BGFX_CAPS_RENDERER_MULTITHREADED UINT64_C(0x0000000000000800) //!< Renderer is on separate thread.
-#define BGFX_CAPS_SWAP_CHAIN UINT64_C(0x0000000000001000) //!< Multiple windows are supported.
-#define BGFX_CAPS_TEXTURE_CUBE_ARRAY UINT64_C(0x0000000000002000) //!< Cubemap texture array is supported.
-#define BGFX_CAPS_TEXTURE_DIRECT_ACCESS UINT64_C(0x0000000000004000) //!< CPU direct access to GPU texture memory.
-#define BGFX_CAPS_TEXTURE_EXTERNAL UINT64_C(0x0000000000008000) //!< External texture is supported.
-#define BGFX_CAPS_TEXTURE_EXTERNAL_SHARED UINT64_C(0x0000000000010000) //!< External shared texture is supported.
-#define BGFX_CAPS_TRANSPARENT_BACKBUFFER UINT64_C(0x0000000000020000) //!< Transparent back buffer supported.
-#define BGFX_CAPS_VARIABLE_RATE_SHADING UINT64_C(0x0000000000040000) //!< Variable Rate Shading
-#define BGFX_CAPS_VERTEX_ATTRIB_UINT10 UINT64_C(0x0000000000080000) //!< Vertex attribute 10_10_10_2 is supported.
-#define BGFX_CAPS_VIDEO_DECODE UINT64_C(0x0000000000100000) //!< Hardware video decode is supported.
-#define BGFX_CAPS_VIEWPORT_LAYER_ARRAY UINT64_C(0x0000000000200000) //!< Viewport layer is available in vertex shader.
+#define BGFX_CAPS_SHADER_F16 UINT64_C(0x0000000000001000) //!< 16-bit floats are supported in shaders.
+#define BGFX_CAPS_SWAP_CHAIN UINT64_C(0x0000000000002000) //!< Multiple windows are supported.
+#define BGFX_CAPS_TEXTURE_CUBE_ARRAY UINT64_C(0x0000000000004000) //!< Cubemap texture array is supported.
+#define BGFX_CAPS_TEXTURE_DIRECT_ACCESS UINT64_C(0x0000000000008000) //!< CPU direct access to GPU texture memory.
+#define BGFX_CAPS_TEXTURE_EXTERNAL UINT64_C(0x0000000000010000) //!< External texture is supported.
+#define BGFX_CAPS_TEXTURE_EXTERNAL_SHARED UINT64_C(0x0000000000020000) //!< External shared texture is supported.
+#define BGFX_CAPS_TRANSPARENT_BACKBUFFER UINT64_C(0x0000000000040000) //!< Transparent back buffer supported.
+#define BGFX_CAPS_VARIABLE_RATE_SHADING UINT64_C(0x0000000000080000) //!< Variable Rate Shading
+#define BGFX_CAPS_VERTEX_ATTRIB_UINT10 UINT64_C(0x0000000000100000) //!< Vertex attribute 10_10_10_2 is supported.
+#define BGFX_CAPS_VIDEO_DECODE UINT64_C(0x0000000000200000) //!< Hardware video decode is supported.
+#define BGFX_CAPS_VIEWPORT_LAYER_ARRAY UINT64_C(0x0000000000400000) //!< Viewport layer is available in vertex shader.
#define BGFX_CAPS_FORMAT_TEXTURE_NONE UINT32_C(0x00000000) //!< Texture format is not supported.
#define BGFX_CAPS_FORMAT_TEXTURE_2D UINT32_C(0x00000001) //!< Texture format is supported.
diff --git a/scripts/bgfx.idl b/scripts/bgfx.idl
index 8bcd12d2d..156610ce3 100644
--- a/scripts/bgfx.idl
+++ b/scripts/bgfx.idl
@@ -1,7 +1,7 @@
-- vim: syntax=lua
-- bgfx interface
-version(163)
+version(164)
typedef "bool"
typedef "char"
@@ -398,6 +398,7 @@ flag.Caps { bits = 64, base = 1, name = "Caps", section = "Available Caps" }
.Index32 --- 32-bit indices are supported.
.PrimitiveId --- PrimitiveID is available in fragment shader.
.RendererMultithreaded --- Renderer is on separate thread.
+ .ShaderF16 --- 16-bit floats are supported in shaders.
.SwapChain --- Multiple windows are supported.
.TextureCubeArray --- Cubemap texture array is supported.
.TextureDirectAccess --- CPU direct access to GPU texture memory.
diff --git a/src/bgfx.cpp b/src/bgfx.cpp
index 942013be5..428148e41 100644
--- a/src/bgfx.cpp
+++ b/src/bgfx.cpp
@@ -1893,6 +1893,7 @@ namespace bgfx
CAPS_FLAGS(BGFX_CAPS_INDEX32),
CAPS_FLAGS(BGFX_CAPS_PRIMITIVE_ID),
CAPS_FLAGS(BGFX_CAPS_RENDERER_MULTITHREADED),
+ CAPS_FLAGS(BGFX_CAPS_SHADER_F16),
CAPS_FLAGS(BGFX_CAPS_SWAP_CHAIN),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_CUBE_ARRAY),
CAPS_FLAGS(BGFX_CAPS_TEXTURE_DIRECT_ACCESS),
diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp
index fce51b921..5700fada6 100644
--- a/src/renderer_d3d12.cpp
+++ b/src/renderer_d3d12.cpp
@@ -883,6 +883,7 @@ namespace bgfx { namespace d3d12
, m_backBufferColorIdx(0)
, m_rtMsaa(false)
, m_directAccessSupport(false)
+ , m_shaderF16Support(false)
, m_variableRateShadingSupport(false)
, m_additionalShadingRatesSupport(false)
, m_computeStateDirty(false)
@@ -1259,6 +1260,7 @@ namespace bgfx { namespace d3d12
BX_TRACE("\tMSAA64KBAlignedTextureSupported %d", options4.MSAA64KBAlignedTextureSupported);
BX_TRACE("\tSharedResourceCompatibilityTier %d", options4.SharedResourceCompatibilityTier);
BX_TRACE("\tNative16BitShaderOpsSupported %d", options4.Native16BitShaderOpsSupported);
+ m_shaderF16Support = !!options4.Native16BitShaderOpsSupported;
break;
}
@@ -1791,6 +1793,7 @@ namespace bgfx { namespace d3d12
| BGFX_CAPS_IMAGE_RW
| BGFX_CAPS_INDEX32
| BGFX_CAPS_PRIMITIVE_ID
+ | (m_shaderF16Support ? BGFX_CAPS_SHADER_F16 : 0)
| (BX_ENABLED(BX_PLATFORM_WINDOWS) ? BGFX_CAPS_SWAP_CHAIN : 0)
| BGFX_CAPS_TEXTURE_CUBE_ARRAY
| (m_directAccessSupport ? BGFX_CAPS_TEXTURE_DIRECT_ACCESS : 0)
@@ -4611,6 +4614,7 @@ namespace bgfx { namespace d3d12
uint32_t m_backBufferColorIdx;
bool m_rtMsaa;
bool m_directAccessSupport;
+ bool m_shaderF16Support;
bool m_variableRateShadingSupport;
bool m_additionalShadingRatesSupport;
diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp
index c2c3b8797..3e67ce9c7 100644
--- a/src/renderer_gl.cpp
+++ b/src/renderer_gl.cpp
@@ -606,6 +606,7 @@ namespace bgfx { namespace gl
enum Enum
{
AMD_conservative_depth,
+ AMD_gpu_shader_half_float,
AMD_multi_draw_indirect,
ANGLE_depth_texture,
@@ -759,6 +760,7 @@ namespace bgfx { namespace gl
NV_copy_image,
NV_draw_buffers,
NV_draw_instanced,
+ NV_gpu_shader5,
NV_instanced_arrays,
NV_occlusion_query,
NV_polygon_mode,
@@ -840,6 +842,7 @@ namespace bgfx { namespace gl
static Extension s_extension[] =
{
{ "AMD_conservative_depth", false, true },
+ { "AMD_gpu_shader_half_float", false, true },
{ "AMD_multi_draw_indirect", false, true },
{ "ANGLE_depth_texture", false, true },
@@ -993,6 +996,7 @@ namespace bgfx { namespace gl
{ "NV_copy_image", false, true },
{ "NV_draw_buffers", false, true }, // GLES extension.
{ "NV_draw_instanced", false, true }, // GLES extension.
+ { "NV_gpu_shader5", false, true },
{ "NV_instanced_arrays", false, true }, // GLES extension.
{ "NV_occlusion_query", false, true },
{ "NV_polygon_mode", false, true }, // GLES extension.
@@ -2830,6 +2834,12 @@ namespace bgfx { namespace gl
: 0
;
+ g_caps.supported |= s_extension[Extension::AMD_gpu_shader_half_float].m_supported
+ || s_extension[Extension::NV_gpu_shader5].m_supported
+ ? BGFX_CAPS_SHADER_F16
+ : 0
+ ;
+
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
{
glPolygonMode = s_extension[Extension::NV_polygon_mode].m_supported
diff --git a/src/renderer_mtl.cpp b/src/renderer_mtl.cpp
index eb0ed4d6f..0063a31cb 100644
--- a/src/renderer_mtl.cpp
+++ b/src/renderer_mtl.cpp
@@ -1003,6 +1003,7 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
| BGFX_CAPS_BLEND_INDEPENDENT
| BGFX_CAPS_COMPUTE
| BGFX_CAPS_INDEX32
+ | BGFX_CAPS_SHADER_F16
| BGFX_CAPS_SWAP_CHAIN
| BGFX_CAPS_TEXTURE_EXTERNAL
| BGFX_CAPS_VERTEX_ATTRIB_UINT10
diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp
index fa39ed4dd..471686500 100644
--- a/src/renderer_vk.cpp
+++ b/src/renderer_vk.cpp
@@ -378,10 +378,12 @@ VK_IMPORT_DEVICE
EXT_shader_viewport_index_layer,
EXT_surface_maintenance1,
EXT_swapchain_maintenance1,
+ KHR_16bit_storage,
KHR_draw_indirect_count,
KHR_fragment_shading_rate,
KHR_get_physical_device_properties2,
KHR_get_surface_capabilities2,
+ KHR_shader_float16_int8,
KHR_video_queue,
KHR_video_decode_queue,
KHR_video_decode_h264,
@@ -426,10 +428,12 @@ VK_IMPORT_DEVICE
{ "VK_EXT_shader_viewport_index_layer", 1, false, false, true, Layer::Count },
{ "VK_EXT_surface_maintenance1", 1, false, false, true, Layer::Count },
{ "VK_EXT_swapchain_maintenance1", 1, false, false, true, Layer::Count },
+ { "VK_KHR_16bit_storage", 1, false, false, true, Layer::Count },
{ "VK_KHR_draw_indirect_count", 1, false, false, true, Layer::Count },
{ "VK_KHR_fragment_shading_rate", 1, false, false, true, Layer::Count },
{ "VK_KHR_get_physical_device_properties2", 1, false, false, true, Layer::Count },
{ "VK_KHR_get_surface_capabilities2", 1, false, false, true, Layer::Count },
+ { "VK_KHR_shader_float16_int8", 1, false, false, true, Layer::Count },
{ "VK_KHR_video_queue", 1, false, false, true, Layer::Count },
{ "VK_KHR_video_decode_queue", 1, false, false, true, Layer::Count },
{ "VK_KHR_video_decode_h264", 1, false, false, true, Layer::Count },
@@ -1337,6 +1341,8 @@ VK_IMPORT_DEVICE
VkPhysicalDeviceCustomBorderColorFeaturesEXT customBorderColorFeatures = {};
VkPhysicalDeviceFragmentShadingRateFeaturesKHR fragmentShadingRate = {};
VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT swapchainMaintenance1Features = {};
+ VkPhysicalDeviceShaderFloat16Int8Features shaderFloat16Int8Features = {};
+ VkPhysicalDevice16BitStorageFeatures storage16BitFeatures = {};
m_fbh = BGFX_INVALID_HANDLE;
m_readOnlyDepthLayout = VK_IMAGE_LAYOUT_UNDEFINED;
@@ -1787,6 +1793,19 @@ VK_IMPORT_INSTANCE
swapchainMaintenance1Features.pNext = NULL;
}
+ next->pNext = (VkBaseOutStructure*)&storage16BitFeatures;
+ next = (VkBaseOutStructure*)&storage16BitFeatures;
+ storage16BitFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES;
+ storage16BitFeatures.pNext = NULL;
+
+ if (s_extension[Extension::KHR_shader_float16_int8].m_supported)
+ {
+ next->pNext = (VkBaseOutStructure*)&shaderFloat16Int8Features;
+ next = (VkBaseOutStructure*)&shaderFloat16Int8Features;
+ shaderFloat16Int8Features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES;
+ shaderFloat16Int8Features.pNext = NULL;
+ }
+
nextFeatures = deviceFeatures2.pNext;
vkGetPhysicalDeviceFeatures2KHR(m_physicalDevice, &deviceFeatures2);
@@ -1947,6 +1966,13 @@ VK_IMPORT_INSTANCE
| (s_extension[Extension::EXT_shader_viewport_index_layer].m_supported ? BGFX_CAPS_VIEWPORT_LAYER_ARRAY : 0)
| (s_extension[Extension::KHR_draw_indirect_count ].m_supported && indirectDrawSupport ? BGFX_CAPS_DRAW_INDIRECT_COUNT : 0)
| (s_extension[Extension::KHR_fragment_shading_rate ].m_supported ? BGFX_CAPS_VARIABLE_RATE_SHADING : 0)
+ | (true
+ && shaderFloat16Int8Features.shaderFloat16
+ && storage16BitFeatures.storageBuffer16BitAccess
+ && storage16BitFeatures.uniformAndStorageBuffer16BitAccess
+ && storage16BitFeatures.storageInputOutput16
+ ? BGFX_CAPS_SHADER_F16
+ : 0)
;
m_variableRateShadingSupported = true
diff --git a/src/renderer_webgpu.cpp b/src/renderer_webgpu.cpp
index f5c62daf6..9f721289d 100644
--- a/src/renderer_webgpu.cpp
+++ b/src/renderer_webgpu.cpp
@@ -1222,6 +1222,8 @@ WGPU_IMPORT
ifSupported(WGPUFeatureName_RG11B10UfloatRenderable),
ifSupported(WGPUFeatureName_Depth32FloatStencil8),
+
+ ifSupported(WGPUFeatureName_ShaderF16),
};
bx::quickSort(requiredFeatures, BX_COUNTOF(requiredFeatures) );
@@ -1465,6 +1467,7 @@ WGPU_IMPORT
| BGFX_CAPS_RENDERER_MULTITHREADED
| BGFX_CAPS_SWAP_CHAIN
| BGFX_CAPS_TEXTURE_CUBE_ARRAY
+ | (isFeatureSupported(WGPUFeatureName_ShaderF16) ? BGFX_CAPS_SHADER_F16 : 0)
;
TextureFormatCaps textureFormatCaps;
diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp
index debc20ae3..08790768f 100644
--- a/tools/shaderc/shaderc.cpp
+++ b/tools/shaderc/shaderc.cpp
@@ -281,6 +281,7 @@ namespace bgfx
, backwardsCompatibility(false)
, warningsAreErrors(false)
, keepIntermediate(false)
+ , uses16BitTypes(false)
, optimize(false)
, optimizationLevel(3)
{
@@ -306,6 +307,7 @@ namespace bgfx
"\t backwardsCompatibility: %s\n"
"\t warningsAreErrors: %s\n"
"\t keepIntermediate: %s\n"
+ "\t uses16BitTypes: %s\n"
"\t optimize: %s\n"
"\t optimizationLevel: %d\n"
@@ -326,6 +328,7 @@ namespace bgfx
, backwardsCompatibility ? "true" : "false"
, warningsAreErrors ? "true" : "false"
, keepIntermediate ? "true" : "false"
+ , uses16BitTypes ? "true" : "false"
, optimize ? "true" : "false"
, optimizationLevel
);
@@ -1147,6 +1150,21 @@ namespace bgfx
const Profile* profile = &s_profiles[profileId];
+ if (_options.uses16BitTypes
+ && profile->lang == ShadingLang::Dxil
+ && profile->id < 620)
+ {
+ for (uint32_t ii = 0; ii < BX_COUNTOF(s_profiles); ++ii)
+ {
+ if (s_profiles[ii].lang == ShadingLang::Dxil
+ && s_profiles[ii].id == 620)
+ {
+ profile = &s_profiles[ii];
+ break;
+ }
+ }
+ }
+
// ESSL is compiled as desktop GLSL, and cross-compiled back down to the
// requested ESSL version by SPIR-V Cross. glslang's ESSL front-end is
// far stricter than the desktop one, and ESSL below 3.10 can't be
@@ -1522,6 +1540,12 @@ namespace bgfx
uint32_t outputHash = 0;
bx::ErrorAssert err;
+ if (_options.uses16BitTypes
+ && (profile->lang == ShadingLang::SpirV || profile->lang == ShadingLang::Metal) )
+ {
+ preprocessor.setDefine("float16_t=half");
+ }
+
char* data;
char* input;
{
@@ -1776,6 +1800,14 @@ namespace bgfx
bx::stringPrintf(code, "#version %d\n", glsl_profile);
+ if (!bx::findIdentifierMatch(preprocessor.m_preprocessed.c_str(), "float16_t").isEmpty() )
+ {
+ bx::stringPrintf(code
+ , "#extension GL_AMD_gpu_shader_half_float : enable\n"
+ "#extension GL_NV_gpu_shader5 : enable\n"
+ );
+ }
+
code += _comment;
code += preprocessor.m_preprocessed;
@@ -2334,6 +2366,14 @@ namespace bgfx
);
}
+ if (!bx::findIdentifierMatch(input, "float16_t").isEmpty() )
+ {
+ bx::stringPrintf(code
+ , "#extension GL_AMD_gpu_shader_half_float : enable\n"
+ "#extension GL_NV_gpu_shader5 : enable\n"
+ );
+ }
+
if (!bx::findIdentifierMatch(input, "gl_FragColor").isEmpty() )
{
bx::stringPrintf(code
@@ -2719,6 +2759,8 @@ namespace bgfx
}
}
+ options.uses16BitTypes = !bx::findIdentifierMatch(data, "float16_t").isEmpty();
+
compiled = compileShader(
varying
, commandLineComment.c_str()
diff --git a/tools/shaderc/shaderc.h b/tools/shaderc/shaderc.h
index 1f05d2c63..1ab4f4c5a 100644
--- a/tools/shaderc/shaderc.h
+++ b/tools/shaderc/shaderc.h
@@ -178,6 +178,7 @@ namespace bgfx
bool backwardsCompatibility;
bool warningsAreErrors;
bool keepIntermediate;
+ bool uses16BitTypes;
bool optimize;
uint32_t optimizationLevel;
diff --git a/tools/shaderc/shaderc_dxil.cpp b/tools/shaderc/shaderc_dxil.cpp
index 2b0460729..914333383 100644
--- a/tools/shaderc/shaderc_dxil.cpp
+++ b/tools/shaderc/shaderc_dxil.cpp
@@ -480,18 +480,19 @@ namespace bgfx { namespace dxil
args[numArgs++] = L"-E";
args[numArgs++] = L"main";
+ wchar_t target[] = L"cs_6_0";
+ target[0] = 'f' == _options.shaderType ? L'p'
+ : 'v' == _options.shaderType ? L'v'
+ : L'c'
+ ;
+ target[5] = wchar_t(L'0' + (_version/10)%10);
+
args[numArgs++] = L"-T";
- if ('c' == _options.shaderType)
+ args[numArgs++] = target;
+
+ if (_options.uses16BitTypes)
{
- args[numArgs++] = L"cs_6_0";
- }
- else if ('f' == _options.shaderType)
- {
- args[numArgs++] = L"ps_6_0";
- }
- else if ('v' == _options.shaderType)
- {
- args[numArgs++] = L"vs_6_0";
+ args[numArgs++] = L"-enable-16bit-types";
}
if (_options.warningsAreErrors)
diff --git a/tools/shaderc/shaderc_metal.cpp b/tools/shaderc/shaderc_metal.cpp
index dbafe6344..640922ccb 100644
--- a/tools/shaderc/shaderc_metal.cpp
+++ b/tools/shaderc/shaderc_metal.cpp
@@ -389,6 +389,7 @@ namespace bgfx { namespace metal
| EShMsgVulkanRules
| EShMsgSpvRules
| EShMsgDebugInfo
+ | (_options.uses16BitTypes ? EShMsgHlslEnable16BitTypes : 0)
);
shader->setEntryPoint("main");
diff --git a/tools/shaderc/shaderc_spirv.cpp b/tools/shaderc/shaderc_spirv.cpp
index 49552458d..1738e0105 100644
--- a/tools/shaderc/shaderc_spirv.cpp
+++ b/tools/shaderc/shaderc_spirv.cpp
@@ -483,6 +483,7 @@ namespace bgfx { namespace spirv
| EShMsgVulkanRules
| EShMsgSpvRules
| EShMsgDebugInfo
+ | (_options.uses16BitTypes ? EShMsgHlslEnable16BitTypes : 0)
);
shader->setEntryPoint("main");