Merge branch 'master' of github.com:bkaradzic/bgfx

This commit is contained in:
Branimir Karadžić 2015-02-17 11:50:38 -08:00
Родитель 7279a31768 5ff63f93b6
Коммит b8d065da79
15 изменённых файлов: 40 добавлений и 59 удалений

Просмотреть файл

@ -495,6 +495,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
break;
case bgfx::RendererType::Direct3D11:
case bgfx::RendererType::Direct3D12:
vs_metaballs = bgfx::makeRef(vs_metaballs_dx11, sizeof(vs_metaballs_dx11) );
fs_metaballs = bgfx::makeRef(fs_metaballs_dx11, sizeof(fs_metaballs_dx11) );
break;
@ -544,7 +545,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
float at[3] = { 0.0f, 0.0f, 0.0f };
float eye[3] = { 0.0f, 0.0f, -50.0f };
// Set view and projection matrix for view 0.
const bgfx::HMD* hmd = bgfx::getHMD();
if (NULL != hmd)
@ -598,7 +599,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
}
profUpdate = bx::getHPCounter();
for (uint32_t zz = 0; zz < DIMS; ++zz)
{
for (uint32_t yy = 0; yy < DIMS; ++yy)
@ -690,7 +691,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
-DIMS*0.5f + float(zz)
};
const Grid* val[8] = {
const Grid* val[8] = {
&grid[xoffset+zpitch+ypitch ],
&grid[xoffset+zpitch+ypitch+1],
&grid[xoffset+ypitch+1 ],
@ -735,7 +736,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
bgfx::dbgTextPrintf(1, 7, 0x0f, " Triangulate: % 7.3f[ms]", double(profTriangulate)*toMs);
bgfx::dbgTextPrintf(1, 8, 0x0f, " Frame: % 7.3f[ms]", double(frameTime)*toMs);
// Advance to next frame. Rendering thread will be kicked to
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
bgfx::frame();
}

Просмотреть файл

@ -146,7 +146,6 @@ static const uint16_t s_planeIndices[] =
1, 3, 2,
};
static const char* s_shaderPath = NULL;
static bool s_flipV = false;
static uint32_t s_viewMask = 0;
static uint32_t s_clearMask = 0;
@ -857,23 +856,12 @@ int _main_(int /*_argc*/, char** /*_argv*/)
// for each renderer.
switch (bgfx::getRendererType() )
{
default:
case bgfx::RendererType::Direct3D9:
s_shaderPath = "shaders/dx9/";
break;
case bgfx::RendererType::Direct3D11:
s_shaderPath = "shaders/dx11/";
break;
case bgfx::RendererType::OpenGL:
s_shaderPath = "shaders/glsl/";
case bgfx::RendererType::OpenGLES:
s_flipV = true;
break;
case bgfx::RendererType::OpenGLES:
s_shaderPath = "shaders/gles/";
s_flipV = true;
default:
break;
}

Просмотреть файл

@ -111,7 +111,6 @@ static const uint16_t s_planeIndices[] =
1, 3, 2,
};
static const char* s_shaderPath = NULL;
static bool s_oglNdc = false;
static float s_texelHalf = 0.0f;
@ -1872,24 +1871,16 @@ int _main_(int /*_argc*/, char** /*_argv*/)
// for each renderer.
switch (bgfx::getRendererType() )
{
default:
case bgfx::RendererType::Direct3D9:
s_shaderPath = "shaders/dx9/";
s_texelHalf = 0.5f;
break;
case bgfx::RendererType::Direct3D11:
s_shaderPath = "shaders/dx11/";
break;
case bgfx::RendererType::OpenGL:
s_shaderPath = "shaders/glsl/";
case bgfx::RendererType::OpenGLES:
s_oglNdc = true;
break;
case bgfx::RendererType::OpenGLES:
s_shaderPath = "shaders/gles/";
s_oglNdc = true;
default:
break;
}

Просмотреть файл

@ -220,7 +220,6 @@ static const uint16_t s_planeIndices[] =
1, 3, 2,
};
static const char* s_shaderPath = NULL;
static bool s_flipV = false;
static float s_texelHalf = 0.0f;
@ -1333,24 +1332,16 @@ int _main_(int /*_argc*/, char** /*_argv*/)
// for each renderer.
switch (bgfx::getRendererType() )
{
default:
case bgfx::RendererType::Direct3D9:
s_shaderPath = "shaders/dx9/";
s_texelHalf = 0.5f;
break;
case bgfx::RendererType::Direct3D11:
s_shaderPath = "shaders/dx11/";
break;
case bgfx::RendererType::OpenGL:
s_shaderPath = "shaders/glsl/";
case bgfx::RendererType::OpenGLES:
s_flipV = true;
break;
case bgfx::RendererType::OpenGLES:
s_shaderPath = "shaders/gles/";
s_flipV = true;
default:
break;
}

Просмотреть файл

@ -280,6 +280,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
break;
case bgfx::RendererType::Direct3D11:
case bgfx::RendererType::Direct3D12:
vs_drawstress = bgfx::makeRef(vs_drawstress_dx11, sizeof(vs_drawstress_dx11) );
fs_drawstress = bgfx::makeRef(fs_drawstress_dx11, sizeof(fs_drawstress_dx11) );
break;

