Added 32-bit texture formats.

This commit is contained in:
Branimir Karadžić 2014-07-21 21:13:16 -07:00
parent 62b620a1a0
commit ade8f49b6d
8 changed files with 183 additions and 36 deletions

View file

@ -26,6 +26,16 @@ typedef enum bgfx_renderer_type
} bgfx_renderer_type_t;
typedef enum bgfx_access
{
BGFX_ACCESS_READ,
BGFX_ACCESS_WRITE,
BGFX_ACCESS_READWRITE,
BGFX_ACCESS_COUNT
} bgfx_access_t;
typedef enum bgfx_attrib
{
BGFX_ATTRIB_POSITION,
@ -82,9 +92,17 @@ typedef enum bgfx_texture_format
BGFX_TEXTURE_FORMAT_R8,
BGFX_TEXTURE_FORMAT_R16,
BGFX_TEXTURE_FORMAT_R16F,
BGFX_TEXTURE_FORMAT_R32,
BGFX_TEXTURE_FORMAT_R32F,
BGFX_TEXTURE_FORMAT_RG16,
BGFX_TEXTURE_FORMAT_RG16F,
BGFX_TEXTURE_FORMAT_RG32,
BGFX_TEXTURE_FORMAT_RG32F,
BGFX_TEXTURE_FORMAT_BGRA8,
BGFX_TEXTURE_FORMAT_RGBA16,
BGFX_TEXTURE_FORMAT_RGBA16F,
BGFX_TEXTURE_FORMAT_RGBA32,
BGFX_TEXTURE_FORMAT_RGBA32F,
BGFX_TEXTURE_FORMAT_R5G6B5,
BGFX_TEXTURE_FORMAT_RGBA4,
BGFX_TEXTURE_FORMAT_RGB5A1,
@ -1284,6 +1302,23 @@ BGFX_C_API uint32_t bgfx_submit(uint8_t _id, int32_t _depth);
*/
BGFX_C_API uint32_t bgfx_submit_mask(uint32_t _viewMask, int32_t _depth);
/**
*
*/
BGFX_C_API void bgfx_set_image(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_texture_format_t _format, bgfx_access_t _access);
/**
*
*/
BGFX_C_API void bgfx_set_image_from_frame_buffer(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, bgfx_texture_format_t _format, bgfx_access_t _access);
/**
* Dispatch compute.
*/
BGFX_C_API void bgfx_dispatch(uint8_t _id, bgfx_program_handle_t _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ);
/**
* Discard all previously set state for draw call.
*/

View file

@ -124,9 +124,17 @@ namespace bgfx
R8,
R16,
R16F,
R32,
R32F,
RG16,
RG16F,
RG32,
RG32F,
BGRA8,
RGBA16,
RGBA16F,
RGBA32,
RGBA32F,
R5G6B5,
RGBA4,
RGB5A1,

View file

@ -3273,6 +3273,26 @@ BGFX_C_API uint32_t bgfx_submit_mask(uint32_t _viewMask, int32_t _depth)
return bgfx::submitMask(_viewMask, _depth);
}
BGFX_C_API void bgfx_set_image(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_texture_format_t _format, bgfx_access_t _access)
{
union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } sampler = { _sampler };
union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
bgfx::setImage(_stage, sampler.cpp, handle.cpp, _mip, bgfx::TextureFormat::Enum(_format), bgfx::Access::Enum(_access) );
}
BGFX_C_API void bgfx_set_image_from_frame_buffer(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, bgfx_texture_format_t _format, bgfx_access_t _access)
{
union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } sampler = { _sampler };
union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
bgfx::setImage(_stage, sampler.cpp, handle.cpp, _attachment, bgfx::TextureFormat::Enum(_format), bgfx::Access::Enum(_access) );
}
BGFX_C_API void bgfx_dispatch(uint8_t _id, bgfx_program_handle_t _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ)
{
union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
bgfx::dispatch(_id, handle.cpp, _numX, _numY, _numZ);
}
BGFX_C_API void bgfx_discard()
{
bgfx::discard();

View file

@ -12,41 +12,49 @@ namespace bgfx
{
static const ImageBlockInfo s_imageBlockInfo[] =
{
{ 4, 4, 4, 8 }, // BC1
{ 8, 4, 4, 16 }, // BC2
{ 8, 4, 4, 16 }, // BC3
{ 4, 4, 4, 8 }, // BC4
{ 8, 4, 4, 16 }, // BC5
{ 4, 4, 4, 8 }, // ETC1
{ 4, 4, 4, 8 }, // ETC2
{ 8, 4, 4, 16 }, // ETC2A
{ 4, 4, 4, 8 }, // ETC2A1
{ 2, 8, 4, 8 }, // PTC12
{ 4, 4, 4, 8 }, // PTC14
{ 2, 8, 4, 8 }, // PTC12A
{ 4, 4, 4, 8 }, // PTC14A
{ 2, 8, 4, 8 }, // PTC22
{ 4, 4, 4, 8 }, // PTC24
{ 0, 0, 0, 0 }, // Unknown
{ 8, 1, 1, 1 }, // R8
{ 16, 1, 1, 2 }, // R16
{ 16, 1, 1, 2 }, // R16F
{ 32, 1, 1, 4 }, // BGRA8
{ 64, 1, 1, 8 }, // RGBA16
{ 64, 1, 1, 8 }, // RGBA16F
{ 16, 1, 1, 2 }, // R5G6B5
{ 16, 1, 1, 2 }, // RGBA4
{ 16, 1, 1, 2 }, // RGB5A1
{ 32, 1, 1, 4 }, // RGB10A2
{ 0, 0, 0, 0 }, // UnknownDepth
{ 16, 1, 1, 2 }, // D16
{ 24, 1, 1, 3 }, // D24
{ 32, 1, 1, 4 }, // D24S8
{ 32, 1, 1, 4 }, // D32
{ 16, 1, 1, 2 }, // D16F
{ 24, 1, 1, 3 }, // D24F
{ 32, 1, 1, 4 }, // D32F
{ 8, 1, 1, 1 }, // D0S8
{ 4, 4, 4, 8 }, // BC1
{ 8, 4, 4, 16 }, // BC2
{ 8, 4, 4, 16 }, // BC3
{ 4, 4, 4, 8 }, // BC4
{ 8, 4, 4, 16 }, // BC5
{ 4, 4, 4, 8 }, // ETC1
{ 4, 4, 4, 8 }, // ETC2
{ 8, 4, 4, 16 }, // ETC2A
{ 4, 4, 4, 8 }, // ETC2A1
{ 2, 8, 4, 8 }, // PTC12
{ 4, 4, 4, 8 }, // PTC14
{ 2, 8, 4, 8 }, // PTC12A
{ 4, 4, 4, 8 }, // PTC14A
{ 2, 8, 4, 8 }, // PTC22
{ 4, 4, 4, 8 }, // PTC24
{ 0, 0, 0, 0 }, // Unknown
{ 8, 1, 1, 1 }, // R8
{ 16, 1, 1, 2 }, // R16
{ 16, 1, 1, 2 }, // R16F
{ 32, 1, 1, 4 }, // R32
{ 32, 1, 1, 4 }, // R32F
{ 32, 1, 1, 4 }, // RG16
{ 32, 1, 1, 4 }, // RG16F
{ 64, 1, 1, 8 }, // RG32
{ 64, 1, 1, 8 }, // RG32F
{ 32, 1, 1, 4 }, // BGRA8
{ 64, 1, 1, 8 }, // RGBA16
{ 64, 1, 1, 8 }, // RGBA16F
{ 128, 1, 1, 16 }, // RGBA32
{ 128, 1, 1, 16 }, // RGBA32F
{ 16, 1, 1, 2 }, // R5G6B5
{ 16, 1, 1, 2 }, // RGBA4
{ 16, 1, 1, 2 }, // RGB5A1
{ 32, 1, 1, 4 }, // RGB10A2
{ 0, 0, 0, 0 }, // UnknownDepth
{ 16, 1, 1, 2 }, // D16
{ 24, 1, 1, 3 }, // D24
{ 32, 1, 1, 4 }, // D24S8
{ 32, 1, 1, 4 }, // D32
{ 16, 1, 1, 2 }, // D16F
{ 24, 1, 1, 3 }, // D24F
{ 32, 1, 1, 4 }, // D32F
{ 8, 1, 1, 1 }, // D0S8
};
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_imageBlockInfo) );
@ -71,9 +79,17 @@ namespace bgfx
"R8", // R8
"R16", // R16
"R16F", // R16F
"R32", // R32
"R32F", // R32F
"RG16", // RG16
"RG16F", // RG16F
"RG32", // RG32
"RG32F", // RG32F
"BGRA8", // BGRA8
"RGBA16", // RGBA16
"RGBA16F", // RGBA16F
"RGBA32", // RGBA32
"RGBA32F", // RGBA32F
"R5G6B5", // R5G6B5
"RGBA4", // RGBA4
"RGB5A1", // RGB5A1

