Added buffer compute format flags.

This commit is contained in:
Branimir Karadžić 2015-05-14 11:37:32 -07:00
parent 65ac7c33f5
commit f5d0a39dd0
11 changed files with 166 additions and 100 deletions

View file

@ -706,7 +706,7 @@ BGFX_C_API void bgfx_dbg_text_image(uint16_t _x, uint16_t _y, uint16_t _width, u
* NOTE: * NOTE:
* Only 16-bit index buffer is supported. * Only 16-bit index buffer is supported.
*/ */
BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t* _mem, uint8_t _flags); BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t* _mem, uint16_t _flags);
/** /**
* Destroy static index buffer. * Destroy static index buffer.
@ -720,7 +720,7 @@ BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle);
* @param _decl Vertex declaration. * @param _decl Vertex declaration.
* @returns Static vertex buffer handle. * @returns Static vertex buffer handle.
*/ */
BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint8_t _flags); BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags);
/** /**
* Destroy static vertex buffer. * Destroy static vertex buffer.
@ -737,7 +737,7 @@ BGFX_C_API void bgfx_destroy_vertex_buffer(bgfx_vertex_buffer_handle_t _handle);
* NOTE: * NOTE:
* Only 16-bit index buffer is supported. * Only 16-bit index buffer is supported.
*/ */
BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(uint32_t _num, uint8_t _flags); BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(uint32_t _num, uint16_t _flags);
/** /**
* Create dynamic index buffer and initialized it. * Create dynamic index buffer and initialized it.
@ -747,7 +747,7 @@ BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(u
* NOTE: * NOTE:
* Only 16-bit index buffer is supported. * Only 16-bit index buffer is supported.
*/ */
BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t* _mem, uint8_t _flags); BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t* _mem, uint16_t _flags);
/** /**
* Update dynamic index buffer. * Update dynamic index buffer.
@ -770,7 +770,7 @@ BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_hand
* @param _num Number of vertices. * @param _num Number of vertices.
* @param _decl Vertex declaration. * @param _decl Vertex declaration.
*/ */
BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl, uint8_t _flags); BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl, uint16_t _flags);
/** /**
* Create dynamic vertex buffer and initialize it. * Create dynamic vertex buffer and initialize it.
@ -778,7 +778,7 @@ BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer
* @param _mem Vertex buffer data. * @param _mem Vertex buffer data.
* @param _decl Vertex declaration. * @param _decl Vertex declaration.
*/ */
BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint8_t _flags); BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags);
/** /**
* Update dynamic vertex buffer. * Update dynamic vertex buffer.

View file

@ -684,7 +684,7 @@ namespace bgfx
/// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
/// index buffers. /// index buffers.
/// ///
IndexBufferHandle createIndexBuffer(const Memory* _mem, uint8_t _flags = BGFX_BUFFER_NONE); IndexBufferHandle createIndexBuffer(const Memory* _mem, uint16_t _flags = BGFX_BUFFER_NONE);
/// Destroy static index buffer. /// Destroy static index buffer.
void destroyIndexBuffer(IndexBufferHandle _handle); void destroyIndexBuffer(IndexBufferHandle _handle);
@ -695,7 +695,7 @@ namespace bgfx
/// @param _decl Vertex declaration. /// @param _decl Vertex declaration.
/// @returns Static vertex buffer handle. /// @returns Static vertex buffer handle.
/// ///
VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint8_t _flags = BGFX_BUFFER_NONE); VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags = BGFX_BUFFER_NONE);
/// Destroy static vertex buffer. /// Destroy static vertex buffer.
/// ///
@ -719,7 +719,7 @@ namespace bgfx
/// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
/// index buffers. /// index buffers.
/// ///
DynamicIndexBufferHandle createDynamicIndexBuffer(uint32_t _num, uint8_t _flags = BGFX_BUFFER_NONE); DynamicIndexBufferHandle createDynamicIndexBuffer(uint32_t _num, uint16_t _flags = BGFX_BUFFER_NONE);
/// Create dynamic index buffer and initialized it. /// Create dynamic index buffer and initialized it.
/// ///
@ -737,7 +737,7 @@ namespace bgfx
/// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
/// index buffers. /// index buffers.
/// ///
DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem, uint8_t _flags = BGFX_BUFFER_NONE); DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem, uint16_t _flags = BGFX_BUFFER_NONE);
/// Update dynamic index buffer. /// Update dynamic index buffer.
/// ///
@ -769,7 +769,7 @@ namespace bgfx
/// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
/// index buffers. /// index buffers.
/// ///
DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint8_t _flags = BGFX_BUFFER_NONE); DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint16_t _flags = BGFX_BUFFER_NONE);
/// Create dynamic vertex buffer and initialize it. /// Create dynamic vertex buffer and initialize it.
/// ///
@ -788,7 +788,7 @@ namespace bgfx
/// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
/// index buffers. /// index buffers.
/// ///
DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint8_t _flags = BGFX_BUFFER_NONE); DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags = BGFX_BUFFER_NONE);
/// Update dynamic vertex buffer. /// Update dynamic vertex buffer.
void updateDynamicVertexBuffer(DynamicVertexBufferHandle _handle, const Memory* _mem); void updateDynamicVertexBuffer(DynamicVertexBufferHandle _handle, const Memory* _mem);

View file

@ -221,12 +221,31 @@
#define BGFX_DEBUG_TEXT UINT32_C(0x00000008) #define BGFX_DEBUG_TEXT UINT32_C(0x00000008)
/// ///
#define BGFX_BUFFER_NONE UINT8_C(0x00) #define BGFX_BUFFER_NONE UINT16_C(0x0000)
#define BGFX_BUFFER_COMPUTE_READ UINT8_C(0x01)
#define BGFX_BUFFER_COMPUTE_WRITE UINT8_C(0x02) #define BGFX_BUFFER_COMPUTE_FORMAT_8x1 UINT16_C(0x0001)
#define BGFX_BUFFER_DRAW_INDIRECT UINT8_C(0x04) #define BGFX_BUFFER_COMPUTE_FORMAT_8x2 UINT16_C(0x0002)
#define BGFX_BUFFER_ALLOW_RESIZE UINT8_C(0x08) #define BGFX_BUFFER_COMPUTE_FORMAT_8x4 UINT16_C(0x0003)
#define BGFX_BUFFER_INDEX32 UINT8_C(0x10) #define BGFX_BUFFER_COMPUTE_FORMAT_16x1 UINT16_C(0x0004)
#define BGFX_BUFFER_COMPUTE_FORMAT_16x2 UINT16_C(0x0005)
#define BGFX_BUFFER_COMPUTE_FORMAT_16x4 UINT16_C(0x0006)
#define BGFX_BUFFER_COMPUTE_FORMAT_32x1 UINT16_C(0x0007)
#define BGFX_BUFFER_COMPUTE_FORMAT_32x2 UINT16_C(0x0008)
#define BGFX_BUFFER_COMPUTE_FORMAT_32x4 UINT16_C(0x0009)
#define BGFX_BUFFER_COMPUTE_FORMAT_SHIFT 0
#define BGFX_BUFFER_COMPUTE_FORMAT_MASK UINT16_C(0x000f)
#define BGFX_BUFFER_COMPUTE_TYPE_UINT UINT16_C(0x0010)
#define BGFX_BUFFER_COMPUTE_TYPE_INT UINT16_C(0x0020)
#define BGFX_BUFFER_COMPUTE_TYPE_FLOAT UINT16_C(0x0030)
#define BGFX_BUFFER_COMPUTE_TYPE_SHIFT 4
#define BGFX_BUFFER_COMPUTE_TYPE_MASK UINT16_C(0x0030)
#define BGFX_BUFFER_COMPUTE_READ UINT16_C(0x0100)
#define BGFX_BUFFER_COMPUTE_WRITE UINT16_C(0x0200)
#define BGFX_BUFFER_DRAW_INDIRECT UINT16_C(0x0400)
#define BGFX_BUFFER_ALLOW_RESIZE UINT16_C(0x0800)
#define BGFX_BUFFER_INDEX32 UINT16_C(0x1000)
#define BGFX_BUFFER_COMPUTE_READ_WRITE (BGFX_BUFFER_COMPUTE_READ | BGFX_BUFFER_COMPUTE_WRITE) #define BGFX_BUFFER_COMPUTE_READ_WRITE (BGFX_BUFFER_COMPUTE_READ | BGFX_BUFFER_COMPUTE_WRITE)
/// ///

View file

@ -1540,7 +1540,7 @@ again:
Memory* mem; Memory* mem;
_cmdbuf.read(mem); _cmdbuf.read(mem);
uint8_t flags; uint16_t flags;
_cmdbuf.read(flags); _cmdbuf.read(flags);
m_renderCtx->createIndexBuffer(handle, mem, flags); m_renderCtx->createIndexBuffer(handle, mem, flags);
@ -1590,7 +1590,7 @@ again:
VertexDeclHandle declHandle; VertexDeclHandle declHandle;
_cmdbuf.read(declHandle); _cmdbuf.read(declHandle);
uint8_t flags; uint16_t flags;
_cmdbuf.read(flags); _cmdbuf.read(flags);
m_renderCtx->createVertexBuffer(handle, mem, declHandle, flags); m_renderCtx->createVertexBuffer(handle, mem, declHandle, flags);
@ -1616,7 +1616,7 @@ again:
uint32_t size; uint32_t size;
_cmdbuf.read(size); _cmdbuf.read(size);
uint8_t flags; uint16_t flags;
_cmdbuf.read(flags); _cmdbuf.read(flags);
m_renderCtx->createDynamicIndexBuffer(handle, size, flags); m_renderCtx->createDynamicIndexBuffer(handle, size, flags);
@ -1660,7 +1660,7 @@ again:
uint32_t size; uint32_t size;
_cmdbuf.read(size); _cmdbuf.read(size);
uint8_t flags; uint16_t flags;
_cmdbuf.read(flags); _cmdbuf.read(flags);
m_renderCtx->createDynamicVertexBuffer(handle, size, flags); m_renderCtx->createDynamicVertexBuffer(handle, size, flags);
@ -2162,7 +2162,7 @@ again:
s_ctx->dbgTextImage(_x, _y, _width, _height, _data, _pitch); s_ctx->dbgTextImage(_x, _y, _width, _height, _data, _pitch);
} }
IndexBufferHandle createIndexBuffer(const Memory* _mem, uint8_t _flags) IndexBufferHandle createIndexBuffer(const Memory* _mem, uint16_t _flags)
{ {
BGFX_CHECK_MAIN_THREAD(); BGFX_CHECK_MAIN_THREAD();
BX_CHECK(NULL != _mem, "_mem can't be NULL"); BX_CHECK(NULL != _mem, "_mem can't be NULL");
@ -2175,7 +2175,7 @@ again:
s_ctx->destroyIndexBuffer(_handle); s_ctx->destroyIndexBuffer(_handle);
} }
VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint8_t _flags) VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags)
{ {
BGFX_CHECK_MAIN_THREAD(); BGFX_CHECK_MAIN_THREAD();
BX_CHECK(NULL != _mem, "_mem can't be NULL"); BX_CHECK(NULL != _mem, "_mem can't be NULL");
@ -2189,13 +2189,13 @@ again:
s_ctx->destroyVertexBuffer(_handle); s_ctx->destroyVertexBuffer(_handle);
} }
DynamicIndexBufferHandle createDynamicIndexBuffer(uint32_t _num, uint8_t _flags) DynamicIndexBufferHandle createDynamicIndexBuffer(uint32_t _num, uint16_t _flags)
{ {
BGFX_CHECK_MAIN_THREAD(); BGFX_CHECK_MAIN_THREAD();
return s_ctx->createDynamicIndexBuffer(_num, _flags); return s_ctx->createDynamicIndexBuffer(_num, _flags);
} }
DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem, uint8_t _flags) DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem, uint16_t _flags)
{ {
BGFX_CHECK_MAIN_THREAD(); BGFX_CHECK_MAIN_THREAD();
BX_CHECK(NULL != _mem, "_mem can't be NULL"); BX_CHECK(NULL != _mem, "_mem can't be NULL");
@ -2215,14 +2215,14 @@ again:
s_ctx->destroyDynamicIndexBuffer(_handle); s_ctx->destroyDynamicIndexBuffer(_handle);
} }
DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint8_t _flags) DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint16_t _flags)
{ {
BGFX_CHECK_MAIN_THREAD(); BGFX_CHECK_MAIN_THREAD();
BX_CHECK(0 != _decl.m_stride, "Invalid VertexDecl."); BX_CHECK(0 != _decl.m_stride, "Invalid VertexDecl.");
return s_ctx->createDynamicVertexBuffer(_num, _decl, _flags); return s_ctx->createDynamicVertexBuffer(_num, _decl, _flags);
} }
DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint8_t _flags) DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags)
{ {
BGFX_CHECK_MAIN_THREAD(); BGFX_CHECK_MAIN_THREAD();
BX_CHECK(NULL != _mem, "_mem can't be NULL"); BX_CHECK(NULL != _mem, "_mem can't be NULL");
@ -3198,7 +3198,7 @@ BGFX_C_API void bgfx_dbg_text_image(uint16_t _x, uint16_t _y, uint16_t _width, u
bgfx::dbgTextImage(_x, _y, _width, _height, _data, _pitch); bgfx::dbgTextImage(_x, _y, _width, _height, _data, _pitch);
} }
BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t* _mem, uint8_t _flags) BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t* _mem, uint16_t _flags)
{ {
union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle; union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle;
handle.cpp = bgfx::createIndexBuffer( (const bgfx::Memory*)_mem, _flags); handle.cpp = bgfx::createIndexBuffer( (const bgfx::Memory*)_mem, _flags);
@ -3211,7 +3211,7 @@ BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle)
bgfx::destroyIndexBuffer(handle.cpp); bgfx::destroyIndexBuffer(handle.cpp);
} }
BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint8_t _flags) BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags)
{ {
const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl; const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle; union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle;
@ -3225,14 +3225,14 @@ BGFX_C_API void bgfx_destroy_vertex_buffer(bgfx_vertex_buffer_handle_t _handle)
bgfx::destroyVertexBuffer(handle.cpp); bgfx::destroyVertexBuffer(handle.cpp);
} }
BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(uint32_t _num, uint8_t _flags) BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(uint32_t _num, uint16_t _flags)
{ {
union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle; union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle;
handle.cpp = bgfx::createDynamicIndexBuffer(_num, _flags); handle.cpp = bgfx::createDynamicIndexBuffer(_num, _flags);
return handle.c; return handle.c;
} }
BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t* _mem, uint8_t _flags) BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t* _mem, uint16_t _flags)
{ {
union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle; union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle;
handle.cpp = bgfx::createDynamicIndexBuffer( (const bgfx::Memory*)_mem, _flags); handle.cpp = bgfx::createDynamicIndexBuffer( (const bgfx::Memory*)_mem, _flags);
@ -3251,7 +3251,7 @@ BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_hand
bgfx::destroyDynamicIndexBuffer(handle.cpp); bgfx::destroyDynamicIndexBuffer(handle.cpp);
} }
BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl, uint8_t _flags) BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl, uint16_t _flags)
{ {
const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl; const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle; union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle;
@ -3259,7 +3259,7 @@ BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer
return handle.c; return handle.c;
} }
BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint8_t _flags) BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags)
{ {
const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl; const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle; union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle;

View file

@ -1185,7 +1185,7 @@ namespace bgfx
uint32_t m_offset; uint32_t m_offset;
uint32_t m_size; uint32_t m_size;
uint32_t m_startIndex; uint32_t m_startIndex;
uint8_t m_flags; uint16_t m_flags;
}; };
struct DynamicVertexBuffer struct DynamicVertexBuffer
@ -1197,7 +1197,7 @@ namespace bgfx
uint32_t m_numVertices; uint32_t m_numVertices;
uint16_t m_stride; uint16_t m_stride;
VertexDeclHandle m_decl; VertexDeclHandle m_decl;
uint8_t m_flags; uint16_t m_flags;
}; };
BX_ALIGN_DECL_CACHE_LINE(struct) Frame BX_ALIGN_DECL_CACHE_LINE(struct) Frame
@ -1847,16 +1847,16 @@ namespace bgfx
virtual RendererType::Enum getRendererType() const = 0; virtual RendererType::Enum getRendererType() const = 0;
virtual const char* getRendererName() const = 0; virtual const char* getRendererName() const = 0;
virtual void flip(HMD& _hmd) = 0; virtual void flip(HMD& _hmd) = 0;
virtual void createIndexBuffer(IndexBufferHandle _handle, Memory* _mem, uint8_t _flags) = 0; virtual void createIndexBuffer(IndexBufferHandle _handle, Memory* _mem, uint16_t _flags) = 0;
virtual void destroyIndexBuffer(IndexBufferHandle _handle) = 0; virtual void destroyIndexBuffer(IndexBufferHandle _handle) = 0;
virtual void createVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl) = 0; virtual void createVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl) = 0;
virtual void destroyVertexDecl(VertexDeclHandle _handle) = 0; virtual void destroyVertexDecl(VertexDeclHandle _handle) = 0;
virtual void createVertexBuffer(VertexBufferHandle _handle, Memory* _mem, VertexDeclHandle _declHandle, uint8_t _flags) = 0; virtual void createVertexBuffer(VertexBufferHandle _handle, Memory* _mem, VertexDeclHandle _declHandle, uint16_t _flags) = 0;
virtual void destroyVertexBuffer(VertexBufferHandle _handle) = 0; virtual void destroyVertexBuffer(VertexBufferHandle _handle) = 0;
virtual void createDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size, uint8_t _flags) = 0; virtual void createDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size, uint16_t _flags) = 0;
virtual void updateDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _offset, uint32_t _size, Memory* _mem) = 0; virtual void updateDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _offset, uint32_t _size, Memory* _mem) = 0;
virtual void destroyDynamicIndexBuffer(IndexBufferHandle _handle) = 0; virtual void destroyDynamicIndexBuffer(IndexBufferHandle _handle) = 0;
virtual void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint8_t _flags) = 0; virtual void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) = 0;
virtual void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, Memory* _mem) = 0; virtual void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, Memory* _mem) = 0;
virtual void destroyDynamicVertexBuffer(VertexBufferHandle _handle) = 0; virtual void destroyDynamicVertexBuffer(VertexBufferHandle _handle) = 0;
virtual void createShader(ShaderHandle _handle, Memory* _mem) = 0; virtual void createShader(ShaderHandle _handle, Memory* _mem) = 0;
@ -1994,7 +1994,7 @@ namespace bgfx
return NULL; return NULL;
} }
BGFX_API_FUNC(IndexBufferHandle createIndexBuffer(const Memory* _mem, uint8_t _flags) ) BGFX_API_FUNC(IndexBufferHandle createIndexBuffer(const Memory* _mem, uint16_t _flags) )
{ {
IndexBufferHandle handle = { m_indexBufferHandle.alloc() }; IndexBufferHandle handle = { m_indexBufferHandle.alloc() };
@ -2035,7 +2035,7 @@ namespace bgfx
return declHandle; return declHandle;
} }
BGFX_API_FUNC(VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint8_t flags) ) BGFX_API_FUNC(VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags) )
{ {
VertexBufferHandle handle = { m_vertexBufferHandle.alloc() }; VertexBufferHandle handle = { m_vertexBufferHandle.alloc() };
@ -2051,7 +2051,7 @@ namespace bgfx
cmdbuf.write(handle); cmdbuf.write(handle);
cmdbuf.write(_mem); cmdbuf.write(_mem);
cmdbuf.write(declHandle); cmdbuf.write(declHandle);
cmdbuf.write(flags); cmdbuf.write(_flags);
} }
return handle; return handle;
@ -2078,7 +2078,7 @@ namespace bgfx
m_vertexBufferHandle.free(_handle.idx); m_vertexBufferHandle.free(_handle.idx);
} }
uint64_t allocDynamicIndexBuffer(uint32_t _size, uint8_t _flags) uint64_t allocDynamicIndexBuffer(uint32_t _size, uint16_t _flags)
{ {
uint64_t ptr = m_dynIndexBufferAllocator.alloc(_size); uint64_t ptr = m_dynIndexBufferAllocator.alloc(_size);
if (ptr == NonLocalAllocator::invalidBlock) if (ptr == NonLocalAllocator::invalidBlock)
@ -2102,7 +2102,7 @@ namespace bgfx
return ptr; return ptr;
} }
BGFX_API_FUNC(DynamicIndexBufferHandle createDynamicIndexBuffer(uint32_t _num, uint8_t _flags) ) BGFX_API_FUNC(DynamicIndexBufferHandle createDynamicIndexBuffer(uint32_t _num, uint16_t _flags) )
{ {
DynamicIndexBufferHandle handle = BGFX_INVALID_HANDLE; DynamicIndexBufferHandle handle = BGFX_INVALID_HANDLE;
const uint32_t indexSize = 0 == (_flags & BGFX_BUFFER_INDEX32) ? 2 : 4; const uint32_t indexSize = 0 == (_flags & BGFX_BUFFER_INDEX32) ? 2 : 4;
@ -2150,7 +2150,7 @@ namespace bgfx
return handle; return handle;
} }
BGFX_API_FUNC(DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem, uint8_t _flags) ) BGFX_API_FUNC(DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem, uint16_t _flags) )
{ {
BX_CHECK(0 == (_flags & BGFX_BUFFER_COMPUTE_READ_WRITE), "Cannot initialize compute buffer from CPU."); BX_CHECK(0 == (_flags & BGFX_BUFFER_COMPUTE_READ_WRITE), "Cannot initialize compute buffer from CPU.");
const uint32_t indexSize = 0 == (_flags & BGFX_BUFFER_INDEX32) ? 2 : 4; const uint32_t indexSize = 0 == (_flags & BGFX_BUFFER_INDEX32) ? 2 : 4;
@ -2227,7 +2227,7 @@ namespace bgfx
m_dynamicIndexBufferHandle.free(_handle.idx); m_dynamicIndexBufferHandle.free(_handle.idx);
} }
uint64_t allocDynamicVertexBuffer(uint32_t _size, uint8_t _flags) uint64_t allocDynamicVertexBuffer(uint32_t _size, uint16_t _flags)
{ {
uint64_t ptr = m_dynVertexBufferAllocator.alloc(_size); uint64_t ptr = m_dynVertexBufferAllocator.alloc(_size);
if (ptr == NonLocalAllocator::invalidBlock) if (ptr == NonLocalAllocator::invalidBlock)
@ -2252,7 +2252,7 @@ namespace bgfx
return ptr; return ptr;
} }
BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint8_t _flags) ) BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint16_t _flags) )
{ {
DynamicVertexBufferHandle handle = BGFX_INVALID_HANDLE; DynamicVertexBufferHandle handle = BGFX_INVALID_HANDLE;
uint32_t size = bx::strideAlign16(_num*_decl.m_stride, _decl.m_stride); uint32_t size = bx::strideAlign16(_num*_decl.m_stride, _decl.m_stride);
@ -2299,7 +2299,7 @@ namespace bgfx
return handle; return handle;
} }
BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint8_t _flags) ) BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags) )
{ {
uint32_t numVertices = _mem->size/_decl.m_stride; uint32_t numVertices = _mem->size/_decl.m_stride;
BX_CHECK(numVertices <= UINT16_MAX, "Num vertices exceeds maximum (num %d, max %d).", numVertices, UINT16_MAX); BX_CHECK(numVertices <= UINT16_MAX, "Num vertices exceeds maximum (num %d, max %d).", numVertices, UINT16_MAX);
@ -2404,7 +2404,8 @@ namespace bgfx
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicIndexBuffer); CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicIndexBuffer);
cmdbuf.write(handle); cmdbuf.write(handle);
cmdbuf.write(_size); cmdbuf.write(_size);
cmdbuf.write(uint8_t(BGFX_BUFFER_NONE) ); uint16_t flags = BGFX_BUFFER_NONE;
cmdbuf.write(flags);
tib = (TransientIndexBuffer*)BX_ALLOC(g_allocator, sizeof(TransientIndexBuffer)+_size); tib = (TransientIndexBuffer*)BX_ALLOC(g_allocator, sizeof(TransientIndexBuffer)+_size);
tib->data = (uint8_t*)&tib[1]; tib->data = (uint8_t*)&tib[1];
@ -2459,7 +2460,8 @@ namespace bgfx
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicVertexBuffer); CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicVertexBuffer);
cmdbuf.write(handle); cmdbuf.write(handle);
cmdbuf.write(_size); cmdbuf.write(_size);
cmdbuf.write(false); uint16_t flags = BGFX_BUFFER_NONE;
cmdbuf.write(flags);
tvb = (TransientVertexBuffer*)BX_ALLOC(g_allocator, sizeof(TransientVertexBuffer)+_size); tvb = (TransientVertexBuffer*)BX_ALLOC(g_allocator, sizeof(TransientVertexBuffer)+_size);
tvb->data = (uint8_t*)&tvb[1]; tvb->data = (uint8_t*)&tvb[1];
@ -2535,8 +2537,8 @@ namespace bgfx
BX_WARN(isValid(handle), "Failed to allocate draw indirect buffer handle."); BX_WARN(isValid(handle), "Failed to allocate draw indirect buffer handle.");
if (isValid(handle) ) if (isValid(handle) )
{ {
uint32_t size = _num * BGFX_CONFIG_DRAW_INDIRECT_STRIDE; uint32_t size = _num * BGFX_CONFIG_DRAW_INDIRECT_STRIDE;
uint8_t flags = BGFX_BUFFER_DRAW_INDIRECT; uint16_t flags = BGFX_BUFFER_DRAW_INDIRECT;
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicVertexBuffer); CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicVertexBuffer);
cmdbuf.write(handle); cmdbuf.write(handle);

View file

@ -1110,7 +1110,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
return BGFX_RENDERER_DIRECT3D11_NAME; return BGFX_RENDERER_DIRECT3D11_NAME;
} }
void createIndexBuffer(IndexBufferHandle _handle, Memory* _mem, uint8_t _flags) BX_OVERRIDE void createIndexBuffer(IndexBufferHandle _handle, Memory* _mem, uint16_t _flags) BX_OVERRIDE
{ {
m_indexBuffers[_handle.idx].create(_mem->size, _mem->data, _flags); m_indexBuffers[_handle.idx].create(_mem->size, _mem->data, _flags);
} }
@ -1131,7 +1131,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{ {
} }
void createVertexBuffer(VertexBufferHandle _handle, Memory* _mem, VertexDeclHandle _declHandle, uint8_t _flags) BX_OVERRIDE void createVertexBuffer(VertexBufferHandle _handle, Memory* _mem, VertexDeclHandle _declHandle, uint16_t _flags) BX_OVERRIDE
{ {
m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags); m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags);
} }
@ -1141,7 +1141,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
m_vertexBuffers[_handle.idx].destroy(); m_vertexBuffers[_handle.idx].destroy();
} }
void createDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size, uint8_t _flags) BX_OVERRIDE void createDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size, uint16_t _flags) BX_OVERRIDE
{ {
m_indexBuffers[_handle.idx].create(_size, NULL, _flags); m_indexBuffers[_handle.idx].create(_size, NULL, _flags);
} }
@ -1156,7 +1156,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
m_indexBuffers[_handle.idx].destroy(); m_indexBuffers[_handle.idx].destroy();
} }
void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint8_t _flags) BX_OVERRIDE void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) BX_OVERRIDE
{ {
VertexDeclHandle decl = BGFX_INVALID_HANDLE; VertexDeclHandle decl = BGFX_INVALID_HANDLE;
m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags); m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags);
@ -1468,7 +1468,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{ {
ovrPreReset(); ovrPreReset();
m_gpuTimer.destroy(); m_gpuTimer.preReset();
if (NULL == g_platformData.backBufferDS) if (NULL == g_platformData.backBufferDS)
{ {
@ -1512,7 +1512,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
DX_RELEASE(color, 0); DX_RELEASE(color, 0);
} }
m_gpuTimer.create(); m_gpuTimer.postReset();
ovrPostReset(); ovrPostReset();
@ -2691,7 +2691,27 @@ BX_PRAGMA_DIAGNOSTIC_POP();
s_renderD3D11 = NULL; s_renderD3D11 = NULL;
} }
void BufferD3D11::create(uint32_t _size, void* _data, uint8_t _flags, uint16_t _stride, bool _vertex) struct UavFormat
{
DXGI_FORMAT format[3];
uint32_t stride;
};
static const UavFormat s_uavFormat[] =
{ // BGFX_BUFFER_COMPUTE_TYPE_UINT, BGFX_BUFFER_COMPUTE_TYPE_INT, BGFX_BUFFER_COMPUTE_TYPE_FLOAT
{ { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, 0 }, // ignored
{ { DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_UNKNOWN }, 1 }, // BGFX_BUFFER_COMPUTE_FORMAT_8x1
{ { DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_UNKNOWN }, 2 }, // BGFX_BUFFER_COMPUTE_FORMAT_8x2
{ { DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_UNKNOWN }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_8x4
{ { DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_FLOAT }, 2 }, // BGFX_BUFFER_COMPUTE_FORMAT_16x1
{ { DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16_FLOAT }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_16x2
{ { DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_FLOAT }, 8 }, // BGFX_BUFFER_COMPUTE_FORMAT_16x4
{ { DXGI_FORMAT_R32_SINT, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_FLOAT }, 4 }, // BGFX_BUFFER_COMPUTE_FORMAT_32x1
{ { DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_FLOAT }, 8 }, // BGFX_BUFFER_COMPUTE_FORMAT_32x2
{ { DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_FLOAT }, 16 }, // BGFX_BUFFER_COMPUTE_FORMAT_32x4
};
void BufferD3D11::create(uint32_t _size, void* _data, uint16_t _flags, uint16_t _stride, bool _vertex)
{ {
m_uav = NULL; m_uav = NULL;
m_size = _size; m_size = _size;
@ -2714,14 +2734,37 @@ BX_PRAGMA_DIAGNOSTIC_POP();
; ;
desc.StructureByteStride = 0; desc.StructureByteStride = 0;
const DXGI_FORMAT indexFormat = 0 == (_flags & BGFX_BUFFER_INDEX32) DXGI_FORMAT format;
? DXGI_FORMAT_R16_UINT uint32_t stride;
: DXGI_FORMAT_R32_UINT
; uint32_t uavFormat = (_flags & BGFX_BUFFER_COMPUTE_FORMAT_MASK) >> BGFX_BUFFER_COMPUTE_FORMAT_SHIFT;
const DXGI_FORMAT format = _vertex if (0 == uavFormat)
? DXGI_FORMAT_R32G32B32A32_FLOAT {
: indexFormat if (_vertex)
; {
format = DXGI_FORMAT_R32G32B32A32_FLOAT;
stride = 16;
}
else
{
if (0 == (_flags & BGFX_BUFFER_INDEX32) )
{
format = DXGI_FORMAT_R16_UINT;
stride = 2;
}
else
{
format = DXGI_FORMAT_R32_UINT;
stride = 4;
}
}
}
else
{
const uint32_t uavType = bx::uint32_satsub( (_flags & BGFX_BUFFER_COMPUTE_TYPE_MASK ) >> BGFX_BUFFER_COMPUTE_TYPE_SHIFT, 1);
format = s_uavFormat[uavFormat].format[uavType];
stride = s_uavFormat[uavFormat].stride;
}
ID3D11Device* device = s_renderD3D11->m_device; ID3D11Device* device = s_renderD3D11->m_device;
@ -2740,7 +2783,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
uavd.Format = format; uavd.Format = format;
uavd.ViewDimension = D3D11_UAV_DIMENSION_BUFFER; uavd.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
uavd.Buffer.FirstElement = 0; uavd.Buffer.FirstElement = 0;
uavd.Buffer.NumElements = m_size / 16; uavd.Buffer.NumElements = m_size / stride;
uavd.Buffer.Flags = 0; uavd.Buffer.Flags = 0;
DX_CHECK(device->CreateUnorderedAccessView(m_ptr DX_CHECK(device->CreateUnorderedAccessView(m_ptr
, &uavd , &uavd
@ -2779,7 +2822,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
srvd.Format = format; srvd.Format = format;
srvd.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; srvd.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
srvd.Buffer.FirstElement = 0; srvd.Buffer.FirstElement = 0;
srvd.Buffer.NumElements = m_size / 16; srvd.Buffer.NumElements = m_size / stride;
DX_CHECK(device->CreateShaderResourceView(m_ptr DX_CHECK(device->CreateShaderResourceView(m_ptr
, &srvd , &srvd
, &m_srv , &m_srv
@ -2841,7 +2884,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
#endif // 0 #endif // 0
} }
void VertexBufferD3D11::create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint8_t _flags) void VertexBufferD3D11::create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint16_t _flags)
{ {
m_decl = _declHandle; m_decl = _declHandle;
uint16_t stride = isValid(_declHandle) uint16_t stride = isValid(_declHandle)
@ -3476,7 +3519,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
} }
} }
void TimerQueryD3D11::create() void TimerQueryD3D11::postReset()
{ {
ID3D11Device* device = s_renderD3D11->m_device; ID3D11Device* device = s_renderD3D11->m_device;
@ -3496,9 +3539,10 @@ BX_PRAGMA_DIAGNOSTIC_POP();
m_elapsed = 0; m_elapsed = 0;
m_frequency = 1; m_frequency = 1;
m_control.reset();
} }
void TimerQueryD3D11::destroy() void TimerQueryD3D11::preReset()
{ {
for (uint32_t ii = 0; ii < BX_COUNTOF(m_frame); ++ii) for (uint32_t ii = 0; ii < BX_COUNTOF(m_frame); ++ii)
{ {
@ -4143,13 +4187,13 @@ BX_PRAGMA_DIAGNOSTIC_POP();
} }
else else
{ {
deviceCtx->IASetVertexBuffers(1, 0, NULL, NULL, NULL); deviceCtx->IASetVertexBuffers(1, 1, s_zero.m_buffer, s_zero.m_zero, s_zero.m_zero);
setInputLayout(vertexDecl, m_program[programIdx], 0); setInputLayout(vertexDecl, m_program[programIdx], 0);
} }
} }
else else
{ {
deviceCtx->IASetVertexBuffers(0, 0, NULL, NULL, NULL); deviceCtx->IASetVertexBuffers(0, 1, s_zero.m_buffer, s_zero.m_zero, s_zero.m_zero);
} }
} }

View file

@ -92,7 +92,7 @@ namespace bgfx { namespace d3d11
{ {
} }
void create(uint32_t _size, void* _data, uint8_t _flags, uint16_t _stride = 0, bool _vertex = false); 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 update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false);
void destroy() void destroy()
@ -111,7 +111,7 @@ namespace bgfx { namespace d3d11
ID3D11ShaderResourceView* m_srv; ID3D11ShaderResourceView* m_srv;
ID3D11UnorderedAccessView* m_uav; ID3D11UnorderedAccessView* m_uav;
uint32_t m_size; uint32_t m_size;
uint8_t m_flags; uint16_t m_flags;
bool m_dynamic; bool m_dynamic;
}; };
@ -124,7 +124,7 @@ namespace bgfx { namespace d3d11
{ {
} }
void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint8_t _flags); void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint16_t _flags);
VertexDeclHandle m_decl; VertexDeclHandle m_decl;
}; };
@ -304,8 +304,8 @@ namespace bgfx { namespace d3d11
{ {
} }
void create(); void postReset();
void destroy(); void preReset();
void begin(); void begin();
void end(); void end();
bool get(); bool get();

View file

@ -686,7 +686,7 @@ namespace bgfx { namespace d3d9
return BGFX_RENDERER_DIRECT3D9_NAME; return BGFX_RENDERER_DIRECT3D9_NAME;
} }
void createIndexBuffer(IndexBufferHandle _handle, Memory* _mem, uint8_t _flags) BX_OVERRIDE void createIndexBuffer(IndexBufferHandle _handle, Memory* _mem, uint16_t _flags) BX_OVERRIDE
{ {
m_indexBuffers[_handle.idx].create(_mem->size, _mem->data, _flags); m_indexBuffers[_handle.idx].create(_mem->size, _mem->data, _flags);
} }
@ -706,7 +706,7 @@ namespace bgfx { namespace d3d9
m_vertexDecls[_handle.idx].destroy(); m_vertexDecls[_handle.idx].destroy();
} }
void createVertexBuffer(VertexBufferHandle _handle, Memory* _mem, VertexDeclHandle _declHandle, uint8_t /*_flags*/) BX_OVERRIDE void createVertexBuffer(VertexBufferHandle _handle, Memory* _mem, VertexDeclHandle _declHandle, uint16_t /*_flags*/) BX_OVERRIDE
{ {
m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle); m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle);
} }
@ -716,7 +716,7 @@ namespace bgfx { namespace d3d9
m_vertexBuffers[_handle.idx].destroy(); m_vertexBuffers[_handle.idx].destroy();
} }
void createDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size, uint8_t _flags) BX_OVERRIDE void createDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size, uint16_t _flags) BX_OVERRIDE
{ {
m_indexBuffers[_handle.idx].create(_size, NULL, _flags); m_indexBuffers[_handle.idx].create(_size, NULL, _flags);
} }
@ -731,7 +731,7 @@ namespace bgfx { namespace d3d9
m_indexBuffers[_handle.idx].destroy(); m_indexBuffers[_handle.idx].destroy();
} }
void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint8_t /*_flags*/) BX_OVERRIDE void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t /*_flags*/) BX_OVERRIDE
{ {
VertexDeclHandle decl = BGFX_INVALID_HANDLE; VertexDeclHandle decl = BGFX_INVALID_HANDLE;
m_vertexBuffers[_handle.idx].create(_size, NULL, decl); m_vertexBuffers[_handle.idx].create(_size, NULL, decl);
@ -1239,7 +1239,7 @@ namespace bgfx { namespace d3d9
capturePreReset(); capturePreReset();
m_gpuTimer.destroy(); m_gpuTimer.preReset();
for (uint32_t ii = 0; ii < BX_COUNTOF(m_indexBuffers); ++ii) for (uint32_t ii = 0; ii < BX_COUNTOF(m_indexBuffers); ++ii)
{ {
@ -1268,7 +1268,7 @@ namespace bgfx { namespace d3d9
DX_CHECK(m_swapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &m_backBufferColor) ); DX_CHECK(m_swapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &m_backBufferColor) );
DX_CHECK(m_device->GetDepthStencilSurface(&m_backBufferDepthStencil) ); DX_CHECK(m_device->GetDepthStencilSurface(&m_backBufferDepthStencil) );
m_gpuTimer.create(); m_gpuTimer.postReset();
capturePostReset(); capturePostReset();
@ -1797,7 +1797,7 @@ namespace bgfx { namespace d3d9
s_renderD3D9 = NULL; s_renderD3D9 = NULL;
} }
void IndexBufferD3D9::create(uint32_t _size, void* _data, uint8_t _flags) void IndexBufferD3D9::create(uint32_t _size, void* _data, uint16_t _flags)
{ {
m_size = _size; m_size = _size;
m_flags = _flags; m_flags = _flags;
@ -2897,7 +2897,7 @@ namespace bgfx { namespace d3d9
) ); ) );
} }
void TimerQueryD3D9::create() void TimerQueryD3D9::postReset()
{ {
IDirect3DDevice9* device = s_renderD3D9->m_device; IDirect3DDevice9* device = s_renderD3D9->m_device;
@ -2912,9 +2912,10 @@ namespace bgfx { namespace d3d9
m_elapsed = 0; m_elapsed = 0;
m_frequency = 1; m_frequency = 1;
m_control.reset();
} }
void TimerQueryD3D9::destroy() void TimerQueryD3D9::preReset()
{ {
for (uint32_t ii = 0; ii < BX_COUNTOF(m_frame); ++ii) for (uint32_t ii = 0; ii < BX_COUNTOF(m_frame); ++ii)
{ {

View file

@ -135,7 +135,7 @@ namespace bgfx { namespace d3d9
{ {
} }
void create(uint32_t _size, void* _data, uint8_t _flags); void create(uint32_t _size, void* _data, uint16_t _flags);
void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false) void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false)
{ {
void* buffer; void* buffer;
@ -164,7 +164,7 @@ namespace bgfx { namespace d3d9
IDirect3DIndexBuffer9* m_ptr; IDirect3DIndexBuffer9* m_ptr;
uint32_t m_size; uint32_t m_size;
uint8_t m_flags; uint16_t m_flags;
bool m_dynamic; bool m_dynamic;
}; };
@ -396,8 +396,8 @@ namespace bgfx { namespace d3d9
{ {
} }
void create(); void postReset();
void destroy(); void preReset();
void begin(); void begin();
void end(); void end();
bool get(); bool get();

View file

@ -1716,7 +1716,7 @@ namespace bgfx { namespace gl
} }
} }
void createIndexBuffer(IndexBufferHandle _handle, Memory* _mem, uint8_t _flags) BX_OVERRIDE void createIndexBuffer(IndexBufferHandle _handle, Memory* _mem, uint16_t _flags) BX_OVERRIDE
{ {
m_indexBuffers[_handle.idx].create(_mem->size, _mem->data, _flags); m_indexBuffers[_handle.idx].create(_mem->size, _mem->data, _flags);
} }
@ -1737,7 +1737,7 @@ namespace bgfx { namespace gl
{ {
} }
void createVertexBuffer(VertexBufferHandle _handle, Memory* _mem, VertexDeclHandle _declHandle, uint8_t _flags) BX_OVERRIDE void createVertexBuffer(VertexBufferHandle _handle, Memory* _mem, VertexDeclHandle _declHandle, uint16_t _flags) BX_OVERRIDE
{ {
m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags); m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle, _flags);
} }
@ -1747,7 +1747,7 @@ namespace bgfx { namespace gl
m_vertexBuffers[_handle.idx].destroy(); m_vertexBuffers[_handle.idx].destroy();
} }
void createDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size, uint8_t _flags) BX_OVERRIDE void createDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size, uint16_t _flags) BX_OVERRIDE
{ {
m_indexBuffers[_handle.idx].create(_size, NULL, _flags); m_indexBuffers[_handle.idx].create(_size, NULL, _flags);
} }
@ -1762,7 +1762,7 @@ namespace bgfx { namespace gl
m_indexBuffers[_handle.idx].destroy(); m_indexBuffers[_handle.idx].destroy();
} }
void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint8_t _flags) BX_OVERRIDE void createDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size, uint16_t _flags) BX_OVERRIDE
{ {
VertexDeclHandle decl = BGFX_INVALID_HANDLE; VertexDeclHandle decl = BGFX_INVALID_HANDLE;
m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags); m_vertexBuffers[_handle.idx].create(_size, NULL, decl, _flags);

View file

@ -869,7 +869,7 @@ namespace bgfx { namespace gl
struct IndexBufferGL struct IndexBufferGL
{ {
void create(uint32_t _size, void* _data, uint8_t _flags) void create(uint32_t _size, void* _data, uint16_t _flags)
{ {
m_size = _size; m_size = _size;
m_flags = _flags; m_flags = _flags;
@ -907,12 +907,12 @@ namespace bgfx { namespace gl
GLuint m_id; GLuint m_id;
uint32_t m_size; uint32_t m_size;
VaoCacheRef m_vcref; VaoCacheRef m_vcref;
uint8_t m_flags; uint16_t m_flags;
}; };
struct VertexBufferGL struct VertexBufferGL
{ {
void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint8_t _flags) void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint16_t _flags)
{ {
m_size = _size; m_size = _size;
m_decl = _declHandle; m_decl = _declHandle;