Просмотреть файл

@ -71,6 +71,7 @@ static bgfx::ShaderHandle loadShader(bx::FileReaderI* _reader, const char* _name
switch (bgfx::getRendererType() )
{
case bgfx::RendererType::Direct3D11:
case bgfx::RendererType::Direct3D12:
shaderPath = "shaders/dx11/";
break;

Просмотреть файл

@ -60,8 +60,8 @@ private:
int32_t width; //< The line _width. The ending coordinate (inclusive) will be x+width-1.
};
uint32_t m_width; //< width (in pixels) of the underlying texture
uint32_t m_width; //< width (in pixels) of the underlying texture
uint32_t m_height; //< height (in pixels) of the underlying texture
uint32_t m_usedSpace; //< Surface used in squared pixel
std::vector<Node> m_skyline; //< node of the skyline algorithm
@ -326,6 +326,7 @@ void Atlas::init()
break;
case bgfx::RendererType::Direct3D11:
case bgfx::RendererType::Direct3D12:
m_texelOffset[0] = texelHalf;
m_texelOffset[1] = texelHalf;
break;

Просмотреть файл

@ -74,7 +74,7 @@ public:
/// Append a wide char unicode string to the buffer using current pen
/// position and color.
void appendText(FontHandle _fontHandle, const wchar_t* _string, const wchar_t* _end = NULL);
/// Append a whole face of the atlas cube, mostly used for debugging
/// and visualizing atlas.
void appendAtlasFace(uint16_t _faceIndex);
@ -250,7 +250,7 @@ void TextBuffer::appendText(FontHandle _fontHandle, const char* _string, const c
}
}
BX_CHECK(state == UTF8_ACCEPT, "The string is not well-formed");
BX_CHECK(state == UTF8_ACCEPT, "The string is not well-formed");
}
void TextBuffer::appendText(FontHandle _fontHandle, const wchar_t* _string, const wchar_t* _end)
@ -366,7 +366,7 @@ void TextBuffer::appendGlyph(FontHandle _handle, CodePoint _codePoint)
float txtDecals = (font.ascender - m_lineAscender);
m_lineAscender = font.ascender;
m_lineGap = font.lineGap;
m_lineGap = font.lineGap;
verticalCenterLastLine( (txtDecals), (m_penY - m_lineAscender), (m_penY + m_lineAscender - m_lineDescender + m_lineGap) );
}
@ -575,6 +575,7 @@ TextBufferManager::TextBufferManager(FontManager* _fontManager)
break;
case bgfx::RendererType::Direct3D11:
case bgfx::RendererType::Direct3D12:
vs_font_basic = bgfx::makeRef(vs_font_basic_dx11, sizeof(vs_font_basic_dx11) );
fs_font_basic = bgfx::makeRef(fs_font_basic_dx11, sizeof(fs_font_basic_dx11) );
vs_font_distance_field = bgfx::makeRef(vs_font_distance_field_dx11, sizeof(vs_font_distance_field_dx11) );

Просмотреть файл