View file

@ -218,9 +218,17 @@ namespace bgfx
{ DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_UNKNOWN }, // R8
{ DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_UNKNOWN }, // R16
{ DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_UNKNOWN }, // R16F
{ DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_UNKNOWN }, // R32
{ DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_UNKNOWN }, // R32F
{ DXGI_FORMAT_R16G16_UNORM, DXGI_FORMAT_R16G16_UNORM, DXGI_FORMAT_UNKNOWN }, // RG16
{ DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_UNKNOWN }, // RG16F
{ DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_UNKNOWN }, // RG32
{ DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_UNKNOWN }, // RG32F
{ DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN }, // BGRA8
{ DXGI_FORMAT_R16G16B16A16_UNORM, DXGI_FORMAT_R16G16B16A16_UNORM, DXGI_FORMAT_UNKNOWN }, // RGBA16
{ DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN }, // RGBA16F
{ DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_UNKNOWN }, // RGBA32
{ DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN }, // RGBA32F
{ DXGI_FORMAT_B5G6R5_UNORM, DXGI_FORMAT_B5G6R5_UNORM, DXGI_FORMAT_UNKNOWN }, // R5G6B5
{ DXGI_FORMAT_B4G4R4A4_UNORM, DXGI_FORMAT_B4G4R4A4_UNORM, DXGI_FORMAT_UNKNOWN }, // RGBA4
{ DXGI_FORMAT_B5G5R5A1_UNORM, DXGI_FORMAT_B5G5R5A1_UNORM, DXGI_FORMAT_UNKNOWN }, // RGB5A1

