diff options
Diffstat (limited to '3rdparty/bgfx/src/renderer_d3d9.h')
-rw-r--r-- | 3rdparty/bgfx/src/renderer_d3d9.h | 104 |
1 files changed, 55 insertions, 49 deletions
diff --git a/3rdparty/bgfx/src/renderer_d3d9.h b/3rdparty/bgfx/src/renderer_d3d9.h index 2aa9b64dcb9..46945e8014f 100644 --- a/3rdparty/bgfx/src/renderer_d3d9.h +++ b/3rdparty/bgfx/src/renderer_d3d9.h @@ -11,21 +11,6 @@ #if BX_PLATFORM_WINDOWS # include <sal.h> # include <d3d9.h> - -#elif BX_PLATFORM_XBOX360 -# include <xgraphics.h> -# define D3DUSAGE_DYNAMIC 0 // not supported on X360 -# define D3DLOCK_DISCARD 0 // not supported on X360 -# define D3DERR_DEVICEHUNG D3DERR_DEVICELOST // not supported on X360 -# define D3DERR_DEVICEREMOVED D3DERR_DEVICELOST // not supported on X360 -# define D3DMULTISAMPLE_8_SAMPLES D3DMULTISAMPLE_4_SAMPLES -# define D3DMULTISAMPLE_16_SAMPLES D3DMULTISAMPLE_4_SAMPLES - -# define D3DFMT_DF24 D3DFMT_D24FS8 - -# define _PIX_SETMARKER(_col, _name) BX_NOOP() -# define _PIX_BEGINEVENT(_col, _name) BX_NOOP() -# define _PIX_ENDEVENT() BX_NOOP #endif // BX_PLATFORM_ #ifndef D3DSTREAMSOURCE_INDEXEDDATA @@ -38,6 +23,7 @@ #include "renderer.h" #include "renderer_d3d.h" +#include "nvapi.h" namespace bgfx { namespace d3d9 { @@ -128,15 +114,21 @@ namespace bgfx { namespace d3d9 { IndexBufferD3D9() : m_ptr(NULL) + , m_dynamic(NULL) , m_size(0) , m_flags(BGFX_BUFFER_NONE) - , m_dynamic(false) { } void create(uint32_t _size, void* _data, uint16_t _flags); void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false) { + if (NULL != m_dynamic + && _data != m_dynamic) + { + bx::memCopy(&m_dynamic[_offset], _data, _size); + } + void* buffer; DX_CHECK(m_ptr->Lock(_offset , _size @@ -154,7 +146,12 @@ namespace bgfx { namespace d3d9 if (NULL != m_ptr) { DX_RELEASE(m_ptr, 0); - m_dynamic = false; + + if (NULL != m_dynamic) + { + BX_FREE(g_allocator, m_dynamic); + m_dynamic = NULL; + } } } @@ -162,22 +159,29 @@ namespace bgfx { namespace d3d9 void postReset(); IDirect3DIndexBuffer9* m_ptr; + uint8_t* m_dynamic; uint32_t m_size; uint16_t m_flags; - bool m_dynamic; }; struct VertexBufferD3D9 { VertexBufferD3D9() : m_ptr(NULL) - , m_dynamic(false) + , m_dynamic(NULL) + , m_size(0) { } void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle); void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false) { + if (NULL != m_dynamic + && _data != m_dynamic) + { + bx::memCopy(&m_dynamic[_offset], _data, _size); + } + void* buffer; DX_CHECK(m_ptr->Lock(_offset , _size @@ -195,7 +199,12 @@ namespace bgfx { namespace d3d9 if (NULL != m_ptr) { DX_RELEASE(m_ptr, 0); - m_dynamic = false; + + if (NULL != m_dynamic) + { + BX_FREE(g_allocator, m_dynamic); + m_dynamic = NULL; + } } } @@ -203,27 +212,9 @@ namespace bgfx { namespace d3d9 void postReset(); IDirect3DVertexBuffer9* m_ptr; + uint8_t* m_dynamic; uint32_t m_size; VertexDeclHandle m_decl; - bool m_dynamic; - }; - - struct VertexDeclD3D9 - { - VertexDeclD3D9() - : m_ptr(NULL) - { - } - - void create(const VertexDecl& _decl); - - void destroy() - { - DX_RELEASE(m_ptr, 0); - } - - IDirect3DVertexDeclaration9* m_ptr; - VertexDecl m_decl; }; struct ShaderD3D9 @@ -429,30 +420,45 @@ namespace bgfx { namespace d3d9 struct TimerQueryD3D9 { TimerQueryD3D9() - : m_control(BX_COUNTOF(m_frame) ) + : m_control(BX_COUNTOF(m_query) ) { } void postReset(); void preReset(); - void begin(); - void end(); - bool get(); + uint32_t begin(uint32_t _resultIdx); + void end(uint32_t _idx); + bool update(); - struct Frame + struct Query { IDirect3DQuery9* m_disjoint; IDirect3DQuery9* m_begin; IDirect3DQuery9* m_end; IDirect3DQuery9* m_freq; + uint32_t m_resultIdx; + bool m_ready; + }; + + struct Result + { + void reset() + { + m_begin = 0; + m_end = 0; + m_frequency = 1; + m_pending = 0; + } + + uint64_t m_begin; + uint64_t m_end; + uint64_t m_frequency; + uint32_t m_pending; }; - uint64_t m_begin; - uint64_t m_end; - uint64_t m_elapsed; - uint64_t m_frequency; + Result m_result[BGFX_CONFIG_MAX_VIEWS+1]; - Frame m_frame[4]; + Query m_query[BGFX_CONFIG_MAX_VIEWS*4]; bx::RingBufferControl m_control; }; |