@ -468,9 +468,9 @@ struct Imgui
IMGUI_create(_data, _size, _fontSize);
m_nvg = nvgCreate(1, m_view);
nvgCreateFontMem(m_nvg, "default", (unsigned char*)_data, INT32_MAX, 0);
nvgFontSize(m_nvg, _fontSize);
nvgFontFace(m_nvg, "default");
nvgCreateFontMem(m_nvg, "default", (unsigned char*)_data, INT32_MAX, 0);
nvgFontSize(m_nvg, _fontSize);
nvgFontFace(m_nvg, "default");
for (int32_t ii = 0; ii < NUM_CIRCLE_VERTS; ++ii)
{
@ -518,6 +518,7 @@ struct Imgui
break;
case bgfx::RendererType::Direct3D11:
case bgfx::RendererType::Direct3D12:
vs_imgui_color = bgfx::makeRef(vs_imgui_color_dx11, sizeof(vs_imgui_color_dx11) );
fs_imgui_color = bgfx::makeRef(fs_imgui_color_dx11, sizeof(fs_imgui_color_dx11) );
vs_imgui_texture = bgfx::makeRef(vs_imgui_texture_dx11, sizeof(vs_imgui_texture_dx11) );

Просмотреть файл

@ -99,6 +99,7 @@ struct OcornutImguiContext
break;
case bgfx::RendererType::Direct3D11:
case bgfx::RendererType::Direct3D12:
vsmem = bgfx::makeRef(vs_ocornut_imgui_dx11, sizeof(vs_ocornut_imgui_dx11));
fsmem = bgfx::makeRef(fs_ocornut_imgui_dx11, sizeof(fs_ocornut_imgui_dx11));
break;

Просмотреть файл

@ -239,6 +239,7 @@ namespace
break;
case bgfx::RendererType::Direct3D11:
case bgfx::RendererType::Direct3D12:
vs_nanovg_fill = bgfx::makeRef(vs_nanovg_fill_dx11, sizeof(vs_nanovg_fill_dx11) );
fs_nanovg_fill = bgfx::makeRef(fs_nanovg_fill_dx11, sizeof(fs_nanovg_fill_dx11) );
break;

Просмотреть файл

@ -725,7 +725,7 @@ BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_hand
* @param _num Number of vertices.
* @param _decl Vertex declaration.
*/
BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint16_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, uint8_t _flags);
/**
* Create dynamic vertex buffer and initialize it.
@ -816,7 +816,7 @@ BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_
* NOTE:
* Only 16-bit index buffer is supported.
*/
BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t* _decl, uint16_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint16_t _numIndices);
BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t* _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices);
/**
* Allocate instance data buffer.

Просмотреть файл

@ -687,7 +687,7 @@ namespace bgfx
/// When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated
/// from CPU.
///
DynamicVertexBufferHandle createDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl, uint8_t _flags = BGFX_BUFFER_NONE);
DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint8_t _flags = BGFX_BUFFER_NONE);
/// Create dynamic vertex buffer and initialize it.
///
@ -766,7 +766,7 @@ namespace bgfx
/// @remarks
/// Only 16-bit index buffer is supported.
///
bool allocTransientBuffers(TransientVertexBuffer* _tvb, const VertexDecl& _decl, uint16_t _numVertices, TransientIndexBuffer* _tib, uint16_t _numIndices);
bool allocTransientBuffers(TransientVertexBuffer* _tvb, const VertexDecl& _decl, uint32_t _numVertices, TransientIndexBuffer* _tib, uint32_t _numIndices);
/// Allocate instance data buffer.
///

Просмотреть файл

@ -355,6 +355,7 @@ namespace bgfx
break;
case RendererType::Direct3D11:
case RendererType::Direct3D12:
mem = makeRef(vs_debugfont_dx11, sizeof(vs_debugfont_dx11) );
break;
@ -372,6 +373,7 @@ namespace bgfx
break;
case RendererType::Direct3D11:
case RendererType::Direct3D12:
mem = makeRef(fs_debugfont_dx11, sizeof(fs_debugfont_dx11) );
break;
@ -552,7 +554,8 @@ namespace bgfx
fragMem[ii] = makeRef(mem[ii].data, uint32_t(mem[ii].size) );
}
}
else if (RendererType::Direct3D11 == g_caps.rendererType)
else if (RendererType::Direct3D11 == g_caps.rendererType
|| RendererType::Direct3D12 == g_caps.rendererType)
{
vsh = createShader(makeRef(vs_clear_dx11, sizeof(vs_clear_dx11) ) );
@ -1928,7 +1931,7 @@ again:
uint8_t num = 0;
for (uint8_t ii = 0; ii < uint8_t(RendererType::Count); ++ii)
{
if (RendererType::Direct3D11 == ii
if ( (RendererType::Direct3D11 == ii || RendererType::Direct3D12 == ii)
&& windowsVersionIs(Condition::LessEqual, 0x0502) )
{
continue;
@ -2163,7 +2166,7 @@ again:
s_ctx->destroyDynamicIndexBuffer(_handle);
}
DynamicVertexBufferHandle createDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl, uint8_t _flags)
DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint8_t _flags)
{
BGFX_CHECK_MAIN_THREAD();
BX_CHECK(0 != _decl.m_stride, "Invalid VertexDecl.");
@ -2239,7 +2242,7 @@ again:
return s_ctx->allocTransientVertexBuffer(_tvb, _num, _decl);
}
bool allocTransientBuffers(bgfx::TransientVertexBuffer* _tvb, const bgfx::VertexDecl& _decl, uint16_t _numVertices, bgfx::TransientIndexBuffer* _tib, uint16_t _numIndices)
bool allocTransientBuffers(bgfx::TransientVertexBuffer* _tvb, const bgfx::VertexDecl& _decl, uint32_t _numVertices, bgfx::TransientIndexBuffer* _tib, uint32_t _numIndices)
{
if (checkAvailTransientBuffers(_numVertices, _decl, _numIndices) )
{
@ -3097,7 +3100,7 @@ BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_hand
bgfx::destroyDynamicIndexBuffer(handle.cpp);
}
BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint16_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, uint8_t _flags)
{
const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle;
@ -3158,7 +3161,7 @@ BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_
bgfx::allocTransientVertexBuffer( (bgfx::TransientVertexBuffer*)_tvb, _num, decl);
}
BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t* _decl, uint16_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint16_t _numIndices)
BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t* _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices)
{
const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
return bgfx::allocTransientBuffers( (bgfx::TransientVertexBuffer*)_tvb, decl, _numVertices, (bgfx::TransientIndexBuffer*)_tib, _numIndices);

Просмотреть файл

@ -2178,7 +2178,7 @@ namespace bgfx
return ptr;
}
BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl, uint8_t _flags) )
BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint8_t _flags) )
{
DynamicVertexBufferHandle handle = BGFX_INVALID_HANDLE;
uint32_t size = strideAlign16( (_num+1)*_decl.m_stride, _decl.m_stride);