View file

@ -204,9 +204,17 @@ namespace bgfx
{ D3DFMT_L8 }, // R8
{ D3DFMT_G16R16 }, // R16
{ D3DFMT_R16F }, // R16F
{ D3DFMT_UNKNOWN }, // R32
{ D3DFMT_R32F }, // R32F
{ D3DFMT_G16R16 }, // RG16
{ D3DFMT_G16R16F }, // RG16F
{ D3DFMT_UNKNOWN }, // RG32
{ D3DFMT_G32R32F }, // RG32F
{ D3DFMT_A8R8G8B8 }, // BGRA8
{ D3DFMT_A16B16G16R16 }, // RGBA16
{ D3DFMT_A16B16G16R16F }, // RGBA16F
{ D3DFMT_UNKNOWN }, // RGBA32
{ D3DFMT_A32B32G32R32F }, // RGBA32F
{ D3DFMT_R5G6B5 }, // R5G6B5
{ D3DFMT_A4R4G4B4 }, // RGBA4
{ D3DFMT_A1R5G5B5 }, // RGB5A1

View file

@ -197,9 +197,17 @@ namespace bgfx
{ GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, true }, // R8
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, true }, // R16
{ GL_R16F, GL_RED, GL_HALF_FLOAT, true }, // R16F
{ GL_R32UI, GL_RED, GL_UNSIGNED_INT, true }, // R32
{ GL_R32F, GL_RED, GL_FLOAT, true }, // R32F
{ GL_RG16, GL_RG, GL_UNSIGNED_SHORT, true }, // RG16
{ GL_RG16F, GL_RG, GL_FLOAT, true }, // RG16F
{ GL_RG32UI, GL_RG, GL_UNSIGNED_INT, true }, // RG32
{ GL_RG32F, GL_RG, GL_FLOAT, true }, // RG32F
{ GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, true }, // BGRA8
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_BYTE, true }, // RGBA16
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, true }, // RGBA16F
{ GL_RGBA32UI, GL_RGBA, GL_UNSIGNED_INT, true }, // RGBA32
{ GL_RGBA32F, GL_RGBA, GL_FLOAT, true }, // RGBA32F
{ GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, true }, // R5G6B5
{ GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, true }, // RGBA4
{ GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, true }, // RGB5A1
@ -237,9 +245,17 @@ namespace bgfx
GL_R8, // R8
GL_R16, // R16
GL_R16F, // R16F
GL_R32UI, // R32
GL_R32F, // R32F
GL_RG16, // RG16
GL_RG16F, // RG16F
GL_RG32UI, // RG32
GL_RG32F, // RG32F
GL_RGBA8, // BGRA8
GL_RGBA16, // RGBA16
GL_RGBA16, // RGBA16F
GL_RGBA16F, // RGBA16F
GL_RGBA32UI, // RGBA32
GL_RGBA32F, // RGBA32F
GL_RGB565, // R5G6B5
GL_RGBA4, // RGBA4
GL_RGB5_A1, // RGB5A1

View file

@ -107,10 +107,42 @@ typedef uint64_t GLuint64;
# define GL_R16F 0x822D
#endif // GL_R16F
#ifndef GL_R32UI
# define GL_R32UI 0x8236
#endif // GL_R32UI
#ifndef GL_R32F
# define GL_R32F 0x822E
#endif // GL_R32F
#ifndef GL_RG16
# define GL_RG16 0x822C
#endif // GL_RG16
#ifndef GL_RG16F
# define GL_RG16F 0x822F
#endif // GL_RG16F
#ifndef GL_R32UI
# define GL_R32UI 0x8236
#endif // GL_R32UI
#ifndef GL_RG32UI
# define GL_RG32UI 0x823C
#endif // GL_RG32UI
#ifndef GL_RG32F
# define GL_RG32F 0x8230
#endif // GL_RG32F
#ifndef GL_RGBA32UI
# define GL_RGBA32UI 0x8D70
#endif // GL_RGBA32UI
#ifndef GL_RGBA32F
# define GL_RGBA32F 0x8814
#endif // GL_RGBA32F
#ifndef GL_RED
# define GL_RED 0x1903
#endif // GL_RED
@ -119,6 +151,10 @@ typedef uint64_t GLuint64;
# define GL_RED_INTEGER 0x8D94
#endif // GL_RED_INTEGER
#ifndef GL_RG
# define GL_RG 0x8227
#endif // GL_RG
#ifndef GL_GREEN
# define GL_GREEN 0x1904
#endif // GL_GREEN