Added DX11 renderer stub.

This commit is contained in:
bkaradzic 2012-07-08 19:10:07 -07:00
parent 60d2993808
commit 98ebe1f076
8 changed files with 3094 additions and 2939 deletions

View File

@ -227,7 +227,7 @@ namespace bgfx
charsetFillTexture(vga8x16, &rgba[8*pitch], 16, pitch, bpp);
m_texture = s_ctx.createTexture(mem, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT, NULL, NULL);
#if BGFX_CONFIG_RENDERER_DIRECT3D
#if BGFX_CONFIG_RENDERER_DIRECT3D9
mem = bgfx::alloc(sizeof(vs_debugfont_hlsl)+1);
memcpy(mem->data, vs_debugfont_hlsl, mem->size-1);
#else
@ -237,7 +237,7 @@ namespace bgfx
mem->data[mem->size-1] = '\0';
bgfx::VertexShaderHandle vsh = bgfx::createVertexShader(mem);
#if BGFX_CONFIG_RENDERER_DIRECT3D
#if BGFX_CONFIG_RENDERER_DIRECT3D9
mem = bgfx::alloc(sizeof(fs_debugfont_hlsl)+1);
memcpy(mem->data, fs_debugfont_hlsl, mem->size-1);
#else
@ -458,11 +458,11 @@ namespace bgfx
RendererType::Enum getRendererType()
{
#if BGFX_CONFIG_RENDERER_DIRECT3D
#if BGFX_CONFIG_RENDERER_DIRECT3D9
return RendererType::Direct3D9;
#elif BGFX_CONFIG_RENDERER_OPENGL
return RendererType::OpenGL;
#elif BGFX_CONFIG_RENDERER_OPENGLES
#elif BGFX_CONFIG_RENDERER_OPENGLES2
return RendererType::OpenGLES;
#else
return RendererType::Null;

View File

@ -132,6 +132,14 @@ namespace stl = std;
#define BGFX_SAMPLER_RENDERTARGET_DEPTH UINT16_C(0x0002)
#define BGFX_SAMPLER_TYPE_MASK UINT16_C(0x0003)
#if BGFX_CONFIG_RENDERER_DIRECT3D9
# define BGFX_RENDERER_NAME "Direct3D 9"
#elif BGFX_CONFIG_RENDERER_OPENGL
# define BGFX_RENDERER_NAME "OpenGL"
#elif BGFX_CONFIG_RENDERER_OPENGLES2
# define BGFX_RENDERER_NAME "OpenGL ES 2"
#endif // BGFX_CONFIG_RENDERER_
namespace bgfx
{
extern const uint32_t g_constantTypeSize[ConstantType::Count];
@ -1088,7 +1096,7 @@ namespace bgfx
void setInstanceDataBuffer(const InstanceDataBuffer* _idb)
{
#if BGFX_CONFIG_RENDERER_OPENGLES
#if BGFX_CONFIG_RENDERER_OPENGLES2
#else
m_state.m_instanceDataOffset = _idb->offset;
m_state.m_instanceDataStride = _idb->stride;
@ -1878,7 +1886,7 @@ namespace bgfx
const InstanceDataBuffer* allocInstanceDataBuffer(uint16_t _num, uint16_t _stride)
{
#if BGFX_CONFIG_RENDERER_OPENGLES
#if BGFX_CONFIG_RENDERER_OPENGLES2
return NULL;
#else
uint16_t stride = BX_ALIGN_16(_stride);

View File

@ -6,21 +6,25 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__
#if !defined(BGFX_CONFIG_RENDERER_DIRECT3D) && !defined(BGFX_CONFIG_RENDERER_OPENGL) && !defined(BGFX_CONFIG_RENDERER_OPENGLES) && !defined(BGFX_CONFIG_RENDERER_NULL)
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D
# define BGFX_CONFIG_RENDERER_DIRECT3D (BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360)
# endif // BGFX_CONFIG_RENDERER_DIRECT3D
#if !defined(BGFX_CONFIG_RENDERER_DIRECT3D9) && !defined(BGFX_CONFIG_RENDERER_DIRECT3D11) && !defined(BGFX_CONFIG_RENDERER_OPENGL) && !defined(BGFX_CONFIG_RENDERER_OPENGLES2) && !defined(BGFX_CONFIG_RENDERER_NULL)
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D9
# define BGFX_CONFIG_RENDERER_DIRECT3D9 (BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360)
# endif // BGFX_CONFIG_RENDERER_DIRECT3D9
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D11
# define BGFX_CONFIG_RENDERER_DIRECT3D11 0
# endif // BGFX_CONFIG_RENDERER_DIRECT3D11
# ifndef BGFX_CONFIG_RENDERER_OPENGL
# define BGFX_CONFIG_RENDERER_OPENGL (BX_PLATFORM_LINUX|BX_PLATFORM_OSX)
# endif // BGFX_CONFIG_RENDERER_OPENGL
# ifndef BGFX_CONFIG_RENDERER_OPENGLES
# define BGFX_CONFIG_RENDERER_OPENGLES (BX_PLATFORM_NACL|BX_PLATFORM_ANDROID|BX_PLATFORM_IOS)
# ifndef BGFX_CONFIG_RENDERER_OPENGLES2
# define BGFX_CONFIG_RENDERER_OPENGLES2 (BX_PLATFORM_NACL|BX_PLATFORM_ANDROID|BX_PLATFORM_IOS)
# endif // BGFX_CONFIG_RENDERER_OPENGLES
# ifndef BGFX_CONFIG_RENDERER_NULL
# define BGFX_CONFIG_RENDERER_NULL (!(BGFX_CONFIG_RENDERER_DIRECT3D|BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES) )
# define BGFX_CONFIG_RENDERER_NULL (!(BGFX_CONFIG_RENDERER_DIRECT3D9|BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES2) )
# endif // BGFX_CONFIG_RENDERER_NULL
#endif // !defined...

141
src/renderer_d3d11.cpp Normal file
View File

@ -0,0 +1,141 @@
/*
* Copyright 2011-2012 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include "bgfx_p.h"
#if BGFX_CONFIG_RENDERER_DIRECT3D11
namespace bgfx
{
void ConstantBuffer::commit()
{
}
void TextVideoMemBlitter::setup()
{
}
void TextVideoMemBlitter::render(uint32_t /*_numIndices*/)
{
}
void Context::flip()
{
}
void Context::rendererInit()
{
}
void Context::rendererShutdown()
{
}
void Context::rendererCreateIndexBuffer(IndexBufferHandle /*_handle*/, Memory* /*_mem*/)
{
}
void Context::rendererDestroyIndexBuffer(IndexBufferHandle /*_handle*/)
{
}
void Context::rendererCreateVertexDecl(VertexDeclHandle /*_handle*/, const VertexDecl& /*_decl*/)
{
}
void Context::rendererDestroyVertexDecl(VertexDeclHandle /*_handle*/)
{
}
void Context::rendererCreateVertexBuffer(VertexBufferHandle /*_handle*/, Memory* /*_mem*/, VertexDeclHandle /*_declHandle*/)
{
}
void Context::rendererDestroyVertexBuffer(VertexBufferHandle /*_handle*/)
{
}
void Context::rendererCreateDynamicIndexBuffer(IndexBufferHandle /*_handle*/, uint32_t /*_size*/)
{
}
void Context::rendererUpdateDynamicIndexBuffer(IndexBufferHandle /*_handle*/, uint32_t /*_offset*/, uint32_t /*_size*/, Memory* /*_mem*/)
{
}
void Context::rendererDestroyDynamicIndexBuffer(IndexBufferHandle /*_handle*/)
{
}
void Context::rendererCreateDynamicVertexBuffer(VertexBufferHandle /*_handle*/, uint32_t /*_size*/)
{
}
void Context::rendererUpdateDynamicVertexBuffer(VertexBufferHandle /*_handle*/, uint32_t /*_offset*/, uint32_t /*_size*/, Memory* /*_mem*/)
{
}
void Context::rendererDestroyDynamicVertexBuffer(VertexBufferHandle /*_handle*/)
{
}
void Context::rendererCreateVertexShader(VertexShaderHandle /*_handle*/, Memory* /*_mem*/)
{
}
void Context::rendererDestroyVertexShader(VertexShaderHandle /*_handle*/)
{
}
void Context::rendererCreateFragmentShader(FragmentShaderHandle /*_handle*/, Memory* /*_mem*/)
{
}
void Context::rendererDestroyFragmentShader(FragmentShaderHandle /*_handle*/)
{
}
void Context::rendererCreateMaterial(MaterialHandle /*_handle*/, VertexShaderHandle /*_vsh*/, FragmentShaderHandle /*_fsh*/)
{
}
void Context::rendererDestroyMaterial(FragmentShaderHandle /*_handle*/)
{
}
void Context::rendererCreateTexture(TextureHandle /*_handle*/, Memory* /*_mem*/, uint32_t /*_flags*/)
{
}
void Context::rendererDestroyTexture(TextureHandle /*_handle*/)
{
}
void Context::rendererCreateRenderTarget(RenderTargetHandle /*_handle*/, uint16_t /*_width*/, uint16_t /*_height*/, uint32_t /*_flags*/, uint32_t /*_textureFlags*/)
{
}
void Context::rendererDestroyRenderTarget(RenderTargetHandle /*_handle*/)
{
}
void Context::rendererCreateUniform(UniformHandle /*_handle*/, ConstantType::Enum /*_type*/, uint16_t /*_num*/, const char* /*_name*/)
{
}
void Context::rendererDestroyUniform(UniformHandle /*_handle*/)
{
}
void Context::rendererSaveScreenShot(Memory* /*_mem*/)
{
}
void Context::rendererSubmit()
{
}
}
#endif // BGFX_CONFIG_RENDERER_DIRECT3D11

View File

@ -5,7 +5,7 @@
#include "bgfx_p.h"
#if BGFX_CONFIG_RENDERER_DIRECT3D
#if BGFX_CONFIG_RENDERER_DIRECT3D9
# include "renderer_d3d9.h"
namespace bgfx
@ -192,7 +192,7 @@ namespace bgfx
m_D3DPERF_BeginEvent = (D3DPERF_BeginEventFunc)GetProcAddress(m_d3d9dll, "D3DPERF_BeginEvent");
m_D3DPERF_EndEvent = (D3DPERF_EndEventFunc)GetProcAddress(m_d3d9dll, "D3DPERF_EndEvent");
#if BGFX_CONFIG_RENDERER_DIRECT3D_EX
#if BGFX_CONFIG_RENDERER_DIRECT3D9EX
Direct3DCreate9ExFunc direct3DCreate9Ex = (Direct3DCreate9ExFunc)GetProcAddress(m_d3d9dll, "Direct3DCreate9Ex");
BGFX_FATAL(NULL != direct3DCreate9Ex, bgfx::Fatal::D3D9_UnableToCreateInterface, "Function Direct3DCreate9Ex not found.");
direct3DCreate9Ex(D3D_SDK_VERSION, &m_d3d9);
@ -247,7 +247,7 @@ namespace bgfx
for (uint32_t ii = 0; ii < countof(behaviorFlags) && NULL == m_device; ++ii)
{
#if BGFX_CONFIG_RENDERER_DIRECT3D_EX
#if BGFX_CONFIG_RENDERER_DIRECT3D9EX
DX_CHECK(m_d3d9->CreateDeviceEx(m_adapter
, m_deviceType
, g_bgfxHwnd
@ -264,7 +264,7 @@ namespace bgfx
, &m_params
, &m_device
) );
#endif // BGFX_CONFIG_RENDERER_DIRECT3D_EX
#endif // BGFX_CONFIG_RENDERER_DIRECT3D9EX
}
BGFX_FATAL(m_device, bgfx::Fatal::D3D9_UnableToCreateDevice, "Unable to create Direct3D9 device.");
@ -560,9 +560,9 @@ namespace bgfx
{
if (NULL != m_device)
{
#if BGFX_CONFIG_RENDERER_DIRECT3D_EX
#if BGFX_CONFIG_RENDERER_DIRECT3D9EX
DX_CHECK(m_device->WaitForVBlank(0) );
#endif // BGFX_CONFIG_RENDERER_DIRECT3D_EX
#endif // BGFX_CONFIG_RENDERER_DIRECT3D9EX
HRESULT hr;
hr = m_device->Present(NULL, NULL, NULL, NULL);
@ -694,13 +694,13 @@ namespace bgfx
D3DPERF_EndEventFunc m_D3DPERF_EndEvent;
#endif // BX_PLATFORM_WINDOWS
#if BGFX_CONFIG_RENDERER_DIRECT3D_EX
#if BGFX_CONFIG_RENDERER_DIRECT3D9EX
IDirect3D9Ex* m_d3d9;
IDirect3DDevice9Ex* m_device;
#else
IDirect3D9* m_d3d9;
IDirect3DDevice9* m_device;
#endif // BGFX_CONFIG_RENDERER_DIRECT3D_EX
#endif // BGFX_CONFIG_RENDERER_DIRECT3D9EX
IDirect3DSurface9* m_backBufferColor;
IDirect3DSurface9* m_backBufferDepthStencil;
@ -2377,6 +2377,7 @@ namespace bgfx
tvm.clear();
uint16_t pos = 10;
tvm.printf(0, 0, 0x8f, " " BGFX_RENDERER_NAME " ");
tvm.printf(10, pos++, 0x8e, " Frame: %3.4f [ms] / %3.2f", frameTime*toMs, freq/frameTime);
tvm.printf(10, pos++, 0x8e, " Draw calls: %4d / CPU %3.4f [ms]"
, m_render->m_num
@ -2415,4 +2416,4 @@ namespace bgfx
}
}
#endif // BGFX_CONFIG_RENDERER_DIRECT3D
#endif // BGFX_CONFIG_RENDERER_DIRECT3D9

View File

@ -6,7 +6,7 @@
#ifndef __RENDERER_D3D9_H__
#define __RENDERER_D3D9_H__
#define BGFX_CONFIG_RENDERER_DIRECT3D_EX (BX_PLATFORM_WINDOWS && 0)
#define BGFX_CONFIG_RENDERER_DIRECT3D9EX (BX_PLATFORM_WINDOWS && 0)
#ifndef D3DSTREAMSOURCE_INDEXEDDATA
# define D3DSTREAMSOURCE_INDEXEDDATA (1<<30)
@ -17,16 +17,16 @@
#endif // D3DSTREAMSOURCE_INSTANCEDATA
#if BX_PLATFORM_WINDOWS
# if !BGFX_CONFIG_RENDERER_DIRECT3D_EX
# if !BGFX_CONFIG_RENDERER_DIRECT3D9EX
# define D3D_DISABLE_9EX
# endif // !BGFX_CONFIG_RENDERER_DIRECT3D_EX
# endif // !BGFX_CONFIG_RENDERER_DIRECT3D9EX
# include <d3d9.h>
# if BGFX_CONFIG_RENDERER_DIRECT3D_EX
# if BGFX_CONFIG_RENDERER_DIRECT3D9EX
typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT SDKVersion, IDirect3D9Ex**);
# else
typedef IDirect3D9* (WINAPI *Direct3DCreate9Func)(UINT SDKVersion);
# endif // BGFX_CONFIG_RENDERER_DIRECT3D_EX
# endif // BGFX_CONFIG_RENDERER_DIRECT3D9EX
typedef int (WINAPI *D3DPERF_BeginEventFunc)(D3DCOLOR col, LPCWSTR wszName);
typedef int (WINAPI *D3DPERF_EndEventFunc)();

View File

@ -5,7 +5,7 @@
#include "bgfx_p.h"
#if (BGFX_CONFIG_RENDERER_OPENGLES|BGFX_CONFIG_RENDERER_OPENGL)
#if (BGFX_CONFIG_RENDERER_OPENGLES2|BGFX_CONFIG_RENDERER_OPENGL)
# include "renderer_gl.h"
# include <bx/timer.h>
# include <bx/uint32_t.h>
@ -2487,6 +2487,7 @@ namespace bgfx
tvm.clear();
uint16_t pos = 10;
tvm.printf(0, 0, 0x8f, " " BGFX_RENDERER_NAME " ");
tvm.printf(10, pos++, 0x8e, " Frame CPU: %3.4f [ms] / %3.2f", double(frameTime)*toMs, freq/frameTime);
tvm.printf(10, pos++, 0x8e, " Draw calls: %4d / CPU %3.4f [ms] %c GPU %3.4f [ms]"
, m_render->m_num

View File

@ -56,7 +56,7 @@
# define GL_VERSION_4_1
# define GL_VERSION_4_2
# include <gl/glext.h>
#elif BGFX_CONFIG_RENDERER_OPENGLES
#elif BGFX_CONFIG_RENDERER_OPENGLES2
# include <GLES2/gl2.h>
# include <GLES2/gl2ext.h>