From 08dddc5d7414bd1ba426df56ccad8be772e0d8b3 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Tue, 19 Jun 2012 20:50:07 -0700 Subject: [PATCH] Moved radixsort out of bgfx. --- src/bgfx.cpp | 52 +-------------------------------------------- src/bgfx_p.h | 1 + src/renderer_gl.cpp | 8 +++++++ 3 files changed, 10 insertions(+), 51 deletions(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index c3c179bd..ff1951c7 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -102,56 +102,6 @@ namespace bgfx _result[15] = 1.0f; } -#define RADIX_BITS 11 -#define RADIX_PASSES 6 -#define RADIX_HISTOGRAM_SIZE (1<>shift)&RADIX_BIT_MASK; - ++histogram[index]; - } - - uint16_t offset = 0; - for (uint32_t ii = 0; ii < RADIX_HISTOGRAM_SIZE; ++ii) - { - uint16_t count = histogram[ii]; - histogram[ii] = offset; - offset += count; - } - - for (uint32_t ii = 0; ii < _size; ++ii) - { - uint64_t key = _keys[ii]; - uint16_t index = (key>>shift)&RADIX_BIT_MASK; - uint16_t dest = histogram[index]++; - _tempKeys[dest] = key; - - uint16_t value = _values[ii]; - _tempValues[dest] = value; - } - - uint64_t* swapKeys = _tempKeys; - _tempKeys = _keys; - _keys = swapKeys; - - uint16_t* swapValues = _tempValues; - _tempValues = _values; - _values = swapValues; - - shift += RADIX_BITS; - } - } - void saveTga(const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _data) { FILE* file = fopen(_filePath, "wb"); @@ -471,7 +421,7 @@ namespace bgfx void Frame::sort() { - radixSort(m_sortKeys, s_ctx.m_tempKeys, m_sortValues, s_ctx.m_tempValues, m_num); + bx::radixSort64(m_sortKeys, s_ctx.m_tempKeys, m_sortValues, s_ctx.m_tempValues, m_num); } RendererType::Enum getRendererType() diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 6df27e46..a41f8b29 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -53,6 +53,7 @@ extern void dbgPrintfData(const void* _data, uint32_t _size, const char* _format #include #include #include +#include #if BX_PLATFORM_WINDOWS # include diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 49f66e63..abe01623 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -344,6 +344,14 @@ namespace bgfx success = eglMakeCurrent(m_display, m_surface, m_surface, m_context); BGFX_FATAL(success, Fatal::OPENGL_UnableToCreateContext, "Failed to set context."); + +# define GL_IMPORT(_optional, _proto, _func) \ + { \ + _func = (_proto)eglGetProcAddress(#_func); \ + BGFX_FATAL(_optional || NULL != _func, bgfx::Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGLES context. eglGetProcAddress(\"%s\")", #_func); \ + } +# include "glimports.h" +# undef GL_IMPORT } #endif // BX_PLATFORM_ }