DX11 stuff wip.
This commit is contained in:
parent
a30a7d4346
commit
7adf1f6dc2
80
src/bgfx.cpp
80
src/bgfx.cpp
@ -37,7 +37,7 @@ namespace bgfx
|
|||||||
# define BGFX_RENDER_THREAD()
|
# define BGFX_RENDER_THREAD()
|
||||||
#endif // BGFX_CONFIG_MULTITHREADED
|
#endif // BGFX_CONFIG_MULTITHREADED
|
||||||
|
|
||||||
void fatalStub(bgfx::Fatal::Enum _code, const char* _str)
|
void fatalStub(Fatal::Enum _code, const char* _str)
|
||||||
{
|
{
|
||||||
BX_TRACE("0x%08x: %s", _code, _str);
|
BX_TRACE("0x%08x: %s", _code, _str);
|
||||||
BX_UNUSED(_code);
|
BX_UNUSED(_code);
|
||||||
@ -71,7 +71,7 @@ namespace bgfx
|
|||||||
static BX_THREAD uint32_t s_threadIndex = 0;
|
static BX_THREAD uint32_t s_threadIndex = 0;
|
||||||
static Context s_ctx;
|
static Context s_ctx;
|
||||||
|
|
||||||
void fatal(bgfx::Fatal::Enum _code, const char* _format, ...)
|
void fatal(Fatal::Enum _code, const char* _format, ...)
|
||||||
{
|
{
|
||||||
char temp[8192];
|
char temp[8192];
|
||||||
|
|
||||||
@ -198,10 +198,10 @@ namespace bgfx
|
|||||||
void TextVideoMemBlitter::init()
|
void TextVideoMemBlitter::init()
|
||||||
{
|
{
|
||||||
m_decl.begin();
|
m_decl.begin();
|
||||||
m_decl.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float);
|
m_decl.add(Attrib::Position, 3, AttribType::Float);
|
||||||
m_decl.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true);
|
m_decl.add(Attrib::Color0, 4, AttribType::Uint8, true);
|
||||||
m_decl.add(bgfx::Attrib::Color1, 4, bgfx::AttribType::Uint8, true);
|
m_decl.add(Attrib::Color1, 4, AttribType::Uint8, true);
|
||||||
m_decl.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float);
|
m_decl.add(Attrib::TexCoord0, 2, AttribType::Float);
|
||||||
m_decl.end();
|
m_decl.end();
|
||||||
|
|
||||||
uint16_t width = 2048;
|
uint16_t width = 2048;
|
||||||
@ -209,7 +209,7 @@ namespace bgfx
|
|||||||
uint8_t bpp = 1;
|
uint8_t bpp = 1;
|
||||||
uint32_t pitch = width*bpp;
|
uint32_t pitch = width*bpp;
|
||||||
|
|
||||||
const bgfx::Memory* mem;
|
const Memory* mem;
|
||||||
|
|
||||||
mem = alloc(pitch*height+16);
|
mem = alloc(pitch*height+16);
|
||||||
|
|
||||||
@ -228,32 +228,32 @@ namespace bgfx
|
|||||||
m_texture = s_ctx.createTexture(mem, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT, NULL, NULL);
|
m_texture = s_ctx.createTexture(mem, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT, NULL, NULL);
|
||||||
|
|
||||||
#if BGFX_CONFIG_RENDERER_DIRECT3D9
|
#if BGFX_CONFIG_RENDERER_DIRECT3D9
|
||||||
mem = bgfx::alloc(sizeof(vs_debugfont_dx9)+1);
|
mem = alloc(sizeof(vs_debugfont_dx9)+1);
|
||||||
memcpy(mem->data, vs_debugfont_dx9, mem->size-1);
|
memcpy(mem->data, vs_debugfont_dx9, mem->size-1);
|
||||||
#elif BGFX_CONFIG_RENDERER_DIRECT3D11
|
#elif BGFX_CONFIG_RENDERER_DIRECT3D11
|
||||||
mem = bgfx::alloc(sizeof(vs_debugfont_dx11)+1);
|
mem = alloc(sizeof(vs_debugfont_dx11)+1);
|
||||||
memcpy(mem->data, vs_debugfont_dx11, mem->size-1);
|
memcpy(mem->data, vs_debugfont_dx11, mem->size-1);
|
||||||
#else
|
#else
|
||||||
mem = bgfx::alloc(sizeof(vs_debugfont_glsl)+1);
|
mem = alloc(sizeof(vs_debugfont_glsl)+1);
|
||||||
memcpy(mem->data, vs_debugfont_glsl, mem->size-1);
|
memcpy(mem->data, vs_debugfont_glsl, mem->size-1);
|
||||||
#endif // BGFX_CONFIG_RENDERER_
|
#endif // BGFX_CONFIG_RENDERER_
|
||||||
mem->data[mem->size-1] = '\0';
|
mem->data[mem->size-1] = '\0';
|
||||||
bgfx::VertexShaderHandle vsh = bgfx::createVertexShader(mem);
|
VertexShaderHandle vsh = createVertexShader(mem);
|
||||||
|
|
||||||
#if BGFX_CONFIG_RENDERER_DIRECT3D9
|
#if BGFX_CONFIG_RENDERER_DIRECT3D9
|
||||||
mem = bgfx::alloc(sizeof(fs_debugfont_dx9)+1);
|
mem = alloc(sizeof(fs_debugfont_dx9)+1);
|
||||||
memcpy(mem->data, fs_debugfont_dx9, mem->size-1);
|
memcpy(mem->data, fs_debugfont_dx9, mem->size-1);
|
||||||
#elif BGFX_CONFIG_RENDERER_DIRECT3D11
|
#elif BGFX_CONFIG_RENDERER_DIRECT3D11
|
||||||
mem = bgfx::alloc(sizeof(fs_debugfont_dx11)+1);
|
mem = alloc(sizeof(fs_debugfont_dx11)+1);
|
||||||
memcpy(mem->data, fs_debugfont_dx11, mem->size-1);
|
memcpy(mem->data, fs_debugfont_dx11, mem->size-1);
|
||||||
#else
|
#else
|
||||||
mem = bgfx::alloc(sizeof(fs_debugfont_glsl)+1);
|
mem = alloc(sizeof(fs_debugfont_glsl)+1);
|
||||||
memcpy(mem->data, fs_debugfont_glsl, mem->size-1);
|
memcpy(mem->data, fs_debugfont_glsl, mem->size-1);
|
||||||
#endif // BGFX_CONFIG_RENDERER_
|
#endif // BGFX_CONFIG_RENDERER_
|
||||||
mem->data[mem->size-1] = '\0';
|
mem->data[mem->size-1] = '\0';
|
||||||
bgfx::FragmentShaderHandle fsh = bgfx::createFragmentShader(mem);
|
FragmentShaderHandle fsh = createFragmentShader(mem);
|
||||||
|
|
||||||
m_material = bgfx::createMaterial(vsh, fsh);
|
m_material = createMaterial(vsh, fsh);
|
||||||
|
|
||||||
m_vb = s_ctx.createTransientVertexBuffer(numBatchVertices*m_decl.m_stride, &m_decl);
|
m_vb = s_ctx.createTransientVertexBuffer(numBatchVertices*m_decl.m_stride, &m_decl);
|
||||||
m_ib = s_ctx.createTransientIndexBuffer(numBatchIndices*2);
|
m_ib = s_ctx.createTransientIndexBuffer(numBatchIndices*2);
|
||||||
@ -261,7 +261,7 @@ namespace bgfx
|
|||||||
|
|
||||||
void TextVideoMemBlitter::blit(const TextVideoMem& _mem)
|
void TextVideoMemBlitter::blit(const TextVideoMem& _mem)
|
||||||
{
|
{
|
||||||
struct FontVertex
|
struct Vertex
|
||||||
{
|
{
|
||||||
float m_x;
|
float m_x;
|
||||||
float m_y;
|
float m_y;
|
||||||
@ -307,7 +307,7 @@ namespace bgfx
|
|||||||
|
|
||||||
for (;yy < _mem.m_height;)
|
for (;yy < _mem.m_height;)
|
||||||
{
|
{
|
||||||
FontVertex* vertex = (FontVertex*)m_vb->data;
|
Vertex* vertex = (Vertex*)m_vb->data;
|
||||||
uint16_t* indices = (uint16_t*)m_ib->data;
|
uint16_t* indices = (uint16_t*)m_ib->data;
|
||||||
uint32_t startVertex = 0;
|
uint32_t startVertex = 0;
|
||||||
uint32_t numIndices = 0;
|
uint32_t numIndices = 0;
|
||||||
@ -328,7 +328,7 @@ namespace bgfx
|
|||||||
uint32_t fg = palette[attr&0xf];
|
uint32_t fg = palette[attr&0xf];
|
||||||
uint32_t bg = palette[(attr>>4)&0xf];
|
uint32_t bg = palette[(attr>>4)&0xf];
|
||||||
|
|
||||||
FontVertex vert[4] =
|
Vertex vert[4] =
|
||||||
{
|
{
|
||||||
{ (xx )*8.0f, (yy )*fontHeight, 0.0f, fg, bg, (ch )*8.0f*texelWidth - texelWidthHalf, utop },
|
{ (xx )*8.0f, (yy )*fontHeight, 0.0f, fg, bg, (ch )*8.0f*texelWidth - texelWidthHalf, utop },
|
||||||
{ (xx+1)*8.0f, (yy )*fontHeight, 0.0f, fg, bg, (ch+1)*8.0f*texelWidth - texelWidthHalf, utop },
|
{ (xx+1)*8.0f, (yy )*fontHeight, 0.0f, fg, bg, (ch+1)*8.0f*texelWidth - texelWidthHalf, utop },
|
||||||
@ -365,6 +365,41 @@ namespace bgfx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClearQuad::init()
|
||||||
|
{
|
||||||
|
#if BGFX_CONFIG_RENDERER_DIRECT3D11
|
||||||
|
m_decl.begin();
|
||||||
|
m_decl.add(Attrib::Position, 3, AttribType::Float);
|
||||||
|
m_decl.add(Attrib::Color0, 4, AttribType::Uint8, true);
|
||||||
|
m_decl.end();
|
||||||
|
|
||||||
|
const Memory* mem;
|
||||||
|
|
||||||
|
mem = alloc(sizeof(vs_clear_dx11)+1);
|
||||||
|
memcpy(mem->data, vs_clear_dx11, mem->size-1);
|
||||||
|
VertexShaderHandle vsh = createVertexShader(mem);
|
||||||
|
|
||||||
|
mem = alloc(sizeof(fs_clear_dx11)+1);
|
||||||
|
memcpy(mem->data, fs_clear_dx11, mem->size-1);
|
||||||
|
FragmentShaderHandle fsh = createFragmentShader(mem);
|
||||||
|
|
||||||
|
m_material = createMaterial(vsh, fsh);
|
||||||
|
|
||||||
|
m_vb = s_ctx.createTransientVertexBuffer(4*m_decl.m_stride, &m_decl);
|
||||||
|
|
||||||
|
mem = alloc(6*sizeof(uint16_t) );
|
||||||
|
uint16_t* indices = (uint16_t*)mem->data;
|
||||||
|
indices[0] = 0;
|
||||||
|
indices[1] = 1;
|
||||||
|
indices[2] = 2;
|
||||||
|
indices[3] = 2;
|
||||||
|
indices[4] = 3;
|
||||||
|
indices[5] = 0;
|
||||||
|
m_ib = s_ctx.createIndexBuffer(mem);
|
||||||
|
|
||||||
|
#endif // BGFX_CONFIG_RENDERER_DIRECT3D11
|
||||||
|
}
|
||||||
|
|
||||||
static const char* s_predefinedName[PredefinedUniform::Count] =
|
static const char* s_predefinedName[PredefinedUniform::Count] =
|
||||||
{
|
{
|
||||||
"u_viewRect",
|
"u_viewRect",
|
||||||
@ -691,11 +726,18 @@ namespace bgfx
|
|||||||
memset(m_seq, 0, sizeof(m_seq) );
|
memset(m_seq, 0, sizeof(m_seq) );
|
||||||
memset(m_seqMask, 0, sizeof(m_seqMask) );
|
memset(m_seqMask, 0, sizeof(m_seqMask) );
|
||||||
|
|
||||||
|
for (uint32_t ii = 0; ii < countof(m_rect); ++ii)
|
||||||
|
{
|
||||||
|
m_rect[ii].m_width = 1;
|
||||||
|
m_rect[ii].m_height = 1;
|
||||||
|
}
|
||||||
|
|
||||||
gameSemPost();
|
gameSemPost();
|
||||||
|
|
||||||
getCommandBuffer(CommandBuffer::RendererInit);
|
getCommandBuffer(CommandBuffer::RendererInit);
|
||||||
|
|
||||||
m_textVideoMemBlitter.init();
|
m_textVideoMemBlitter.init();
|
||||||
|
m_clearQuad.init();
|
||||||
|
|
||||||
m_submit->m_transientVb = createTransientVertexBuffer(BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE);
|
m_submit->m_transientVb = createTransientVertexBuffer(BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE);
|
||||||
m_submit->m_transientIb = createTransientIndexBuffer(BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE);
|
m_submit->m_transientIb = createTransientIndexBuffer(BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE);
|
||||||
|
90
src/bgfx_p.h
90
src/bgfx_p.h
@ -47,14 +47,15 @@ extern void dbgPrintfData(const void* _data, uint32_t _size, const char* _format
|
|||||||
|
|
||||||
#define BX_NAMESPACE 1
|
#define BX_NAMESPACE 1
|
||||||
#include <bx/bx.h>
|
#include <bx/bx.h>
|
||||||
#include <bx/countof.h>
|
|
||||||
#include <bx/debug.h>
|
#include <bx/debug.h>
|
||||||
#include <bx/blockalloc.h>
|
#include <bx/blockalloc.h>
|
||||||
|
#include <bx/countof.h>
|
||||||
|
#include <bx/endian.h>
|
||||||
#include <bx/handlealloc.h>
|
#include <bx/handlealloc.h>
|
||||||
#include <bx/hash.h>
|
#include <bx/hash.h>
|
||||||
|
#include <bx/radixsort.h>
|
||||||
#include <bx/ringbuffer.h>
|
#include <bx/ringbuffer.h>
|
||||||
#include <bx/uint32_t.h>
|
#include <bx/uint32_t.h>
|
||||||
#include <bx/radixsort.h>
|
|
||||||
|
|
||||||
#if BX_PLATFORM_WINDOWS
|
#if BX_PLATFORM_WINDOWS
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
@ -144,13 +145,29 @@ namespace stl = std;
|
|||||||
|
|
||||||
namespace bgfx
|
namespace bgfx
|
||||||
{
|
{
|
||||||
|
struct Clear
|
||||||
|
{
|
||||||
|
uint32_t m_rgba;
|
||||||
|
float m_depth;
|
||||||
|
uint8_t m_stencil;
|
||||||
|
uint8_t m_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Rect
|
||||||
|
{
|
||||||
|
uint16_t m_x;
|
||||||
|
uint16_t m_y;
|
||||||
|
uint16_t m_width;
|
||||||
|
uint16_t m_height;
|
||||||
|
};
|
||||||
|
|
||||||
extern const uint32_t g_constantTypeSize[ConstantType::Count];
|
extern const uint32_t g_constantTypeSize[ConstantType::Count];
|
||||||
extern FatalFn g_fatal;
|
extern FatalFn g_fatal;
|
||||||
extern ReallocFn g_realloc;
|
extern ReallocFn g_realloc;
|
||||||
extern FreeFn g_free;
|
extern FreeFn g_free;
|
||||||
extern CacheFn g_cache;
|
extern CacheFn g_cache;
|
||||||
|
|
||||||
void fatal(bgfx::Fatal::Enum _code, const char* _format, ...);
|
void fatal(Fatal::Enum _code, const char* _format, ...);
|
||||||
void release(const Memory* _mem);
|
void release(const Memory* _mem);
|
||||||
void saveTga(const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, bool _grayscale = false, bool _yflip = false);
|
void saveTga(const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, bool _grayscale = false, bool _yflip = false);
|
||||||
const char* getAttribName(Attrib::Enum _attr);
|
const char* getAttribName(Attrib::Enum _attr);
|
||||||
@ -161,6 +178,11 @@ namespace bgfx
|
|||||||
return _a > _b ? _b : _a;
|
return _a > _b ? _b : _a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline uint32_t uint16_max(uint16_t _a, uint16_t _b)
|
||||||
|
{
|
||||||
|
return _a < _b ? _b : _a;
|
||||||
|
}
|
||||||
|
|
||||||
inline uint32_t hash(const void* _data, uint32_t _size)
|
inline uint32_t hash(const void* _data, uint32_t _size)
|
||||||
{
|
{
|
||||||
HashMurmur2A murmur;
|
HashMurmur2A murmur;
|
||||||
@ -313,13 +335,24 @@ namespace bgfx
|
|||||||
void setup();
|
void setup();
|
||||||
void render(uint32_t _numIndices);
|
void render(uint32_t _numIndices);
|
||||||
|
|
||||||
bgfx::TextureHandle m_texture;
|
TextureHandle m_texture;
|
||||||
TransientVertexBuffer* m_vb;
|
TransientVertexBuffer* m_vb;
|
||||||
TransientIndexBuffer* m_ib;
|
TransientIndexBuffer* m_ib;
|
||||||
bgfx::VertexDecl m_decl;
|
VertexDecl m_decl;
|
||||||
bgfx::MaterialHandle m_material;
|
MaterialHandle m_material;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ClearQuad
|
||||||
|
{
|
||||||
|
void init();
|
||||||
|
void clear(const Rect& _rect, const Clear& _clear);
|
||||||
|
|
||||||
|
TransientVertexBuffer* m_vb;
|
||||||
|
IndexBufferHandle m_ib;
|
||||||
|
VertexDecl m_decl;
|
||||||
|
MaterialHandle m_material;
|
||||||
|
};
|
||||||
|
|
||||||
struct PredefinedUniform
|
struct PredefinedUniform
|
||||||
{
|
{
|
||||||
enum Enum
|
enum Enum
|
||||||
@ -583,22 +616,6 @@ namespace bgfx
|
|||||||
uint8_t m_trans;
|
uint8_t m_trans;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Clear
|
|
||||||
{
|
|
||||||
uint32_t m_rgba;
|
|
||||||
float m_depth;
|
|
||||||
uint8_t m_stencil;
|
|
||||||
uint8_t m_flags;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Rect
|
|
||||||
{
|
|
||||||
uint16_t m_x;
|
|
||||||
uint16_t m_y;
|
|
||||||
uint16_t m_width;
|
|
||||||
uint16_t m_height;
|
|
||||||
};
|
|
||||||
|
|
||||||
BX_ALIGN_STRUCT_16(struct) Matrix4
|
BX_ALIGN_STRUCT_16(struct) Matrix4
|
||||||
{
|
{
|
||||||
float val[16];
|
float val[16];
|
||||||
@ -876,14 +893,14 @@ namespace bgfx
|
|||||||
m_instanceDataStride = 0;
|
m_instanceDataStride = 0;
|
||||||
m_numInstances = 1;
|
m_numInstances = 1;
|
||||||
m_num = 1;
|
m_num = 1;
|
||||||
m_vertexBuffer.idx = bgfx::invalidHandle;
|
m_vertexBuffer.idx = invalidHandle;
|
||||||
m_vertexDecl.idx = bgfx::invalidHandle;
|
m_vertexDecl.idx = invalidHandle;
|
||||||
m_indexBuffer.idx = bgfx::invalidHandle;
|
m_indexBuffer.idx = invalidHandle;
|
||||||
m_instanceDataBuffer.idx = bgfx::invalidHandle;
|
m_instanceDataBuffer.idx = invalidHandle;
|
||||||
|
|
||||||
for (uint32_t ii = 0; ii < BGFX_STATE_TEX_COUNT; ++ii)
|
for (uint32_t ii = 0; ii < BGFX_STATE_TEX_COUNT; ++ii)
|
||||||
{
|
{
|
||||||
m_sampler[ii].m_idx = bgfx::invalidHandle;
|
m_sampler[ii].m_idx = invalidHandle;
|
||||||
m_sampler[ii].m_flags = BGFX_SAMPLER_TEXTURE;
|
m_sampler[ii].m_flags = BGFX_SAMPLER_TEXTURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1122,7 +1139,7 @@ namespace bgfx
|
|||||||
sampler.m_idx = _handle.idx;
|
sampler.m_idx = _handle.idx;
|
||||||
sampler.m_flags = BGFX_SAMPLER_TEXTURE;
|
sampler.m_flags = BGFX_SAMPLER_TEXTURE;
|
||||||
|
|
||||||
if (bgfx::invalidHandle != _sampler.idx)
|
if (invalidHandle != _sampler.idx)
|
||||||
{
|
{
|
||||||
uint32_t stage = _stage;
|
uint32_t stage = _stage;
|
||||||
setUniform(_sampler, &stage);
|
setUniform(_sampler, &stage);
|
||||||
@ -1136,7 +1153,7 @@ namespace bgfx
|
|||||||
sampler.m_idx = _handle.idx;
|
sampler.m_idx = _handle.idx;
|
||||||
sampler.m_flags = _depth ? BGFX_SAMPLER_RENDERTARGET_DEPTH : BGFX_SAMPLER_RENDERTARGET_COLOR;
|
sampler.m_flags = _depth ? BGFX_SAMPLER_RENDERTARGET_DEPTH : BGFX_SAMPLER_RENDERTARGET_COLOR;
|
||||||
|
|
||||||
if (bgfx::invalidHandle != _sampler.idx)
|
if (invalidHandle != _sampler.idx)
|
||||||
{
|
{
|
||||||
uint32_t stage = _stage;
|
uint32_t stage = _stage;
|
||||||
setUniform(_sampler, &stage);
|
setUniform(_sampler, &stage);
|
||||||
@ -1607,7 +1624,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
VertexDeclHandle declHandle = m_declRef.find(_decl.m_hash);
|
VertexDeclHandle declHandle = m_declRef.find(_decl.m_hash);
|
||||||
|
|
||||||
if (bgfx::invalidHandle == declHandle.idx)
|
if (invalidHandle == declHandle.idx)
|
||||||
{
|
{
|
||||||
VertexDeclHandle temp = { m_vertexDeclHandle.alloc() };
|
VertexDeclHandle temp = { m_vertexDeclHandle.alloc() };
|
||||||
declHandle = temp;
|
declHandle = temp;
|
||||||
@ -1636,7 +1653,7 @@ namespace bgfx
|
|||||||
void destroyVertexBuffer(VertexBufferHandle _handle)
|
void destroyVertexBuffer(VertexBufferHandle _handle)
|
||||||
{
|
{
|
||||||
VertexDeclHandle declHandle = m_declRef.release(_handle);
|
VertexDeclHandle declHandle = m_declRef.release(_handle);
|
||||||
if (bgfx::invalidHandle != declHandle.idx)
|
if (invalidHandle != declHandle.idx)
|
||||||
{
|
{
|
||||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexDecl);
|
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexDecl);
|
||||||
cmdbuf.write(declHandle);
|
cmdbuf.write(declHandle);
|
||||||
@ -1770,7 +1787,7 @@ namespace bgfx
|
|||||||
DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx];
|
DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx];
|
||||||
|
|
||||||
VertexDeclHandle declHandle = m_declRef.release(dvb.m_handle);
|
VertexDeclHandle declHandle = m_declRef.release(dvb.m_handle);
|
||||||
if (bgfx::invalidHandle != declHandle.idx)
|
if (invalidHandle != declHandle.idx)
|
||||||
{
|
{
|
||||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexDecl);
|
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexDecl);
|
||||||
cmdbuf.write(declHandle);
|
cmdbuf.write(declHandle);
|
||||||
@ -1864,7 +1881,7 @@ namespace bgfx
|
|||||||
|
|
||||||
TransientVertexBuffer& dvb = *m_submit->m_transientVb;
|
TransientVertexBuffer& dvb = *m_submit->m_transientVb;
|
||||||
|
|
||||||
if (bgfx::invalidHandle == declHandle.idx)
|
if (invalidHandle == declHandle.idx)
|
||||||
{
|
{
|
||||||
VertexDeclHandle temp = { m_vertexDeclHandle.alloc() };
|
VertexDeclHandle temp = { m_vertexDeclHandle.alloc() };
|
||||||
declHandle = temp;
|
declHandle = temp;
|
||||||
@ -1947,7 +1964,7 @@ namespace bgfx
|
|||||||
//
|
//
|
||||||
// MaterialHandle handle = m_materialRef.find(hash);
|
// MaterialHandle handle = m_materialRef.find(hash);
|
||||||
//
|
//
|
||||||
// if (bgfx::invalidHandle != handle.idx)
|
// if (invalidHandle != handle.idx)
|
||||||
// {
|
// {
|
||||||
// return handle;
|
// return handle;
|
||||||
// }
|
// }
|
||||||
@ -2080,8 +2097,8 @@ namespace bgfx
|
|||||||
Rect& rect = m_rect[_id];
|
Rect& rect = m_rect[_id];
|
||||||
rect.m_x = _x;
|
rect.m_x = _x;
|
||||||
rect.m_y = _y;
|
rect.m_y = _y;
|
||||||
rect.m_width = _width;
|
rect.m_width = uint16_max(_width, 1);
|
||||||
rect.m_height = _height;
|
rect.m_height = uint16_max(_height, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
||||||
@ -2785,6 +2802,7 @@ namespace bgfx
|
|||||||
uint32_t m_debug;
|
uint32_t m_debug;
|
||||||
|
|
||||||
TextVideoMemBlitter m_textVideoMemBlitter;
|
TextVideoMemBlitter m_textVideoMemBlitter;
|
||||||
|
ClearQuad m_clearQuad;
|
||||||
|
|
||||||
#if BX_PLATFORM_WINDOWS
|
#if BX_PLATFORM_WINDOWS
|
||||||
struct Window
|
struct Window
|
||||||
|
@ -531,3 +531,6 @@ static const uint8_t vga8x16[256*16] =
|
|||||||
|
|
||||||
#include "vs_debugfont_dx11.bin.h"
|
#include "vs_debugfont_dx11.bin.h"
|
||||||
#include "fs_debugfont_dx11.bin.h"
|
#include "fs_debugfont_dx11.bin.h"
|
||||||
|
|
||||||
|
#include "vs_clear_dx11.bin.h"
|
||||||
|
#include "fs_clear_dx11.bin.h"
|
||||||
|
37
src/fs_clear_dx11.bin.h
Normal file
37
src/fs_clear_dx11.bin.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
static const uint8_t fs_clear_dx11[539] =
|
||||||
|
{
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x14, 0x02, 0x44, 0x58, 0x42, 0x43, 0xda, 0x0f, 0xc3, 0x91, 0x70, 0x6f, // ......DXBC....po
|
||||||
|
0xd4, 0x7b, 0xeb, 0xe0, 0x21, 0x07, 0x79, 0xd8, 0x54, 0xd4, 0x01, 0x00, 0x00, 0x00, 0x14, 0x02, // .{..!.y.T.......
|
||||||
|
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0x00, 0x01, // ......4.........
|
||||||
|
0x00, 0x00, 0x34, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x70, 0x00, // ..4...x...RDEFp.
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, // ..............<.
|
||||||
|
0x00, 0x00, 0x00, 0x05, 0xff, 0xff, 0x00, 0x91, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x52, 0x44, // ..........<...RD
|
||||||
|
0x31, 0x31, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, // 11<....... ...(.
|
||||||
|
0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x69, // ..$...........Mi
|
||||||
|
0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, // crosoft (R) HLSL
|
||||||
|
0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, // Shader Compiler
|
||||||
|
0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, // 9.29.952.3111..
|
||||||
|
0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, // ..ISGNL.........
|
||||||
|
0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, // ..8.............
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, // ..........D.....
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x0f, // ................
|
||||||
|
0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, // ..SV_POSITION.CO
|
||||||
|
0x4c, 0x4f, 0x52, 0x00, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, // LOR...OSGN,.....
|
||||||
|
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ...... .........
|
||||||
|
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, // ..............SV
|
||||||
|
0x5f, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, 0xab, 0x53, 0x48, 0x45, 0x58, 0x3c, 0x00, // _TARGET...SHEX<.
|
||||||
|
0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x6a, 0x08, 0x00, 0x01, 0x62, 0x10, // ..P.......j...b.
|
||||||
|
0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, // ..........e....
|
||||||
|
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, // ......6.... ....
|
||||||
|
0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, // ..F.......>...ST
|
||||||
|
0x41, 0x54, 0x94, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // AT..............
|
||||||
|
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ...........
|
||||||
|
};
|
@ -67,6 +67,24 @@ namespace bgfx
|
|||||||
D3D11_TEXTURE_ADDRESS_CLAMP,
|
D3D11_TEXTURE_ADDRESS_CLAMP,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TextureFormatInfo
|
||||||
|
{
|
||||||
|
DXGI_FORMAT m_fmt;
|
||||||
|
uint8_t m_bpp;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const TextureFormatInfo s_textureFormat[TextureFormat::Count] =
|
||||||
|
{
|
||||||
|
{ DXGI_FORMAT_BC1_UNORM, 1 },
|
||||||
|
{ DXGI_FORMAT_BC2_UNORM, 1 },
|
||||||
|
{ DXGI_FORMAT_BC3_UNORM, 1 },
|
||||||
|
{ DXGI_FORMAT_UNKNOWN, 0 },
|
||||||
|
{ DXGI_FORMAT_R8_UNORM, 1 },
|
||||||
|
{ DXGI_FORMAT_R8G8B8A8_UNORM, 4 },
|
||||||
|
{ DXGI_FORMAT_R8G8B8A8_UNORM, 4 },
|
||||||
|
{ DXGI_FORMAT_R16G16B16A16_FLOAT, 8 },
|
||||||
|
};
|
||||||
|
|
||||||
static const D3D11_INPUT_ELEMENT_DESC s_attrib[Attrib::Count] =
|
static const D3D11_INPUT_ELEMENT_DESC s_attrib[Attrib::Count] =
|
||||||
{
|
{
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
@ -222,16 +240,16 @@ namespace bgfx
|
|||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
m_d3d11dll = LoadLibrary("d3d11.dll");
|
m_d3d11dll = LoadLibrary("d3d11.dll");
|
||||||
BGFX_FATAL(NULL != m_d3d11dll, bgfx::Fatal::D3D11_UnableToInitialize, "Failed to load d3d11.dll.");
|
BGFX_FATAL(NULL != m_d3d11dll, Fatal::D3D11_UnableToInitialize, "Failed to load d3d11.dll.");
|
||||||
|
|
||||||
m_dxgidll = LoadLibrary("dxgi.dll");
|
m_dxgidll = LoadLibrary("dxgi.dll");
|
||||||
BGFX_FATAL(NULL != m_dxgidll, bgfx::Fatal::D3D11_UnableToInitialize, "Failed to load dxgi.dll.");
|
BGFX_FATAL(NULL != m_dxgidll, Fatal::D3D11_UnableToInitialize, "Failed to load dxgi.dll.");
|
||||||
|
|
||||||
PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN d3D11CreateDeviceAndSwapChain = (PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)GetProcAddress(m_d3d11dll, "D3D11CreateDeviceAndSwapChain");
|
PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN d3D11CreateDeviceAndSwapChain = (PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)GetProcAddress(m_d3d11dll, "D3D11CreateDeviceAndSwapChain");
|
||||||
BGFX_FATAL(NULL != d3D11CreateDeviceAndSwapChain, bgfx::Fatal::D3D11_UnableToInitialize, "Function D3D11CreateDeviceAndSwapChain not found.");
|
BGFX_FATAL(NULL != d3D11CreateDeviceAndSwapChain, Fatal::D3D11_UnableToInitialize, "Function D3D11CreateDeviceAndSwapChain not found.");
|
||||||
|
|
||||||
CreateDXGIFactoryFn createDXGIFactory = (CreateDXGIFactoryFn)GetProcAddress(m_dxgidll, "CreateDXGIFactory");
|
CreateDXGIFactoryFn createDXGIFactory = (CreateDXGIFactoryFn)GetProcAddress(m_dxgidll, "CreateDXGIFactory");
|
||||||
BGFX_FATAL(NULL != createDXGIFactory, bgfx::Fatal::D3D11_UnableToInitialize, "Function CreateDXGIFactory not found.");
|
BGFX_FATAL(NULL != createDXGIFactory, Fatal::D3D11_UnableToInitialize, "Function CreateDXGIFactory not found.");
|
||||||
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
// IDXGIFactory* factory;
|
// IDXGIFactory* factory;
|
||||||
@ -276,7 +294,7 @@ namespace bgfx
|
|||||||
, &featureLevel
|
, &featureLevel
|
||||||
, &m_deviceCtx
|
, &m_deviceCtx
|
||||||
);
|
);
|
||||||
BGFX_FATAL(SUCCEEDED(hr), bgfx::Fatal::D3D11_UnableToInitialize, "Unable to create Direct3D11 device.");
|
BGFX_FATAL(SUCCEEDED(hr), Fatal::D3D11_UnableToInitialize, "Unable to create Direct3D11 device.");
|
||||||
|
|
||||||
ID3D11Texture2D* color;
|
ID3D11Texture2D* color;
|
||||||
DX_CHECK(m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&color) );
|
DX_CHECK(m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&color) );
|
||||||
@ -470,6 +488,8 @@ namespace bgfx
|
|||||||
|
|
||||||
void clear(const Rect& _rect, const Clear& _clear)
|
void clear(const Rect& _rect, const Clear& _clear)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE) );
|
// DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE) );
|
||||||
// DX_CHECK(s_renderCtx.m_device->SetScissorRect(&rc) );
|
// DX_CHECK(s_renderCtx.m_device->SetScissorRect(&rc) );
|
||||||
|
|
||||||
@ -593,6 +613,8 @@ namespace bgfx
|
|||||||
m_deviceCtx->RSSetState(rs);
|
m_deviceCtx->RSSetState(rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void saveScreenShot(Memory* _mem)
|
void saveScreenShot(Memory* _mem)
|
||||||
{
|
{
|
||||||
ID3D11Texture2D* backBuffer;
|
ID3D11Texture2D* backBuffer;
|
||||||
@ -845,7 +867,7 @@ namespace bgfx
|
|||||||
ID3D11DeviceContext* deviceCtx = s_renderCtx.m_deviceCtx;
|
ID3D11DeviceContext* deviceCtx = s_renderCtx.m_deviceCtx;
|
||||||
|
|
||||||
uint32_t width = s_renderCtx.m_scd.BufferDesc.Width;
|
uint32_t width = s_renderCtx.m_scd.BufferDesc.Width;
|
||||||
uint32_t height = s_renderCtx.m_scd.BufferDesc.Width;
|
uint32_t height = s_renderCtx.m_scd.BufferDesc.Height;
|
||||||
|
|
||||||
RenderTargetHandle rt = BGFX_INVALID_HANDLE;
|
RenderTargetHandle rt = BGFX_INVALID_HANDLE;
|
||||||
s_renderCtx.setRenderTarget(rt, false);
|
s_renderCtx.setRenderTarget(rt, false);
|
||||||
@ -868,16 +890,6 @@ namespace bgfx
|
|||||||
s_renderCtx.setDepthStencilState(state);
|
s_renderCtx.setDepthStencilState(state);
|
||||||
s_renderCtx.setRasterizerState(state);
|
s_renderCtx.setRasterizerState(state);
|
||||||
|
|
||||||
#if 0
|
|
||||||
DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ZENABLE, FALSE) );
|
|
||||||
DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS) );
|
|
||||||
DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE) );
|
|
||||||
DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE) );
|
|
||||||
DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER) );
|
|
||||||
DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_BLUE) );
|
|
||||||
DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID) );
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
Material& material = s_renderCtx.m_materials[m_material.idx];
|
Material& material = s_renderCtx.m_materials[m_material.idx];
|
||||||
s_renderCtx.m_currentMaterial = &material;
|
s_renderCtx.m_currentMaterial = &material;
|
||||||
deviceCtx->VSSetShader( (ID3D11VertexShader*)material.m_vsh->m_ptr, NULL, 0);
|
deviceCtx->VSSetShader( (ID3D11VertexShader*)material.m_vsh->m_ptr, NULL, 0);
|
||||||
@ -920,6 +932,93 @@ namespace bgfx
|
|||||||
deviceCtx->DrawIndexed(_numIndices, 0, 0);
|
deviceCtx->DrawIndexed(_numIndices, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClearQuad::clear(const Rect& _rect, const Clear& _clear)
|
||||||
|
{
|
||||||
|
uint32_t width = s_renderCtx.m_scd.BufferDesc.Width;
|
||||||
|
uint32_t height = s_renderCtx.m_scd.BufferDesc.Height;
|
||||||
|
|
||||||
|
if (0 == _rect.m_x
|
||||||
|
&& 0 == _rect.m_y
|
||||||
|
&& width == _rect.m_width
|
||||||
|
&& height == _rect.m_height)
|
||||||
|
{
|
||||||
|
s_renderCtx.clear(_rect, _clear);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ID3D11DeviceContext* deviceCtx = s_renderCtx.m_deviceCtx;
|
||||||
|
|
||||||
|
D3D11_VIEWPORT vp;
|
||||||
|
vp.TopLeftX = _rect.m_x;
|
||||||
|
vp.TopLeftY = _rect.m_y;
|
||||||
|
vp.Width = (float)_rect.m_width;
|
||||||
|
vp.Height = (float)_rect.m_height;
|
||||||
|
vp.MinDepth = 0.0f;
|
||||||
|
vp.MaxDepth = 1.0f;
|
||||||
|
deviceCtx->RSSetViewports(1, &vp);
|
||||||
|
|
||||||
|
uint64_t state = 0;
|
||||||
|
state |= _clear.m_flags & BGFX_CLEAR_COLOR_BIT ? BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE : 0;
|
||||||
|
state |= _clear.m_flags & BGFX_CLEAR_DEPTH_BIT ? BGFX_STATE_DEPTH_WRITE : 0;
|
||||||
|
|
||||||
|
s_renderCtx.setBlendState(state);
|
||||||
|
s_renderCtx.setDepthStencilState(state);
|
||||||
|
s_renderCtx.setRasterizerState(state);
|
||||||
|
|
||||||
|
Material& material = s_renderCtx.m_materials[m_material.idx];
|
||||||
|
s_renderCtx.m_currentMaterial = &material;
|
||||||
|
deviceCtx->VSSetShader( (ID3D11VertexShader*)material.m_vsh->m_ptr, NULL, 0);
|
||||||
|
deviceCtx->VSSetConstantBuffers(0, 0, NULL);
|
||||||
|
deviceCtx->PSSetShader( (ID3D11PixelShader*)material.m_fsh->m_ptr, NULL, 0);
|
||||||
|
deviceCtx->PSSetConstantBuffers(0, 0, NULL);
|
||||||
|
|
||||||
|
VertexBuffer& vb = s_renderCtx.m_vertexBuffers[m_vb->handle.idx];
|
||||||
|
VertexDecl& vertexDecl = s_renderCtx.m_vertexDecls[m_vb->decl.idx];
|
||||||
|
uint32_t stride = vertexDecl.m_stride;
|
||||||
|
uint32_t offset = 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
struct Vertex
|
||||||
|
{
|
||||||
|
float m_x;
|
||||||
|
float m_y;
|
||||||
|
float m_z;
|
||||||
|
uint32_t m_abgr;
|
||||||
|
} * vertex = (Vertex*)m_vb->data;
|
||||||
|
|
||||||
|
vertex->m_x = -1.0f;
|
||||||
|
vertex->m_y = -1.0f;
|
||||||
|
vertex->m_z = _clear.m_depth;
|
||||||
|
vertex->m_abgr = rand(); //bx::endianSwap(_clear.m_rgba);
|
||||||
|
vertex++;
|
||||||
|
vertex->m_x = 1.0f;
|
||||||
|
vertex->m_y = -1.0f;
|
||||||
|
vertex->m_z = _clear.m_depth;
|
||||||
|
vertex->m_abgr = bx::endianSwap(_clear.m_rgba);
|
||||||
|
vertex++;
|
||||||
|
vertex->m_x = 1.0f;
|
||||||
|
vertex->m_y = 1.0f;
|
||||||
|
vertex->m_z = _clear.m_depth;
|
||||||
|
vertex->m_abgr = bx::endianSwap(_clear.m_rgba);
|
||||||
|
vertex++;
|
||||||
|
vertex->m_x = -1.0f;
|
||||||
|
vertex->m_y = 1.0f;
|
||||||
|
vertex->m_z = _clear.m_depth;
|
||||||
|
vertex->m_abgr = bx::endianSwap(_clear.m_rgba);
|
||||||
|
}
|
||||||
|
|
||||||
|
s_renderCtx.m_vertexBuffers[m_vb->handle.idx].update(0, 4*m_decl.m_stride, m_vb->data);
|
||||||
|
deviceCtx->IASetVertexBuffers(0, 1, &vb.m_ptr, &stride, &offset);
|
||||||
|
s_renderCtx.setInputLayout(vertexDecl, material);
|
||||||
|
|
||||||
|
IndexBuffer& ib = s_renderCtx.m_indexBuffers[m_ib.idx];
|
||||||
|
deviceCtx->IASetIndexBuffer(ib.m_ptr, DXGI_FORMAT_R16_UINT, 0);
|
||||||
|
|
||||||
|
deviceCtx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
|
deviceCtx->DrawIndexed(6, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Shader::create(bool _fragment, const Memory* _mem)
|
void Shader::create(bool _fragment, const Memory* _mem)
|
||||||
{
|
{
|
||||||
m_constantBuffer = ConstantBuffer::create(1024);
|
m_constantBuffer = ConstantBuffer::create(1024);
|
||||||
@ -1072,16 +1171,97 @@ namespace bgfx
|
|||||||
|
|
||||||
if (dds.m_cubeMap)
|
if (dds.m_cubeMap)
|
||||||
{
|
{
|
||||||
|
m_type = TextureCube;
|
||||||
// createCubeTexture(dds.m_width, dds.m_numMips, s_textureFormat[dds.m_type].m_fmt);
|
// createCubeTexture(dds.m_width, dds.m_numMips, s_textureFormat[dds.m_type].m_fmt);
|
||||||
}
|
}
|
||||||
else if (dds.m_depth > 1)
|
else if (dds.m_depth > 1)
|
||||||
{
|
{
|
||||||
|
m_type = Texture3D;
|
||||||
// createVolumeTexture(dds.m_width, dds.m_height, dds.m_depth, dds.m_numMips, s_textureFormat[dds.m_type].m_fmt);
|
// createVolumeTexture(dds.m_width, dds.m_height, dds.m_depth, dds.m_numMips, s_textureFormat[dds.m_type].m_fmt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
m_type = Texture2D;
|
||||||
// createTexture(dds.m_width, dds.m_height, dds.m_numMips, s_textureFormat[dds.m_type].m_fmt);
|
// createTexture(dds.m_width, dds.m_height, dds.m_numMips, s_textureFormat[dds.m_type].m_fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
D3D11_TEXTURE2D_DESC desc;
|
||||||
|
desc.Width = dds.m_width;
|
||||||
|
desc.Height = dds.m_height;
|
||||||
|
desc.MipLevels = dds.m_numMips;
|
||||||
|
desc.ArraySize = 1;
|
||||||
|
desc.Format = s_textureFormat[dds.m_type].m_fmt;
|
||||||
|
desc.SampleDesc.Count = 1;
|
||||||
|
desc.SampleDesc.Quality = 0;
|
||||||
|
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
|
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||||
|
desc.CPUAccessFlags = 0;
|
||||||
|
desc.MiscFlags = 0;
|
||||||
|
|
||||||
|
uint32_t numSrd = dds.m_numMips*(dds.m_cubeMap ? 6 : 1);
|
||||||
|
D3D11_SUBRESOURCE_DATA* srd = (D3D11_SUBRESOURCE_DATA*)alloca(numSrd*sizeof(D3D11_SUBRESOURCE_DATA) );
|
||||||
|
|
||||||
|
uint32_t kk = 0;
|
||||||
|
|
||||||
|
if (decompress
|
||||||
|
|| TextureFormat::Unknown < dds.m_type)
|
||||||
|
{
|
||||||
|
for (uint8_t side = 0, numSides = dds.m_cubeMap ? 6 : 1; side < numSides; ++side)
|
||||||
|
{
|
||||||
|
uint32_t width = dds.m_width;
|
||||||
|
uint32_t height = dds.m_height;
|
||||||
|
uint32_t depth = dds.m_depth;
|
||||||
|
|
||||||
|
for (uint32_t lod = 0, num = dds.m_numMips; lod < num; ++lod)
|
||||||
|
{
|
||||||
|
width = uint32_max(1, width);
|
||||||
|
height = uint32_max(1, height);
|
||||||
|
depth = uint32_max(1, depth);
|
||||||
|
|
||||||
|
Mip mip;
|
||||||
|
if (getRawImageData(dds, side, lod, _mem, mip) )
|
||||||
|
{
|
||||||
|
srd[kk].pSysMem = mip.m_data;
|
||||||
|
srd[kk].SysMemPitch = mip.m_width*mip.m_bpp;
|
||||||
|
srd[kk].SysMemSlicePitch = 0;
|
||||||
|
++kk;
|
||||||
|
}
|
||||||
|
|
||||||
|
width >>= 1;
|
||||||
|
height >>= 1;
|
||||||
|
depth >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (uint8_t side = 0, numSides = dds.m_cubeMap ? 6 : 1; side < numSides; ++side)
|
||||||
|
{
|
||||||
|
for (uint32_t lod = 0, num = dds.m_numMips; lod < num; ++lod)
|
||||||
|
{
|
||||||
|
Mip mip;
|
||||||
|
if (getRawImageData(dds, 0, lod, _mem, mip) )
|
||||||
|
{
|
||||||
|
srd[kk].pSysMem = mip.m_data;
|
||||||
|
srd[kk].SysMemPitch = mip.m_width*mip.m_bpp;
|
||||||
|
srd[kk].SysMemSlicePitch = 0;
|
||||||
|
++kk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D11Texture2D* texture;
|
||||||
|
DX_CHECK(s_renderCtx.m_device->CreateTexture2D(&desc, srd, &texture) );
|
||||||
|
|
||||||
|
D3D11_SHADER_RESOURCE_VIEW_DESC srv;
|
||||||
|
memset(&srv, 0, sizeof(srv) );
|
||||||
|
srv.Format = s_textureFormat[dds.m_type].m_fmt;
|
||||||
|
srv.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||||
|
srv.Texture2D.MipLevels = dds.m_numMips;
|
||||||
|
DX_CHECK(s_renderCtx.m_device->CreateShaderResourceView(texture, &srv, &m_ptr) );
|
||||||
|
|
||||||
|
DX_RELEASE(texture, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1380,7 +1560,7 @@ namespace bgfx
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_FILLMODE, m_render->m_debug&BGFX_DEBUG_WIREFRAME ? D3DFILL_WIREFRAME : D3DFILL_SOLID) );
|
// DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_FILLMODE, m_render->m_debug&BGFX_DEBUG_WIREFRAME ? D3DFILL_WIREFRAME : D3DFILL_SOLID) );
|
||||||
uint16_t materialIdx = bgfx::invalidHandle;
|
uint16_t materialIdx = invalidHandle;
|
||||||
SortKey key;
|
SortKey key;
|
||||||
uint8_t view = 0xff;
|
uint8_t view = 0xff;
|
||||||
RenderTargetHandle rt = BGFX_INVALID_HANDLE;
|
RenderTargetHandle rt = BGFX_INVALID_HANDLE;
|
||||||
@ -1414,7 +1594,7 @@ namespace bgfx
|
|||||||
currentState.m_flags = newFlags;
|
currentState.m_flags = newFlags;
|
||||||
|
|
||||||
view = key.m_view;
|
view = key.m_view;
|
||||||
materialIdx = bgfx::invalidHandle;
|
materialIdx = invalidHandle;
|
||||||
|
|
||||||
if (m_render->m_rt[view].idx != rt.idx)
|
if (m_render->m_rt[view].idx != rt.idx)
|
||||||
{
|
{
|
||||||
@ -1436,7 +1616,7 @@ namespace bgfx
|
|||||||
|
|
||||||
if (BGFX_CLEAR_NONE != clear.m_flags)
|
if (BGFX_CLEAR_NONE != clear.m_flags)
|
||||||
{
|
{
|
||||||
s_renderCtx.clear(rect, clear);
|
m_clearQuad.clear(rect, clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
s_renderCtx.setBlendState(BGFX_STATE_DEFAULT);
|
s_renderCtx.setBlendState(BGFX_STATE_DEFAULT);
|
||||||
@ -1481,7 +1661,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
materialIdx = key.m_material;
|
materialIdx = key.m_material;
|
||||||
|
|
||||||
if (bgfx::invalidHandle == materialIdx)
|
if (invalidHandle == materialIdx)
|
||||||
{
|
{
|
||||||
s_renderCtx.m_currentMaterial = NULL;
|
s_renderCtx.m_currentMaterial = NULL;
|
||||||
|
|
||||||
@ -1504,7 +1684,7 @@ namespace bgfx
|
|||||||
constantsChanged = true;
|
constantsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bgfx::invalidHandle != materialIdx)
|
if (invalidHandle != materialIdx)
|
||||||
{
|
{
|
||||||
Material& material = s_renderCtx.m_materials[materialIdx];
|
Material& material = s_renderCtx.m_materials[materialIdx];
|
||||||
|
|
||||||
@ -1641,7 +1821,7 @@ namespace bgfx
|
|||||||
|| current.m_flags != sampler.m_flags
|
|| current.m_flags != sampler.m_flags
|
||||||
|| materialChanged)
|
|| materialChanged)
|
||||||
{
|
{
|
||||||
if (bgfx::invalidHandle != sampler.m_idx)
|
if (invalidHandle != sampler.m_idx)
|
||||||
{
|
{
|
||||||
switch (sampler.m_flags&BGFX_SAMPLER_TYPE_MASK)
|
switch (sampler.m_flags&BGFX_SAMPLER_TYPE_MASK)
|
||||||
{
|
{
|
||||||
@ -1674,11 +1854,11 @@ namespace bgfx
|
|||||||
currentState.m_vertexBuffer = state.m_vertexBuffer;
|
currentState.m_vertexBuffer = state.m_vertexBuffer;
|
||||||
|
|
||||||
uint16_t handle = state.m_vertexBuffer.idx;
|
uint16_t handle = state.m_vertexBuffer.idx;
|
||||||
if (bgfx::invalidHandle != handle)
|
if (invalidHandle != handle)
|
||||||
{
|
{
|
||||||
const VertexBuffer& vb = s_renderCtx.m_vertexBuffers[handle];
|
const VertexBuffer& vb = s_renderCtx.m_vertexBuffers[handle];
|
||||||
|
|
||||||
uint16_t decl = vb.m_decl.idx == bgfx::invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx;
|
uint16_t decl = vb.m_decl.idx == invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx;
|
||||||
const VertexDecl& vertexDecl = s_renderCtx.m_vertexDecls[decl];
|
const VertexDecl& vertexDecl = s_renderCtx.m_vertexDecls[decl];
|
||||||
uint32_t stride = vertexDecl.m_stride;
|
uint32_t stride = vertexDecl.m_stride;
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
@ -1714,7 +1894,7 @@ namespace bgfx
|
|||||||
currentState.m_indexBuffer = state.m_indexBuffer;
|
currentState.m_indexBuffer = state.m_indexBuffer;
|
||||||
|
|
||||||
uint16_t handle = state.m_indexBuffer.idx;
|
uint16_t handle = state.m_indexBuffer.idx;
|
||||||
if (bgfx::invalidHandle != handle)
|
if (invalidHandle != handle)
|
||||||
{
|
{
|
||||||
const IndexBuffer& ib = s_renderCtx.m_indexBuffers[handle];
|
const IndexBuffer& ib = s_renderCtx.m_indexBuffers[handle];
|
||||||
deviceCtx->IASetIndexBuffer(ib.m_ptr, DXGI_FORMAT_R16_UINT, 0);
|
deviceCtx->IASetIndexBuffer(ib.m_ptr, DXGI_FORMAT_R16_UINT, 0);
|
||||||
@ -1725,13 +1905,13 @@ namespace bgfx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bgfx::invalidHandle != currentState.m_vertexBuffer.idx)
|
if (invalidHandle != currentState.m_vertexBuffer.idx)
|
||||||
{
|
{
|
||||||
uint32_t numVertices = state.m_numVertices;
|
uint32_t numVertices = state.m_numVertices;
|
||||||
if (UINT32_C(0xffffffff) == numVertices)
|
if (UINT32_C(0xffffffff) == numVertices)
|
||||||
{
|
{
|
||||||
const VertexBuffer& vb = s_renderCtx.m_vertexBuffers[currentState.m_vertexBuffer.idx];
|
const VertexBuffer& vb = s_renderCtx.m_vertexBuffers[currentState.m_vertexBuffer.idx];
|
||||||
uint16_t decl = vb.m_decl.idx == bgfx::invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx;
|
uint16_t decl = vb.m_decl.idx == invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx;
|
||||||
const VertexDecl& vertexDecl = s_renderCtx.m_vertexDecls[decl];
|
const VertexDecl& vertexDecl = s_renderCtx.m_vertexDecls[decl];
|
||||||
numVertices = vb.m_size/vertexDecl.m_stride;
|
numVertices = vb.m_size/vertexDecl.m_stride;
|
||||||
}
|
}
|
||||||
@ -1741,7 +1921,7 @@ namespace bgfx
|
|||||||
uint32_t numInstances = 0;
|
uint32_t numInstances = 0;
|
||||||
uint32_t numPrimsRendered = 0;
|
uint32_t numPrimsRendered = 0;
|
||||||
|
|
||||||
if (bgfx::invalidHandle != state.m_indexBuffer.idx)
|
if (invalidHandle != state.m_indexBuffer.idx)
|
||||||
{
|
{
|
||||||
if (BGFX_DRAW_WHOLE_INDEX_BUFFER == state.m_startIndex)
|
if (BGFX_DRAW_WHOLE_INDEX_BUFFER == state.m_startIndex)
|
||||||
{
|
{
|
||||||
|
@ -186,7 +186,7 @@ namespace bgfx
|
|||||||
m_params.BackBufferHeight = rect.bottom-rect.top;
|
m_params.BackBufferHeight = rect.bottom-rect.top;
|
||||||
|
|
||||||
m_d3d9dll = LoadLibrary("d3d9.dll");
|
m_d3d9dll = LoadLibrary("d3d9.dll");
|
||||||
BGFX_FATAL(NULL != m_d3d9dll, bgfx::Fatal::D3D9_UnableToCreateInterface, "Failed to load d3d9.dll.");
|
BGFX_FATAL(NULL != m_d3d9dll, Fatal::D3D9_UnableToCreateInterface, "Failed to load d3d9.dll.");
|
||||||
|
|
||||||
m_D3DPERF_SetMarker = (D3DPERF_SetMarkerFunc)GetProcAddress(m_d3d9dll, "D3DPERF_SetMarker");
|
m_D3DPERF_SetMarker = (D3DPERF_SetMarkerFunc)GetProcAddress(m_d3d9dll, "D3DPERF_SetMarker");
|
||||||
m_D3DPERF_BeginEvent = (D3DPERF_BeginEventFunc)GetProcAddress(m_d3d9dll, "D3DPERF_BeginEvent");
|
m_D3DPERF_BeginEvent = (D3DPERF_BeginEventFunc)GetProcAddress(m_d3d9dll, "D3DPERF_BeginEvent");
|
||||||
@ -194,15 +194,15 @@ namespace bgfx
|
|||||||
|
|
||||||
#if BGFX_CONFIG_RENDERER_DIRECT3D9EX
|
#if BGFX_CONFIG_RENDERER_DIRECT3D9EX
|
||||||
Direct3DCreate9ExFn direct3DCreate9Ex = (Direct3DCreate9ExFn)GetProcAddress(m_d3d9dll, "Direct3DCreate9Ex");
|
Direct3DCreate9ExFn direct3DCreate9Ex = (Direct3DCreate9ExFn)GetProcAddress(m_d3d9dll, "Direct3DCreate9Ex");
|
||||||
BGFX_FATAL(NULL != direct3DCreate9Ex, bgfx::Fatal::D3D9_UnableToCreateInterface, "Function Direct3DCreate9Ex not found.");
|
BGFX_FATAL(NULL != direct3DCreate9Ex, Fatal::D3D9_UnableToCreateInterface, "Function Direct3DCreate9Ex not found.");
|
||||||
direct3DCreate9Ex(D3D_SDK_VERSION, &m_d3d9);
|
direct3DCreate9Ex(D3D_SDK_VERSION, &m_d3d9);
|
||||||
#else
|
#else
|
||||||
Direct3DCreate9Fn direct3DCreate9 = (Direct3DCreate9Fn)GetProcAddress(m_d3d9dll, "Direct3DCreate9");
|
Direct3DCreate9Fn direct3DCreate9 = (Direct3DCreate9Fn)GetProcAddress(m_d3d9dll, "Direct3DCreate9");
|
||||||
BGFX_FATAL(NULL != direct3DCreate9, bgfx::Fatal::D3D9_UnableToCreateInterface, "Function Direct3DCreate9 not found.");
|
BGFX_FATAL(NULL != direct3DCreate9, Fatal::D3D9_UnableToCreateInterface, "Function Direct3DCreate9 not found.");
|
||||||
m_d3d9 = direct3DCreate9(D3D_SDK_VERSION);
|
m_d3d9 = direct3DCreate9(D3D_SDK_VERSION);
|
||||||
#endif // defined(D3D_DISABLE_9EX)
|
#endif // defined(D3D_DISABLE_9EX)
|
||||||
|
|
||||||
BGFX_FATAL(m_d3d9, bgfx::Fatal::D3D9_UnableToCreateInterface, "Unable to create Direct3D.");
|
BGFX_FATAL(m_d3d9, Fatal::D3D9_UnableToCreateInterface, "Unable to create Direct3D.");
|
||||||
|
|
||||||
m_adapter = D3DADAPTER_DEFAULT;
|
m_adapter = D3DADAPTER_DEFAULT;
|
||||||
m_deviceType = D3DDEVTYPE_HAL;
|
m_deviceType = D3DDEVTYPE_HAL;
|
||||||
@ -267,22 +267,22 @@ namespace bgfx
|
|||||||
#endif // BGFX_CONFIG_RENDERER_DIRECT3D9EX
|
#endif // BGFX_CONFIG_RENDERER_DIRECT3D9EX
|
||||||
}
|
}
|
||||||
|
|
||||||
BGFX_FATAL(m_device, bgfx::Fatal::D3D9_UnableToCreateDevice, "Unable to create Direct3D9 device.");
|
BGFX_FATAL(m_device, Fatal::D3D9_UnableToCreateDevice, "Unable to create Direct3D9 device.");
|
||||||
|
|
||||||
DX_CHECK(m_device->GetDeviceCaps(&m_caps) );
|
DX_CHECK(m_device->GetDeviceCaps(&m_caps) );
|
||||||
|
|
||||||
// For shit GPUs that can create DX9 device but can't do simple stuff. GTFO!
|
// For shit GPUs that can create DX9 device but can't do simple stuff. GTFO!
|
||||||
BGFX_FATAL( (D3DPTEXTURECAPS_SQUAREONLY & m_caps.TextureCaps) == 0, bgfx::Fatal::MinimumRequiredSpecs, "D3DPTEXTURECAPS_SQUAREONLY");
|
BGFX_FATAL( (D3DPTEXTURECAPS_SQUAREONLY & m_caps.TextureCaps) == 0, Fatal::MinimumRequiredSpecs, "D3DPTEXTURECAPS_SQUAREONLY");
|
||||||
BGFX_FATAL( (D3DPTEXTURECAPS_MIPMAP & m_caps.TextureCaps) == D3DPTEXTURECAPS_MIPMAP, bgfx::Fatal::MinimumRequiredSpecs, "D3DPTEXTURECAPS_MIPMAP");
|
BGFX_FATAL( (D3DPTEXTURECAPS_MIPMAP & m_caps.TextureCaps) == D3DPTEXTURECAPS_MIPMAP, Fatal::MinimumRequiredSpecs, "D3DPTEXTURECAPS_MIPMAP");
|
||||||
BGFX_FATAL( (D3DPTEXTURECAPS_ALPHA & m_caps.TextureCaps) == D3DPTEXTURECAPS_ALPHA, bgfx::Fatal::MinimumRequiredSpecs, "D3DPTEXTURECAPS_ALPHA");
|
BGFX_FATAL( (D3DPTEXTURECAPS_ALPHA & m_caps.TextureCaps) == D3DPTEXTURECAPS_ALPHA, Fatal::MinimumRequiredSpecs, "D3DPTEXTURECAPS_ALPHA");
|
||||||
BGFX_FATAL(m_caps.VertexShaderVersion >= D3DVS_VERSION(2, 0) && m_caps.PixelShaderVersion >= D3DPS_VERSION(2, 1)
|
BGFX_FATAL(m_caps.VertexShaderVersion >= D3DVS_VERSION(2, 0) && m_caps.PixelShaderVersion >= D3DPS_VERSION(2, 1)
|
||||||
, bgfx::Fatal::MinimumRequiredSpecs
|
, Fatal::MinimumRequiredSpecs
|
||||||
, "Shader Model Version (vs: %x, ps: %x)."
|
, "Shader Model Version (vs: %x, ps: %x)."
|
||||||
, m_caps.VertexShaderVersion
|
, m_caps.VertexShaderVersion
|
||||||
, m_caps.PixelShaderVersion
|
, m_caps.PixelShaderVersion
|
||||||
);
|
);
|
||||||
BGFX_FATAL(m_caps.MaxTextureWidth >= 2048 && m_caps.MaxTextureHeight >= 2048
|
BGFX_FATAL(m_caps.MaxTextureWidth >= 2048 && m_caps.MaxTextureHeight >= 2048
|
||||||
, bgfx::Fatal::MinimumRequiredSpecs
|
, Fatal::MinimumRequiredSpecs
|
||||||
, "Maximum texture size is below 2048 (w: %d, h: %d)."
|
, "Maximum texture size is below 2048 (w: %d, h: %d)."
|
||||||
, m_caps.MaxTextureWidth
|
, m_caps.MaxTextureWidth
|
||||||
, m_caps.MaxTextureHeight
|
, m_caps.MaxTextureHeight
|
||||||
@ -723,12 +723,12 @@ namespace bgfx
|
|||||||
|
|
||||||
IndexBuffer m_indexBuffers[BGFX_CONFIG_MAX_INDEX_BUFFERS];
|
IndexBuffer m_indexBuffers[BGFX_CONFIG_MAX_INDEX_BUFFERS];
|
||||||
VertexBuffer m_vertexBuffers[BGFX_CONFIG_MAX_VERTEX_BUFFERS];
|
VertexBuffer m_vertexBuffers[BGFX_CONFIG_MAX_VERTEX_BUFFERS];
|
||||||
Shader m_vertexShaders[BGFX_CONFIG_MAX_VERTEX_SHADERS];
|
Shader m_vertexShaders[BGFX_CONFIG_MAX_VERTEX_SHADERS];
|
||||||
Shader m_fragmentShaders[BGFX_CONFIG_MAX_FRAGMENT_SHADERS];
|
Shader m_fragmentShaders[BGFX_CONFIG_MAX_FRAGMENT_SHADERS];
|
||||||
Material m_materials[BGFX_CONFIG_MAX_MATERIALS];
|
Material m_materials[BGFX_CONFIG_MAX_MATERIALS];
|
||||||
Texture m_textures[BGFX_CONFIG_MAX_TEXTURES];
|
Texture m_textures[BGFX_CONFIG_MAX_TEXTURES];
|
||||||
VertexDeclaration m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS];
|
VertexDeclaration m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS];
|
||||||
RenderTarget m_renderTargets[BGFX_CONFIG_MAX_RENDER_TARGETS];
|
RenderTarget m_renderTargets[BGFX_CONFIG_MAX_RENDER_TARGETS];
|
||||||
UniformRegistry m_uniformReg;
|
UniformRegistry m_uniformReg;
|
||||||
void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS];
|
void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS];
|
||||||
|
|
||||||
@ -1413,7 +1413,7 @@ namespace bgfx
|
|||||||
, NULL
|
, NULL
|
||||||
) );
|
) );
|
||||||
|
|
||||||
BGFX_FATAL(m_rt, bgfx::Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create 1x1 render target.");
|
BGFX_FATAL(m_rt, Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create 1x1 render target.");
|
||||||
|
|
||||||
DX_CHECK(s_renderCtx.m_device->CreateTexture(m_width
|
DX_CHECK(s_renderCtx.m_device->CreateTexture(m_width
|
||||||
, m_height
|
, m_height
|
||||||
@ -1425,7 +1425,7 @@ namespace bgfx
|
|||||||
, NULL
|
, NULL
|
||||||
) );
|
) );
|
||||||
|
|
||||||
BGFX_FATAL(m_depthTexture, bgfx::Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create depth texture.");
|
BGFX_FATAL(m_depthTexture, Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create depth texture.");
|
||||||
|
|
||||||
DX_CHECK(m_depthTexture->GetSurfaceLevel(0, &m_depth) );
|
DX_CHECK(m_depthTexture->GetSurfaceLevel(0, &m_depth) );
|
||||||
}
|
}
|
||||||
@ -1443,7 +1443,7 @@ namespace bgfx
|
|||||||
, NULL
|
, NULL
|
||||||
) );
|
) );
|
||||||
|
|
||||||
BGFX_FATAL(m_rt, bgfx::Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create MSAA render target.");
|
BGFX_FATAL(m_rt, Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create MSAA render target.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < colorFormat)
|
if (0 < colorFormat)
|
||||||
@ -1458,7 +1458,7 @@ namespace bgfx
|
|||||||
, NULL
|
, NULL
|
||||||
) );
|
) );
|
||||||
|
|
||||||
BGFX_FATAL(m_colorTexture, bgfx::Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create color render target.");
|
BGFX_FATAL(m_colorTexture, Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create color render target.");
|
||||||
|
|
||||||
DX_CHECK(m_colorTexture->GetSurfaceLevel(0, &m_color) );
|
DX_CHECK(m_colorTexture->GetSurfaceLevel(0, &m_color) );
|
||||||
}
|
}
|
||||||
@ -1475,7 +1475,7 @@ namespace bgfx
|
|||||||
, NULL
|
, NULL
|
||||||
) );
|
) );
|
||||||
|
|
||||||
BGFX_FATAL(m_depth, bgfx::Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create depth stencil surface.");
|
BGFX_FATAL(m_depth, Fatal::D3D9_UnableToCreateRenderTarget, "Unable to create depth stencil surface.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1540,7 +1540,7 @@ namespace bgfx
|
|||||||
) );
|
) );
|
||||||
#endif // BX_PLATFORM_WINDOWS
|
#endif // BX_PLATFORM_WINDOWS
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConstantBuffer::commit()
|
void ConstantBuffer::commit()
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
@ -1856,7 +1856,7 @@ namespace bgfx
|
|||||||
}
|
}
|
||||||
|
|
||||||
DX_CHECK(device->SetRenderState(D3DRS_FILLMODE, m_render->m_debug&BGFX_DEBUG_WIREFRAME ? D3DFILL_WIREFRAME : D3DFILL_SOLID) );
|
DX_CHECK(device->SetRenderState(D3DRS_FILLMODE, m_render->m_debug&BGFX_DEBUG_WIREFRAME ? D3DFILL_WIREFRAME : D3DFILL_SOLID) );
|
||||||
uint16_t materialIdx = bgfx::invalidHandle;
|
uint16_t materialIdx = invalidHandle;
|
||||||
SortKey key;
|
SortKey key;
|
||||||
uint8_t view = 0xff;
|
uint8_t view = 0xff;
|
||||||
RenderTargetHandle rt = BGFX_INVALID_HANDLE;
|
RenderTargetHandle rt = BGFX_INVALID_HANDLE;
|
||||||
@ -1892,7 +1892,8 @@ namespace bgfx
|
|||||||
PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), "view");
|
PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), "view");
|
||||||
|
|
||||||
view = key.m_view;
|
view = key.m_view;
|
||||||
materialIdx = bgfx::invalidHandle;
|
|
||||||
|
materialIdx = invalidHandle;
|
||||||
|
|
||||||
if (m_render->m_rt[view].idx != rt.idx)
|
if (m_render->m_rt[view].idx != rt.idx)
|
||||||
{
|
{
|
||||||
@ -2049,7 +2050,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
materialIdx = key.m_material;
|
materialIdx = key.m_material;
|
||||||
|
|
||||||
if (bgfx::invalidHandle == materialIdx)
|
if (invalidHandle == materialIdx)
|
||||||
{
|
{
|
||||||
device->SetVertexShader(NULL);
|
device->SetVertexShader(NULL);
|
||||||
device->SetPixelShader(NULL);
|
device->SetPixelShader(NULL);
|
||||||
@ -2065,7 +2066,7 @@ namespace bgfx
|
|||||||
constantsChanged = true;
|
constantsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bgfx::invalidHandle != materialIdx)
|
if (invalidHandle != materialIdx)
|
||||||
{
|
{
|
||||||
Material& material = s_renderCtx.m_materials[materialIdx];
|
Material& material = s_renderCtx.m_materials[materialIdx];
|
||||||
|
|
||||||
@ -2197,7 +2198,7 @@ namespace bgfx
|
|||||||
|| current.m_flags != sampler.m_flags
|
|| current.m_flags != sampler.m_flags
|
||||||
|| materialChanged)
|
|| materialChanged)
|
||||||
{
|
{
|
||||||
if (bgfx::invalidHandle != sampler.m_idx)
|
if (invalidHandle != sampler.m_idx)
|
||||||
{
|
{
|
||||||
switch (sampler.m_flags&BGFX_SAMPLER_TYPE_MASK)
|
switch (sampler.m_flags&BGFX_SAMPLER_TYPE_MASK)
|
||||||
{
|
{
|
||||||
@ -2230,11 +2231,11 @@ namespace bgfx
|
|||||||
currentState.m_vertexBuffer = state.m_vertexBuffer;
|
currentState.m_vertexBuffer = state.m_vertexBuffer;
|
||||||
|
|
||||||
uint16_t handle = state.m_vertexBuffer.idx;
|
uint16_t handle = state.m_vertexBuffer.idx;
|
||||||
if (bgfx::invalidHandle != handle)
|
if (invalidHandle != handle)
|
||||||
{
|
{
|
||||||
const VertexBuffer& vb = s_renderCtx.m_vertexBuffers[handle];
|
const VertexBuffer& vb = s_renderCtx.m_vertexBuffers[handle];
|
||||||
|
|
||||||
uint16_t decl = vb.m_decl.idx == bgfx::invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx;
|
uint16_t decl = vb.m_decl.idx == invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx;
|
||||||
const VertexDeclaration& vertexDecl = s_renderCtx.m_vertexDecls[decl];
|
const VertexDeclaration& vertexDecl = s_renderCtx.m_vertexDecls[decl];
|
||||||
DX_CHECK(device->SetStreamSource(0, vb.m_ptr, 0, vertexDecl.m_decl.m_stride) );
|
DX_CHECK(device->SetStreamSource(0, vb.m_ptr, 0, vertexDecl.m_decl.m_stride) );
|
||||||
|
|
||||||
@ -2269,7 +2270,7 @@ namespace bgfx
|
|||||||
currentState.m_indexBuffer = state.m_indexBuffer;
|
currentState.m_indexBuffer = state.m_indexBuffer;
|
||||||
|
|
||||||
uint16_t handle = state.m_indexBuffer.idx;
|
uint16_t handle = state.m_indexBuffer.idx;
|
||||||
if (bgfx::invalidHandle != handle)
|
if (invalidHandle != handle)
|
||||||
{
|
{
|
||||||
IndexBuffer& ib = s_renderCtx.m_indexBuffers[handle];
|
IndexBuffer& ib = s_renderCtx.m_indexBuffers[handle];
|
||||||
DX_CHECK(device->SetIndices(ib.m_ptr) );
|
DX_CHECK(device->SetIndices(ib.m_ptr) );
|
||||||
@ -2280,13 +2281,13 @@ namespace bgfx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bgfx::invalidHandle != currentState.m_vertexBuffer.idx)
|
if (invalidHandle != currentState.m_vertexBuffer.idx)
|
||||||
{
|
{
|
||||||
uint32_t numVertices = state.m_numVertices;
|
uint32_t numVertices = state.m_numVertices;
|
||||||
if (UINT32_C(0xffffffff) == numVertices)
|
if (UINT32_C(0xffffffff) == numVertices)
|
||||||
{
|
{
|
||||||
VertexBuffer& vb = s_renderCtx.m_vertexBuffers[currentState.m_vertexBuffer.idx];
|
VertexBuffer& vb = s_renderCtx.m_vertexBuffers[currentState.m_vertexBuffer.idx];
|
||||||
uint16_t decl = vb.m_decl.idx == bgfx::invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx;
|
uint16_t decl = vb.m_decl.idx == invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx;
|
||||||
VertexDeclaration& vertexDecl = s_renderCtx.m_vertexDecls[decl];
|
VertexDeclaration& vertexDecl = s_renderCtx.m_vertexDecls[decl];
|
||||||
numVertices = vb.m_size/vertexDecl.m_decl.m_stride;
|
numVertices = vb.m_size/vertexDecl.m_decl.m_stride;
|
||||||
}
|
}
|
||||||
@ -2296,7 +2297,7 @@ namespace bgfx
|
|||||||
uint32_t numInstances = 0;
|
uint32_t numInstances = 0;
|
||||||
uint32_t numPrimsRendered = 0;
|
uint32_t numPrimsRendered = 0;
|
||||||
|
|
||||||
if (bgfx::invalidHandle != state.m_indexBuffer.idx)
|
if (invalidHandle != state.m_indexBuffer.idx)
|
||||||
{
|
{
|
||||||
if (BGFX_DRAW_WHOLE_INDEX_BUFFER == state.m_startIndex)
|
if (BGFX_DRAW_WHOLE_INDEX_BUFFER == state.m_startIndex)
|
||||||
{
|
{
|
||||||
|
@ -131,7 +131,7 @@ namespace bgfx
|
|||||||
# define GL_IMPORT(_optional, _proto, _func) \
|
# define GL_IMPORT(_optional, _proto, _func) \
|
||||||
{ \
|
{ \
|
||||||
_func = (_proto)eglGetProcAddress(#_func); \
|
_func = (_proto)eglGetProcAddress(#_func); \
|
||||||
BGFX_FATAL(_optional || NULL != _func, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGL context. eglGetProcAddress(\"%s\")", #_func); \
|
BGFX_FATAL(_optional || NULL != _func, Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGL context. eglGetProcAddress(\"%s\")", #_func); \
|
||||||
}
|
}
|
||||||
# include "glimports.h"
|
# include "glimports.h"
|
||||||
# undef GL_IMPORT
|
# undef GL_IMPORT
|
||||||
@ -146,22 +146,22 @@ namespace bgfx
|
|||||||
if (NULL == m_hdc)
|
if (NULL == m_hdc)
|
||||||
{
|
{
|
||||||
m_opengl32dll = LoadLibrary("opengl32.dll");
|
m_opengl32dll = LoadLibrary("opengl32.dll");
|
||||||
BGFX_FATAL(NULL != m_opengl32dll, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed to load opengl32.dll.");
|
BGFX_FATAL(NULL != m_opengl32dll, Fatal::OPENGL_UnableToCreateContext, "Failed to load opengl32.dll.");
|
||||||
|
|
||||||
wglGetProcAddress = (PFNWGLGETPROCADDRESSPROC)GetProcAddress(m_opengl32dll, "wglGetProcAddress");
|
wglGetProcAddress = (PFNWGLGETPROCADDRESSPROC)GetProcAddress(m_opengl32dll, "wglGetProcAddress");
|
||||||
BGFX_FATAL(NULL != wglGetProcAddress, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed get wglGetProcAddress.");
|
BGFX_FATAL(NULL != wglGetProcAddress, Fatal::OPENGL_UnableToCreateContext, "Failed get wglGetProcAddress.");
|
||||||
|
|
||||||
wglMakeCurrent = (PFNWGLMAKECURRENTPROC)GetProcAddress(m_opengl32dll, "wglMakeCurrent");
|
wglMakeCurrent = (PFNWGLMAKECURRENTPROC)GetProcAddress(m_opengl32dll, "wglMakeCurrent");
|
||||||
BGFX_FATAL(NULL != wglMakeCurrent, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed get wglMakeCurrent.");
|
BGFX_FATAL(NULL != wglMakeCurrent, Fatal::OPENGL_UnableToCreateContext, "Failed get wglMakeCurrent.");
|
||||||
|
|
||||||
wglCreateContext = (PFNWGLCREATECONTEXTPROC)GetProcAddress(m_opengl32dll, "wglCreateContext");
|
wglCreateContext = (PFNWGLCREATECONTEXTPROC)GetProcAddress(m_opengl32dll, "wglCreateContext");
|
||||||
BGFX_FATAL(NULL != wglCreateContext, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed get wglCreateContext.");
|
BGFX_FATAL(NULL != wglCreateContext, Fatal::OPENGL_UnableToCreateContext, "Failed get wglCreateContext.");
|
||||||
|
|
||||||
wglDeleteContext = (PFNWGLDELETECONTEXTPROC)GetProcAddress(m_opengl32dll, "wglDeleteContext");
|
wglDeleteContext = (PFNWGLDELETECONTEXTPROC)GetProcAddress(m_opengl32dll, "wglDeleteContext");
|
||||||
BGFX_FATAL(NULL != wglDeleteContext, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed get wglDeleteContext.");
|
BGFX_FATAL(NULL != wglDeleteContext, Fatal::OPENGL_UnableToCreateContext, "Failed get wglDeleteContext.");
|
||||||
|
|
||||||
m_hdc = GetDC(g_bgfxHwnd);
|
m_hdc = GetDC(g_bgfxHwnd);
|
||||||
BGFX_FATAL(NULL != m_hdc, bgfx::Fatal::OPENGL_UnableToCreateContext, "GetDC failed!");
|
BGFX_FATAL(NULL != m_hdc, Fatal::OPENGL_UnableToCreateContext, "GetDC failed!");
|
||||||
|
|
||||||
PIXELFORMATDESCRIPTOR pfd;
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
memset(&pfd, 0, sizeof(pfd) );
|
memset(&pfd, 0, sizeof(pfd) );
|
||||||
@ -175,19 +175,19 @@ namespace bgfx
|
|||||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||||
|
|
||||||
int pixelFormat = ChoosePixelFormat(m_hdc, &pfd);
|
int pixelFormat = ChoosePixelFormat(m_hdc, &pfd);
|
||||||
BGFX_FATAL(0 != pixelFormat, bgfx::Fatal::OPENGL_UnableToCreateContext, "ChoosePixelFormat failed!");
|
BGFX_FATAL(0 != pixelFormat, Fatal::OPENGL_UnableToCreateContext, "ChoosePixelFormat failed!");
|
||||||
|
|
||||||
DescribePixelFormat(m_hdc, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
DescribePixelFormat(m_hdc, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
result = SetPixelFormat(m_hdc, pixelFormat, &pfd);
|
result = SetPixelFormat(m_hdc, pixelFormat, &pfd);
|
||||||
BGFX_FATAL(0 != result, bgfx::Fatal::OPENGL_UnableToCreateContext, "SetPixelFormat failed!");
|
BGFX_FATAL(0 != result, Fatal::OPENGL_UnableToCreateContext, "SetPixelFormat failed!");
|
||||||
|
|
||||||
m_context = wglCreateContext(m_hdc);
|
m_context = wglCreateContext(m_hdc);
|
||||||
BGFX_FATAL(NULL != m_context, bgfx::Fatal::OPENGL_UnableToCreateContext, "wglCreateContext failed!");
|
BGFX_FATAL(NULL != m_context, Fatal::OPENGL_UnableToCreateContext, "wglCreateContext failed!");
|
||||||
|
|
||||||
result = wglMakeCurrent(m_hdc, m_context);
|
result = wglMakeCurrent(m_hdc, m_context);
|
||||||
BGFX_FATAL(0 != result, bgfx::Fatal::OPENGL_UnableToCreateContext, "wglMakeCurrent failed!");
|
BGFX_FATAL(0 != result, Fatal::OPENGL_UnableToCreateContext, "wglMakeCurrent failed!");
|
||||||
|
|
||||||
# define GL_IMPORT(_optional, _proto, _func) \
|
# define GL_IMPORT(_optional, _proto, _func) \
|
||||||
{ \
|
{ \
|
||||||
@ -196,7 +196,7 @@ namespace bgfx
|
|||||||
{ \
|
{ \
|
||||||
_func = (_proto)GetProcAddress(m_opengl32dll, #_func); \
|
_func = (_proto)GetProcAddress(m_opengl32dll, #_func); \
|
||||||
} \
|
} \
|
||||||
BGFX_FATAL(_optional || NULL != _func, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGL context. wglGetProcAddress(\"%s\")", #_func); \
|
BGFX_FATAL(_optional || NULL != _func, Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGL context. wglGetProcAddress(\"%s\")", #_func); \
|
||||||
}
|
}
|
||||||
# include "glimports.h"
|
# include "glimports.h"
|
||||||
# undef GL_IMPORT
|
# undef GL_IMPORT
|
||||||
@ -207,14 +207,14 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
Display* display = XOpenDisplay(0);
|
Display* display = XOpenDisplay(0);
|
||||||
XLockDisplay(display);
|
XLockDisplay(display);
|
||||||
BGFX_FATAL(display, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed to open X display (0).");
|
BGFX_FATAL(display, Fatal::OPENGL_UnableToCreateContext, "Failed to open X display (0).");
|
||||||
|
|
||||||
int glxMajor, glxMinor;
|
int glxMajor, glxMinor;
|
||||||
if (!glXQueryVersion(display, &glxMajor, &glxMinor))
|
if (!glXQueryVersion(display, &glxMajor, &glxMinor))
|
||||||
{
|
{
|
||||||
BGFX_FATAL(false, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed to query GLX version");
|
BGFX_FATAL(false, Fatal::OPENGL_UnableToCreateContext, "Failed to query GLX version");
|
||||||
}
|
}
|
||||||
BGFX_FATAL((glxMajor == 1 && glxMinor >= 3) || glxMajor > 1, bgfx::Fatal::OPENGL_UnableToCreateContext, "GLX version is not >=1.3 (%d.%d).", glxMajor, glxMinor);
|
BGFX_FATAL((glxMajor == 1 && glxMinor >= 3) || glxMajor > 1, Fatal::OPENGL_UnableToCreateContext, "GLX version is not >=1.3 (%d.%d).", glxMajor, glxMinor);
|
||||||
|
|
||||||
const int glxAttribs[] =
|
const int glxAttribs[] =
|
||||||
{
|
{
|
||||||
@ -269,7 +269,7 @@ namespace bgfx
|
|||||||
}
|
}
|
||||||
|
|
||||||
XFree(configs);
|
XFree(configs);
|
||||||
BGFX_FATAL(visualInfo, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed to find a suitable X11 display configuration.");
|
BGFX_FATAL(visualInfo, Fatal::OPENGL_UnableToCreateContext, "Failed to find a suitable X11 display configuration.");
|
||||||
|
|
||||||
// Generate colormaps
|
// Generate colormaps
|
||||||
XSetWindowAttributes windowAttrs;
|
XSetWindowAttributes windowAttrs;
|
||||||
@ -287,7 +287,7 @@ namespace bgfx
|
|||||||
, CWBorderPixel|CWColormap
|
, CWBorderPixel|CWColormap
|
||||||
, &windowAttrs
|
, &windowAttrs
|
||||||
);
|
);
|
||||||
BGFX_FATAL(window, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed to create X11 window.");
|
BGFX_FATAL(window, Fatal::OPENGL_UnableToCreateContext, "Failed to create X11 window.");
|
||||||
|
|
||||||
XMapRaised(display, window);
|
XMapRaised(display, window);
|
||||||
XFlush(display);
|
XFlush(display);
|
||||||
@ -297,7 +297,7 @@ namespace bgfx
|
|||||||
|
|
||||||
typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
|
typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
|
||||||
glXCreateContextAttribsARBProc glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
|
glXCreateContextAttribsARBProc glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
|
||||||
BGFX_FATAL(glXCreateContextAttribsARB, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed to get glXCreateContextAttribsARB.");
|
BGFX_FATAL(glXCreateContextAttribsARB, Fatal::OPENGL_UnableToCreateContext, "Failed to get glXCreateContextAttribsARB.");
|
||||||
|
|
||||||
const int contextArrib[] =
|
const int contextArrib[] =
|
||||||
{
|
{
|
||||||
@ -307,14 +307,14 @@ namespace bgfx
|
|||||||
};
|
};
|
||||||
|
|
||||||
m_context = glXCreateContextAttribsARB(display, bestconfig, 0, True, contextArrib);
|
m_context = glXCreateContextAttribsARB(display, bestconfig, 0, True, contextArrib);
|
||||||
BGFX_FATAL(m_context, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed to create GLX context.");
|
BGFX_FATAL(m_context, Fatal::OPENGL_UnableToCreateContext, "Failed to create GLX context.");
|
||||||
|
|
||||||
glXMakeCurrent(display, window, m_context);
|
glXMakeCurrent(display, window, m_context);
|
||||||
|
|
||||||
# define GL_IMPORT(_optional, _proto, _func) \
|
# define GL_IMPORT(_optional, _proto, _func) \
|
||||||
{ \
|
{ \
|
||||||
_func = (_proto)glXGetProcAddress((const GLubyte*)#_func); \
|
_func = (_proto)glXGetProcAddress((const GLubyte*)#_func); \
|
||||||
BGFX_FATAL(_optional || NULL != _func, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGL context. glXGetProcAddress %s", #_func); \
|
BGFX_FATAL(_optional || NULL != _func, Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGL context. glXGetProcAddress %s", #_func); \
|
||||||
}
|
}
|
||||||
# include "glimports.h"
|
# include "glimports.h"
|
||||||
# undef GL_IMPORT
|
# undef GL_IMPORT
|
||||||
@ -368,7 +368,7 @@ namespace bgfx
|
|||||||
# define GL_IMPORT(_optional, _proto, _func) \
|
# define GL_IMPORT(_optional, _proto, _func) \
|
||||||
{ \
|
{ \
|
||||||
_func = (_proto)eglGetProcAddress(#_func); \
|
_func = (_proto)eglGetProcAddress(#_func); \
|
||||||
BGFX_FATAL(_optional || NULL != _func, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGLES context. eglGetProcAddress(\"%s\")", #_func); \
|
BGFX_FATAL(_optional || NULL != _func, Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGLES context. eglGetProcAddress(\"%s\")", #_func); \
|
||||||
}
|
}
|
||||||
# include "glimports.h"
|
# include "glimports.h"
|
||||||
# undef GL_IMPORT
|
# undef GL_IMPORT
|
||||||
@ -1943,7 +1943,7 @@ namespace bgfx
|
|||||||
matrix_mul(viewProj[ii].val, m_render->m_view[ii].val, m_render->m_proj[ii].val);
|
matrix_mul(viewProj[ii].val, m_render->m_view[ii].val, m_render->m_proj[ii].val);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t materialIdx = bgfx::invalidHandle;
|
uint16_t materialIdx = invalidHandle;
|
||||||
SortKey key;
|
SortKey key;
|
||||||
uint8_t view = 0xff;
|
uint8_t view = 0xff;
|
||||||
RenderTargetHandle rt = BGFX_INVALID_HANDLE;
|
RenderTargetHandle rt = BGFX_INVALID_HANDLE;
|
||||||
@ -1980,13 +1980,13 @@ namespace bgfx
|
|||||||
GREMEDY_SETMARKER("view");
|
GREMEDY_SETMARKER("view");
|
||||||
|
|
||||||
view = key.m_view;
|
view = key.m_view;
|
||||||
materialIdx = bgfx::invalidHandle;
|
materialIdx = invalidHandle;
|
||||||
|
|
||||||
if (m_render->m_rt[view].idx != rt.idx)
|
if (m_render->m_rt[view].idx != rt.idx)
|
||||||
{
|
{
|
||||||
rt = m_render->m_rt[view];
|
rt = m_render->m_rt[view];
|
||||||
|
|
||||||
if (rt.idx == bgfx::invalidHandle)
|
if (rt.idx == invalidHandle)
|
||||||
{
|
{
|
||||||
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0) );
|
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0) );
|
||||||
height = m_render->m_resolution.m_height;
|
height = m_render->m_resolution.m_height;
|
||||||
@ -2152,14 +2152,14 @@ namespace bgfx
|
|||||||
if (key.m_material != materialIdx)
|
if (key.m_material != materialIdx)
|
||||||
{
|
{
|
||||||
materialIdx = key.m_material;
|
materialIdx = key.m_material;
|
||||||
GLuint id = bgfx::invalidHandle == materialIdx ? 0 : s_renderCtx.m_materials[materialIdx].m_id;
|
GLuint id = invalidHandle == materialIdx ? 0 : s_renderCtx.m_materials[materialIdx].m_id;
|
||||||
GL_CHECK(glUseProgram(id) );
|
GL_CHECK(glUseProgram(id) );
|
||||||
materialChanged =
|
materialChanged =
|
||||||
constantsChanged =
|
constantsChanged =
|
||||||
bindAttribs = true;
|
bindAttribs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bgfx::invalidHandle != materialIdx)
|
if (invalidHandle != materialIdx)
|
||||||
{
|
{
|
||||||
Material& material = s_renderCtx.m_materials[materialIdx];
|
Material& material = s_renderCtx.m_materials[materialIdx];
|
||||||
|
|
||||||
@ -2318,7 +2318,7 @@ namespace bgfx
|
|||||||
|| materialChanged)
|
|| materialChanged)
|
||||||
{
|
{
|
||||||
GL_CHECK(glActiveTexture(GL_TEXTURE0+stage) );
|
GL_CHECK(glActiveTexture(GL_TEXTURE0+stage) );
|
||||||
if (bgfx::invalidHandle != sampler.m_idx)
|
if (invalidHandle != sampler.m_idx)
|
||||||
{
|
{
|
||||||
switch (sampler.m_flags&BGFX_SAMPLER_TYPE_MASK)
|
switch (sampler.m_flags&BGFX_SAMPLER_TYPE_MASK)
|
||||||
{
|
{
|
||||||
@ -2358,7 +2358,7 @@ namespace bgfx
|
|||||||
currentState.m_vertexBuffer = state.m_vertexBuffer;
|
currentState.m_vertexBuffer = state.m_vertexBuffer;
|
||||||
|
|
||||||
uint16_t handle = state.m_vertexBuffer.idx;
|
uint16_t handle = state.m_vertexBuffer.idx;
|
||||||
if (bgfx::invalidHandle != handle)
|
if (invalidHandle != handle)
|
||||||
{
|
{
|
||||||
VertexBuffer& vb = s_renderCtx.m_vertexBuffers[handle];
|
VertexBuffer& vb = s_renderCtx.m_vertexBuffers[handle];
|
||||||
GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vb.m_id) );
|
GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vb.m_id) );
|
||||||
@ -2375,7 +2375,7 @@ namespace bgfx
|
|||||||
currentState.m_indexBuffer = state.m_indexBuffer;
|
currentState.m_indexBuffer = state.m_indexBuffer;
|
||||||
|
|
||||||
uint16_t handle = state.m_indexBuffer.idx;
|
uint16_t handle = state.m_indexBuffer.idx;
|
||||||
if (bgfx::invalidHandle != handle)
|
if (invalidHandle != handle)
|
||||||
{
|
{
|
||||||
IndexBuffer& ib = s_renderCtx.m_indexBuffers[handle];
|
IndexBuffer& ib = s_renderCtx.m_indexBuffers[handle];
|
||||||
GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ib.m_id) );
|
GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ib.m_id) );
|
||||||
@ -2386,14 +2386,14 @@ namespace bgfx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bgfx::invalidHandle != currentState.m_vertexBuffer.idx)
|
if (invalidHandle != currentState.m_vertexBuffer.idx)
|
||||||
{
|
{
|
||||||
if (baseVertex != state.m_startVertex
|
if (baseVertex != state.m_startVertex
|
||||||
|| bindAttribs)
|
|| bindAttribs)
|
||||||
{
|
{
|
||||||
baseVertex = state.m_startVertex;
|
baseVertex = state.m_startVertex;
|
||||||
VertexBuffer& vb = s_renderCtx.m_vertexBuffers[state.m_vertexBuffer.idx];
|
VertexBuffer& vb = s_renderCtx.m_vertexBuffers[state.m_vertexBuffer.idx];
|
||||||
uint16_t decl = vb.m_decl.idx == bgfx::invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx;
|
uint16_t decl = vb.m_decl.idx == invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx;
|
||||||
const Material& material = s_renderCtx.m_materials[materialIdx];
|
const Material& material = s_renderCtx.m_materials[materialIdx];
|
||||||
material.bindAttributes(s_renderCtx.m_vertexDecls[decl], state.m_startVertex);
|
material.bindAttributes(s_renderCtx.m_vertexDecls[decl], state.m_startVertex);
|
||||||
|
|
||||||
@ -2409,7 +2409,7 @@ namespace bgfx
|
|||||||
uint32_t numInstances = 0;
|
uint32_t numInstances = 0;
|
||||||
uint32_t numPrimsRendered = 0;
|
uint32_t numPrimsRendered = 0;
|
||||||
|
|
||||||
if (bgfx::invalidHandle != state.m_indexBuffer.idx)
|
if (invalidHandle != state.m_indexBuffer.idx)
|
||||||
{
|
{
|
||||||
if (BGFX_DRAW_WHOLE_INDEX_BUFFER == state.m_startIndex)
|
if (BGFX_DRAW_WHOLE_INDEX_BUFFER == state.m_startIndex)
|
||||||
{
|
{
|
||||||
|
43
src/vs_clear_dx11.bin.h
Normal file
43
src/vs_clear_dx11.bin.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
static const uint8_t vs_clear_dx11[635] =
|
||||||
|
{
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x74, 0x02, 0x44, 0x58, 0x42, 0x43, 0x9f, 0x90, 0x55, 0x9a, 0x15, 0xd7, // ....t.DXBC..U...
|
||||||
|
0x4d, 0x46, 0x12, 0x19, 0x32, 0x30, 0xa7, 0xfd, 0x7a, 0x83, 0x01, 0x00, 0x00, 0x00, 0x74, 0x02, // MF..20..z.....t.
|
||||||
|
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0xfc, 0x00, // ......4.........
|
||||||
|
0x00, 0x00, 0x50, 0x01, 0x00, 0x00, 0xd8, 0x01, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x70, 0x00, // ..P.......RDEFp.
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, // ..............<.
|
||||||
|
0x00, 0x00, 0x00, 0x05, 0xfe, 0xff, 0x00, 0x91, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x52, 0x44, // ..........<...RD
|
||||||
|
0x31, 0x31, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, // 11<....... ...(.
|
||||||
|
0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x69, // ..$...........Mi
|
||||||
|
0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, // crosoft (R) HLSL
|
||||||
|
0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, // Shader Compiler
|
||||||
|
0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, // 9.29.952.3111..
|
||||||
|
0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x48, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, // ..ISGNH.........
|
||||||
|
0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, // ..8.............
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, // ..........A.....
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x0f, // ................
|
||||||
|
0x00, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, // ..POSITION.COLOR
|
||||||
|
0x00, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, // ..OSGNL.........
|
||||||
|
0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, // ..8.............
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, // ..........D.....
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, // ..SV_POSITION.CO
|
||||||
|
0x4c, 0x4f, 0x52, 0x00, 0xab, 0xab, 0x53, 0x48, 0x45, 0x58, 0x80, 0x00, 0x00, 0x00, 0x50, 0x00, // LOR...SHEX....P.
|
||||||
|
0x01, 0x00, 0x20, 0x00, 0x00, 0x00, 0x6a, 0x08, 0x00, 0x01, 0x5f, 0x00, 0x00, 0x03, 0x72, 0x10, // .. ...j..._...r.
|
||||||
|
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x01, 0x00, // ......_.........
|
||||||
|
0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, // ..g.... ........
|
||||||
|
0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, // ..e.... ......6.
|
||||||
|
0x00, 0x05, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x12, 0x10, 0x00, 0x00, 0x00, // ..r ......F.....
|
||||||
|
0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, // ..6.... .......@
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, // .....?6.... ....
|
||||||
|
0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, // ..F.......>...ST
|
||||||
|
0x41, 0x54, 0x94, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // AT..............
|
||||||
|
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ...........
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user