mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Adds UAV support for D3D12, Vulkan and reworked for OpenGL, D3D11 (#2119)
* Adds UAV support for D3D12, Vulkan and reworked support for OpenGL, D3D11 UAV support is now uniform across compute and draw. To set a UAV you just use bgfx::setImage() and IMAGE2D in the shader, just like in compute. Due to these changes shaders will have to be recompiled. The changes include: - D3D11 requires patching of the UAV slot number (which is now done by modifying the DXBC instead of using a macro) - If the DXBC binary includes a debug chunk, that is also patched to match the new slot number - All the other renderers don't need any kind of patching - There are some shader annotations to better convert the UAV format used in hlsl to spirv Possibility of further enhancements: - bgfx::setViewFrameBuffer() only supports binding to a framebuffer or, using BGFX_INVALID_HANDLE, to bind the default backbuffer. This doesn't allow for the case where there is no need to bind to either one of them, for example when using a fragment shader only to read and write to an UAV. * Bump shader version, because they need to be recompiled.
This commit is contained in:
@@ -1041,9 +1041,9 @@ public static partial class bgfx
|
||||
FragmentOrdering = 0x0000000000000040,
|
||||
|
||||
/// <summary>
|
||||
/// Read/Write frame buffer attachments are supported.
|
||||
/// Image Read/Write is supported.
|
||||
/// </summary>
|
||||
FramebufferRw = 0x0000000000000080,
|
||||
ImageRw = 0x0000000000000080,
|
||||
|
||||
/// <summary>
|
||||
/// Graphics debugger is present.
|
||||
@@ -1148,87 +1148,92 @@ public static partial class bgfx
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum CapsFormatFlags : ushort
|
||||
public enum CapsFormatFlags : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Texture format is not supported.
|
||||
/// </summary>
|
||||
TextureNone = 0x0000,
|
||||
TextureNone = 0x00000000,
|
||||
|
||||
/// <summary>
|
||||
/// Texture format is supported.
|
||||
/// </summary>
|
||||
Texture2d = 0x0001,
|
||||
Texture2d = 0x00000001,
|
||||
|
||||
/// <summary>
|
||||
/// Texture as sRGB format is supported.
|
||||
/// </summary>
|
||||
Texture2dSrgb = 0x0002,
|
||||
Texture2dSrgb = 0x00000002,
|
||||
|
||||
/// <summary>
|
||||
/// Texture format is emulated.
|
||||
/// </summary>
|
||||
Texture2dEmulated = 0x0004,
|
||||
Texture2dEmulated = 0x00000004,
|
||||
|
||||
/// <summary>
|
||||
/// Texture format is supported.
|
||||
/// </summary>
|
||||
Texture3d = 0x0008,
|
||||
Texture3d = 0x00000008,
|
||||
|
||||
/// <summary>
|
||||
/// Texture as sRGB format is supported.
|
||||
/// </summary>
|
||||
Texture3dSrgb = 0x0010,
|
||||
Texture3dSrgb = 0x00000010,
|
||||
|
||||
/// <summary>
|
||||
/// Texture format is emulated.
|
||||
/// </summary>
|
||||
Texture3dEmulated = 0x0020,
|
||||
Texture3dEmulated = 0x00000020,
|
||||
|
||||
/// <summary>
|
||||
/// Texture format is supported.
|
||||
/// </summary>
|
||||
TextureCube = 0x0040,
|
||||
TextureCube = 0x00000040,
|
||||
|
||||
/// <summary>
|
||||
/// Texture as sRGB format is supported.
|
||||
/// </summary>
|
||||
TextureCubeSrgb = 0x0080,
|
||||
TextureCubeSrgb = 0x00000080,
|
||||
|
||||
/// <summary>
|
||||
/// Texture format is emulated.
|
||||
/// </summary>
|
||||
TextureCubeEmulated = 0x0100,
|
||||
TextureCubeEmulated = 0x00000100,
|
||||
|
||||
/// <summary>
|
||||
/// Texture format can be used from vertex shader.
|
||||
/// </summary>
|
||||
TextureVertex = 0x0200,
|
||||
TextureVertex = 0x00000200,
|
||||
|
||||
/// <summary>
|
||||
/// Texture format can be used as image from compute shader.
|
||||
/// Texture format can be used as image and read from.
|
||||
/// </summary>
|
||||
TextureImage = 0x0400,
|
||||
TextureImageRead = 0x00000400,
|
||||
|
||||
/// <summary>
|
||||
/// Texture format can be used as image and written to.
|
||||
/// </summary>
|
||||
TextureImageWrite = 0x00000800,
|
||||
|
||||
/// <summary>
|
||||
/// Texture format can be used as frame buffer.
|
||||
/// </summary>
|
||||
TextureFramebuffer = 0x0800,
|
||||
TextureFramebuffer = 0x00001000,
|
||||
|
||||
/// <summary>
|
||||
/// Texture format can be used as MSAA frame buffer.
|
||||
/// </summary>
|
||||
TextureFramebufferMsaa = 0x1000,
|
||||
TextureFramebufferMsaa = 0x00002000,
|
||||
|
||||
/// <summary>
|
||||
/// Texture can be sampled as MSAA.
|
||||
/// </summary>
|
||||
TextureMsaa = 0x2000,
|
||||
TextureMsaa = 0x00004000,
|
||||
|
||||
/// <summary>
|
||||
/// Texture format supports auto-generated mips.
|
||||
/// </summary>
|
||||
TextureMipAutogen = 0x4000,
|
||||
TextureMipAutogen = 0x00008000,
|
||||
}
|
||||
|
||||
[Flags]
|
||||
|
||||
@@ -354,7 +354,7 @@ enum ulong BGFX_CAPS_CONSERVATIVE_RASTER = 0x0000000000000008; /// Conservative
|
||||
enum ulong BGFX_CAPS_DRAW_INDIRECT = 0x0000000000000010; /// Draw indirect is supported.
|
||||
enum ulong BGFX_CAPS_FRAGMENT_DEPTH = 0x0000000000000020; /// Fragment depth is accessible in fragment shader.
|
||||
enum ulong BGFX_CAPS_FRAGMENT_ORDERING = 0x0000000000000040; /// Fragment ordering is available in fragment shader.
|
||||
enum ulong BGFX_CAPS_FRAMEBUFFER_RW = 0x0000000000000080; /// Read/Write frame buffer attachments are supported.
|
||||
enum ulong BGFX_CAPS_IMAGE_RW = 0x0000000000000080; /// Image Read/Write is supported.
|
||||
enum ulong BGFX_CAPS_GRAPHICS_DEBUGGER = 0x0000000000000100; /// Graphics debugger is present.
|
||||
enum ulong BGFX_CAPS_RESERVED = 0x0000000000000200;
|
||||
enum ulong BGFX_CAPS_HDR10 = 0x0000000000000400; /// HDR10 rendering is supported.
|
||||
@@ -377,22 +377,23 @@ enum ulong BGFX_CAPS_VERTEX_ATTRIB_UINT10 = 0x0000000004000000; /// Vertex attri
|
||||
enum ulong BGFX_CAPS_VERTEX_ID = 0x0000000008000000; /// Rendering with VertexID only is supported.
|
||||
enum ulong BGFX_CAPS_TEXTURE_COMPARE_ALL = 0x0000000000300000; /// All texture compare modes are supported.
|
||||
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_NONE = 0x0000; /// Texture format is not supported.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_2D = 0x0001; /// Texture format is supported.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB = 0x0002; /// Texture as sRGB format is supported.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED = 0x0004; /// Texture format is emulated.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_3D = 0x0008; /// Texture format is supported.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB = 0x0010; /// Texture as sRGB format is supported.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED = 0x0020; /// Texture format is emulated.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_CUBE = 0x0040; /// Texture format is supported.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB = 0x0080; /// Texture as sRGB format is supported.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED = 0x0100; /// Texture format is emulated.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_VERTEX = 0x0200; /// Texture format can be used from vertex shader.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_IMAGE = 0x0400; /// Texture format can be used as image from compute shader.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER = 0x0800; /// Texture format can be used as frame buffer.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA = 0x1000; /// Texture format can be used as MSAA frame buffer.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_MSAA = 0x2000; /// Texture can be sampled as MSAA.
|
||||
enum ushort BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN = 0x4000; /// Texture format supports auto-generated mips.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_NONE = 0x00000000; /// Texture format is not supported.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_2D = 0x00000001; /// Texture format is supported.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB = 0x00000002; /// Texture as sRGB format is supported.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED = 0x00000004; /// Texture format is emulated.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_3D = 0x00000008; /// Texture format is supported.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB = 0x00000010; /// Texture as sRGB format is supported.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED = 0x00000020; /// Texture format is emulated.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_CUBE = 0x00000040; /// Texture format is supported.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB = 0x00000080; /// Texture as sRGB format is supported.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED = 0x00000100; /// Texture format is emulated.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_VERTEX = 0x00000200; /// Texture format can be used from vertex shader.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ = 0x00000400; /// Texture format can be used as image and read from.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_IMAGE_WRITE = 0x00000800; /// Texture format can be used as image and written to.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER = 0x00001000; /// Texture format can be used as frame buffer.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA = 0x00002000; /// Texture format can be used as MSAA frame buffer.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_MSAA = 0x00004000; /// Texture can be sampled as MSAA.
|
||||
enum uint BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN = 0x00008000; /// Texture format supports auto-generated mips.
|
||||
|
||||
enum ubyte BGFX_RESOLVE_NONE = 0x00; /// No resolve flags.
|
||||
enum ubyte BGFX_RESOLVE_AUTO_GEN_MIPS = 0x01; /// Auto-generate mip maps on resolve.
|
||||
@@ -759,8 +760,10 @@ struct bgfx_caps_t
|
||||
* - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB` - Texture as sRGB format is supported.
|
||||
* - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED` - Texture format is emulated.
|
||||
* - `BGFX_CAPS_FORMAT_TEXTURE_VERTEX` - Texture format can be used from vertex shader.
|
||||
* - `BGFX_CAPS_FORMAT_TEXTURE_IMAGE` - Texture format can be used as image from compute
|
||||
* shader.
|
||||
* - `BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ` - Texture format can be used as image
|
||||
* and read from.
|
||||
* - `BGFX_CAPS_FORMAT_TEXTURE_IMAGE_WRITE` - Texture format can be used as image
|
||||
* and written to.
|
||||
* - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER` - Texture format can be used as frame
|
||||
* buffer.
|
||||
* - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA` - Texture format can be used as MSAA
|
||||
|
||||
Reference in New Issue
Block a user