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:
kingscallop
2020-10-05 05:51:41 +01:00
committed by GitHub
parent 32aa281147
commit 436b7fab9e
22 changed files with 587 additions and 259 deletions

View File

@@ -371,7 +371,7 @@ flag.Caps { bits = 64, base = 1, name = "Caps" }
.DrawIndirect --- Draw indirect is supported.
.FragmentDepth --- Fragment depth is accessible in fragment shader.
.FragmentOrdering --- Fragment ordering is available in fragment shader.
.FramebufferRw --- Read/Write frame buffer attachments are supported.
.ImageRw --- Image Read/Write is supported.
.GraphicsDebugger --- Graphics debugger is present.
.Reserved
.Hdr10 --- HDR10 rendering is supported.
@@ -395,7 +395,7 @@ flag.Caps { bits = 64, base = 1, name = "Caps" }
.TextureCompareAll { "TextureCompareReserved", "TextureCompareLequal" } --- All texture compare modes are supported.
()
flag.CapsFormat { bits = 16 }
flag.CapsFormat { bits = 32 }
.TextureNone --- Texture format is not supported.
.Texture_2d --- Texture format is supported.
.Texture_2dSrgb --- Texture as sRGB format is supported.
@@ -407,7 +407,8 @@ flag.CapsFormat { bits = 16 }
.TextureCubeSrgb --- Texture as sRGB format is supported.
.TextureCubeEmulated --- Texture format is emulated.
.TextureVertex --- Texture format can be used from vertex shader.
.TextureImage --- Texture format can be used as image from compute shader.
.TextureImageRead --- Texture format can be used as image and read from.
.TextureImageWrite --- Texture format can be used as image and written to.
.TextureFramebuffer --- Texture format can be used as frame buffer.
.TextureFramebufferMsaa --- Texture format can be used as MSAA frame buffer.
.TextureMsaa --- Texture can be sampled as MSAA.
@@ -728,8 +729,10 @@ struct.Caps
--- - `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