mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
Fix merge conflict and add check for unix and not apple for glx
Merge branch 'development-gg' into gladdev # Conflicts: # Tools/CMake/libraries/glad.cmake
This commit is contained in:
commit
0296e6d3fd
728 changed files with 83679 additions and 66879 deletions
|
|
@ -119,74 +119,77 @@ void GFXD3D11Device::enumerateAdapters(Vector<GFXAdapter*> &adapterList)
|
|||
|
||||
for(U32 adapterIndex = 0; DXGIFactory->EnumAdapters1(adapterIndex, &EnumAdapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex)
|
||||
{
|
||||
GFXAdapter *toAdd = new GFXAdapter;
|
||||
toAdd->mType = Direct3D11;
|
||||
toAdd->mIndex = adapterIndex;
|
||||
toAdd->mCreateDeviceInstanceDelegate = mCreateDeviceInstance;
|
||||
GFXAdapter *toAdd = new GFXAdapter;
|
||||
toAdd->mType = Direct3D11;
|
||||
toAdd->mIndex = adapterIndex;
|
||||
toAdd->mCreateDeviceInstanceDelegate = mCreateDeviceInstance;
|
||||
|
||||
toAdd->mShaderModel = 5.0f;
|
||||
DXGI_ADAPTER_DESC1 desc;
|
||||
EnumAdapter->GetDesc1(&desc);
|
||||
toAdd->mShaderModel = 5.0f;
|
||||
DXGI_ADAPTER_DESC1 desc;
|
||||
EnumAdapter->GetDesc1(&desc);
|
||||
|
||||
size_t size=wcslen(desc.Description);
|
||||
char *str = new char[size+1];
|
||||
// LUID identifies adapter for oculus rift
|
||||
dMemcpy(&toAdd->mLUID, &desc.AdapterLuid, sizeof(toAdd->mLUID));
|
||||
|
||||
wcstombs(str, desc.Description,size);
|
||||
str[size]='\0';
|
||||
String Description=str;
|
||||
size_t size=wcslen(desc.Description);
|
||||
char *str = new char[size+1];
|
||||
|
||||
wcstombs(str, desc.Description,size);
|
||||
str[size]='\0';
|
||||
String Description=str;
|
||||
SAFE_DELETE_ARRAY(str);
|
||||
|
||||
dStrncpy(toAdd->mName, Description.c_str(), GFXAdapter::MaxAdapterNameLen);
|
||||
dStrncat(toAdd->mName, " (D3D11)", GFXAdapter::MaxAdapterNameLen);
|
||||
dStrncpy(toAdd->mName, Description.c_str(), GFXAdapter::MaxAdapterNameLen);
|
||||
dStrncat(toAdd->mName, " (D3D11)", GFXAdapter::MaxAdapterNameLen);
|
||||
|
||||
IDXGIOutput* pOutput = NULL;
|
||||
HRESULT hr;
|
||||
IDXGIOutput* pOutput = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
hr = EnumAdapter->EnumOutputs(adapterIndex, &pOutput);
|
||||
hr = EnumAdapter->EnumOutputs(adapterIndex, &pOutput);
|
||||
|
||||
if(hr == DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
if(hr == DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
SAFE_RELEASE(EnumAdapter);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateAdapters -> EnumOutputs call failure");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateAdapters -> EnumOutputs call failure");
|
||||
|
||||
UINT numModes = 0;
|
||||
DXGI_MODE_DESC* displayModes = NULL;
|
||||
DXGI_FORMAT format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
UINT numModes = 0;
|
||||
DXGI_MODE_DESC* displayModes = NULL;
|
||||
DXGI_FORMAT format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
|
||||
// Get the number of elements
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, NULL);
|
||||
// Get the number of elements
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, NULL);
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateAdapters -> GetDisplayModeList call failure");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateAdapters -> GetDisplayModeList call failure");
|
||||
|
||||
displayModes = new DXGI_MODE_DESC[numModes];
|
||||
displayModes = new DXGI_MODE_DESC[numModes];
|
||||
|
||||
// Get the list
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, displayModes);
|
||||
// Get the list
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, displayModes);
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateAdapters -> GetDisplayModeList call failure");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateAdapters -> GetDisplayModeList call failure");
|
||||
|
||||
for(U32 numMode = 0; numMode < numModes; ++numMode)
|
||||
{
|
||||
GFXVideoMode vmAdd;
|
||||
for(U32 numMode = 0; numMode < numModes; ++numMode)
|
||||
{
|
||||
GFXVideoMode vmAdd;
|
||||
|
||||
vmAdd.fullScreen = true;
|
||||
vmAdd.bitDepth = 32;
|
||||
vmAdd.refreshRate = displayModes[numMode].RefreshRate.Numerator / displayModes[numMode].RefreshRate.Denominator;
|
||||
vmAdd.resolution.x = displayModes[numMode].Width;
|
||||
vmAdd.resolution.y = displayModes[numMode].Height;
|
||||
toAdd->mAvailableModes.push_back(vmAdd);
|
||||
}
|
||||
vmAdd.fullScreen = true;
|
||||
vmAdd.bitDepth = 32;
|
||||
vmAdd.refreshRate = displayModes[numMode].RefreshRate.Numerator / displayModes[numMode].RefreshRate.Denominator;
|
||||
vmAdd.resolution.x = displayModes[numMode].Width;
|
||||
vmAdd.resolution.y = displayModes[numMode].Height;
|
||||
toAdd->mAvailableModes.push_back(vmAdd);
|
||||
}
|
||||
|
||||
delete[] displayModes;
|
||||
delete[] displayModes;
|
||||
SAFE_RELEASE(pOutput);
|
||||
SAFE_RELEASE(EnumAdapter);
|
||||
adapterList.push_back(toAdd);
|
||||
adapterList.push_back(toAdd);
|
||||
}
|
||||
|
||||
SAFE_RELEASE(DXGIFactory);
|
||||
|
|
@ -207,50 +210,50 @@ void GFXD3D11Device::enumerateVideoModes()
|
|||
|
||||
for(U32 adapterIndex = 0; DXGIFactory->EnumAdapters1(adapterIndex, &EnumAdapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex)
|
||||
{
|
||||
IDXGIOutput* pOutput = NULL;
|
||||
IDXGIOutput* pOutput = NULL;
|
||||
|
||||
hr = EnumAdapter->EnumOutputs(adapterIndex, &pOutput);
|
||||
hr = EnumAdapter->EnumOutputs(adapterIndex, &pOutput);
|
||||
|
||||
if(hr == DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
if(hr == DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
SAFE_RELEASE(EnumAdapter);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateVideoModes -> EnumOutputs call failure");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateVideoModes -> EnumOutputs call failure");
|
||||
|
||||
UINT numModes = 0;
|
||||
DXGI_MODE_DESC* displayModes = NULL;
|
||||
DXGI_FORMAT format = GFXD3D11TextureFormat[GFXFormatR8G8B8A8];
|
||||
UINT numModes = 0;
|
||||
DXGI_MODE_DESC* displayModes = NULL;
|
||||
DXGI_FORMAT format = GFXD3D11TextureFormat[GFXFormatR8G8B8A8];
|
||||
|
||||
// Get the number of elements
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, NULL);
|
||||
// Get the number of elements
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, NULL);
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateVideoModes -> GetDisplayModeList call failure");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateVideoModes -> GetDisplayModeList call failure");
|
||||
|
||||
displayModes = new DXGI_MODE_DESC[numModes];
|
||||
displayModes = new DXGI_MODE_DESC[numModes];
|
||||
|
||||
// Get the list
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, displayModes);
|
||||
// Get the list
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, displayModes);
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateVideoModes -> GetDisplayModeList call failure");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateVideoModes -> GetDisplayModeList call failure");
|
||||
|
||||
for(U32 numMode = 0; numMode < numModes; ++numMode)
|
||||
{
|
||||
GFXVideoMode toAdd;
|
||||
for(U32 numMode = 0; numMode < numModes; ++numMode)
|
||||
{
|
||||
GFXVideoMode toAdd;
|
||||
|
||||
toAdd.fullScreen = false;
|
||||
toAdd.bitDepth = 32;
|
||||
toAdd.refreshRate = displayModes[numMode].RefreshRate.Numerator / displayModes[numMode].RefreshRate.Denominator;
|
||||
toAdd.resolution.x = displayModes[numMode].Width;
|
||||
toAdd.resolution.y = displayModes[numMode].Height;
|
||||
mVideoModes.push_back(toAdd);
|
||||
}
|
||||
toAdd.fullScreen = false;
|
||||
toAdd.bitDepth = 32;
|
||||
toAdd.refreshRate = displayModes[numMode].RefreshRate.Numerator / displayModes[numMode].RefreshRate.Denominator;
|
||||
toAdd.resolution.x = displayModes[numMode].Width;
|
||||
toAdd.resolution.y = displayModes[numMode].Height;
|
||||
mVideoModes.push_back(toAdd);
|
||||
}
|
||||
|
||||
delete[] displayModes;
|
||||
delete[] displayModes;
|
||||
SAFE_RELEASE(pOutput);
|
||||
SAFE_RELEASE(EnumAdapter);
|
||||
}
|
||||
|
|
@ -260,7 +263,7 @@ void GFXD3D11Device::enumerateVideoModes()
|
|||
|
||||
IDXGISwapChain* GFXD3D11Device::getSwapChain()
|
||||
{
|
||||
return mSwapChain;
|
||||
return mSwapChain;
|
||||
}
|
||||
|
||||
void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window)
|
||||
|
|
@ -282,19 +285,19 @@ void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window)
|
|||
// create a device, device context and swap chain using the information in the d3dpp struct
|
||||
HRESULT hres = D3D11CreateDeviceAndSwapChain(NULL,
|
||||
driverType,
|
||||
NULL,
|
||||
createDeviceFlags,
|
||||
NULL,
|
||||
0,
|
||||
D3D11_SDK_VERSION,
|
||||
&d3dpp,
|
||||
&mSwapChain,
|
||||
&mD3DDevice,
|
||||
&deviceFeature,
|
||||
&mD3DDeviceContext);
|
||||
NULL,
|
||||
createDeviceFlags,
|
||||
NULL,
|
||||
0,
|
||||
D3D11_SDK_VERSION,
|
||||
&d3dpp,
|
||||
&mSwapChain,
|
||||
&mD3DDevice,
|
||||
&deviceFeature,
|
||||
&mD3DDeviceContext);
|
||||
|
||||
if(FAILED(hres))
|
||||
{
|
||||
if(FAILED(hres))
|
||||
{
|
||||
#ifdef TORQUE_DEBUG
|
||||
//try again without debug device layer enabled
|
||||
createDeviceFlags &= ~D3D11_CREATE_DEVICE_DEBUG;
|
||||
|
|
@ -312,9 +315,9 @@ void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window)
|
|||
Con::warnf("GFXD3D11Device::init - Debug layers not detected!");
|
||||
mDebugLayers = false;
|
||||
#else
|
||||
AssertFatal(false, "GFXD3D11Device::init - D3D11CreateDeviceAndSwapChain failed!");
|
||||
AssertFatal(false, "GFXD3D11Device::init - D3D11CreateDeviceAndSwapChain failed!");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//set the fullscreen state here if we need to
|
||||
if(mode.fullScreen)
|
||||
|
|
@ -326,79 +329,79 @@ void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window)
|
|||
}
|
||||
}
|
||||
|
||||
mTextureManager = new GFXD3D11TextureManager();
|
||||
mTextureManager = new GFXD3D11TextureManager();
|
||||
|
||||
// Now reacquire all the resources we trashed earlier
|
||||
reacquireDefaultPoolResources();
|
||||
// Now reacquire all the resources we trashed earlier
|
||||
reacquireDefaultPoolResources();
|
||||
//TODO implement feature levels?
|
||||
if (deviceFeature >= D3D_FEATURE_LEVEL_11_0)
|
||||
mPixVersion = 5.0f;
|
||||
else
|
||||
AssertFatal(false, "GFXD3D11Device::init - We don't support anything below feature level 11.");
|
||||
if (deviceFeature >= D3D_FEATURE_LEVEL_11_0)
|
||||
mPixVersion = 5.0f;
|
||||
else
|
||||
AssertFatal(false, "GFXD3D11Device::init - We don't support anything below feature level 11.");
|
||||
|
||||
D3D11_QUERY_DESC queryDesc;
|
||||
D3D11_QUERY_DESC queryDesc;
|
||||
queryDesc.Query = D3D11_QUERY_OCCLUSION;
|
||||
queryDesc.MiscFlags = 0;
|
||||
|
||||
ID3D11Query *testQuery = NULL;
|
||||
ID3D11Query *testQuery = NULL;
|
||||
|
||||
// detect occlusion query support
|
||||
if (SUCCEEDED(mD3DDevice->CreateQuery(&queryDesc, &testQuery))) mOcclusionQuerySupported = true;
|
||||
// detect occlusion query support
|
||||
if (SUCCEEDED(mD3DDevice->CreateQuery(&queryDesc, &testQuery))) mOcclusionQuerySupported = true;
|
||||
|
||||
SAFE_RELEASE(testQuery);
|
||||
|
||||
Con::printf("Hardware occlusion query detected: %s", mOcclusionQuerySupported ? "Yes" : "No");
|
||||
Con::printf("Hardware occlusion query detected: %s", mOcclusionQuerySupported ? "Yes" : "No");
|
||||
|
||||
mCardProfiler = new GFXD3D11CardProfiler();
|
||||
mCardProfiler->init();
|
||||
mCardProfiler = new GFXD3D11CardProfiler();
|
||||
mCardProfiler->init();
|
||||
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.Width = mode.resolution.x;
|
||||
desc.Height = mode.resolution.y;
|
||||
desc.SampleDesc.Count =1;
|
||||
desc.SampleDesc.Quality =0;
|
||||
desc.MiscFlags = 0;
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.Width = mode.resolution.x;
|
||||
desc.Height = mode.resolution.y;
|
||||
desc.SampleDesc.Count =1;
|
||||
desc.SampleDesc.Quality =0;
|
||||
desc.MiscFlags = 0;
|
||||
|
||||
HRESULT hr = mD3DDevice->CreateTexture2D(&desc, NULL, &mDeviceDepthStencil);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::init - couldn't create device's depth-stencil surface.");
|
||||
}
|
||||
HRESULT hr = mD3DDevice->CreateTexture2D(&desc, NULL, &mDeviceDepthStencil);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::init - couldn't create device's depth-stencil surface.");
|
||||
}
|
||||
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC depthDesc;
|
||||
depthDesc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
depthDesc.Flags =0 ;
|
||||
depthDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
depthDesc.Texture2D.MipSlice = 0;
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC depthDesc;
|
||||
depthDesc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
depthDesc.Flags =0 ;
|
||||
depthDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
depthDesc.Texture2D.MipSlice = 0;
|
||||
|
||||
hr = mD3DDevice->CreateDepthStencilView(mDeviceDepthStencil, &depthDesc, &mDeviceDepthStencilView);
|
||||
hr = mD3DDevice->CreateDepthStencilView(mDeviceDepthStencil, &depthDesc, &mDeviceDepthStencilView);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::init - couldn't create depth stencil view");
|
||||
}
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::init - couldn't create depth stencil view");
|
||||
}
|
||||
|
||||
hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mDeviceBackbuffer);
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::init - coudln't retrieve backbuffer ref");
|
||||
hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mDeviceBackbuffer);
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::init - coudln't retrieve backbuffer ref");
|
||||
|
||||
//create back buffer view
|
||||
D3D11_RENDER_TARGET_VIEW_DESC RTDesc;
|
||||
//create back buffer view
|
||||
D3D11_RENDER_TARGET_VIEW_DESC RTDesc;
|
||||
|
||||
RTDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
RTDesc.Texture2D.MipSlice = 0;
|
||||
RTDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
RTDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
RTDesc.Texture2D.MipSlice = 0;
|
||||
RTDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
|
||||
hr = mD3DDevice->CreateRenderTargetView(mDeviceBackbuffer, &RTDesc, &mDeviceBackBufferView);
|
||||
hr = mD3DDevice->CreateRenderTargetView(mDeviceBackbuffer, &RTDesc, &mDeviceBackBufferView);
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::init - couldn't create back buffer target view");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::init - couldn't create back buffer target view");
|
||||
|
||||
#ifdef TORQUE_DEBUG
|
||||
String backBufferName = "MainBackBuffer";
|
||||
|
|
@ -416,8 +419,8 @@ void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window)
|
|||
|
||||
gScreenShot = new ScreenShotD3D11;
|
||||
|
||||
mInitialized = true;
|
||||
deviceInited();
|
||||
mInitialized = true;
|
||||
deviceInited();
|
||||
}
|
||||
|
||||
// Supress any debug layer messages we don't want to see
|
||||
|
|
@ -486,28 +489,28 @@ GFXTextureTarget* GFXD3D11Device::allocRenderToTextureTarget()
|
|||
|
||||
void GFXD3D11Device::reset(DXGI_SWAP_CHAIN_DESC &d3dpp)
|
||||
{
|
||||
if (!mD3DDevice)
|
||||
return;
|
||||
if (!mD3DDevice)
|
||||
return;
|
||||
|
||||
mInitialized = false;
|
||||
mInitialized = false;
|
||||
|
||||
// Clean up some commonly dangling state. This helps prevents issues with
|
||||
// items that are destroyed by the texture manager callbacks and recreated
|
||||
// later, but still left bound.
|
||||
setVertexBuffer(NULL);
|
||||
setPrimitiveBuffer(NULL);
|
||||
for (S32 i = 0; i<getNumSamplers(); i++)
|
||||
setTexture(i, NULL);
|
||||
// Clean up some commonly dangling state. This helps prevents issues with
|
||||
// items that are destroyed by the texture manager callbacks and recreated
|
||||
// later, but still left bound.
|
||||
setVertexBuffer(NULL);
|
||||
setPrimitiveBuffer(NULL);
|
||||
for (S32 i = 0; i<getNumSamplers(); i++)
|
||||
setTexture(i, NULL);
|
||||
|
||||
mD3DDeviceContext->ClearState();
|
||||
mD3DDeviceContext->ClearState();
|
||||
|
||||
DXGI_MODE_DESC displayModes;
|
||||
displayModes.Format = d3dpp.BufferDesc.Format;
|
||||
displayModes.Height = d3dpp.BufferDesc.Height;
|
||||
displayModes.Width = d3dpp.BufferDesc.Width;
|
||||
displayModes.RefreshRate = d3dpp.BufferDesc.RefreshRate;
|
||||
displayModes.Scaling = d3dpp.BufferDesc.Scaling;
|
||||
displayModes.ScanlineOrdering = d3dpp.BufferDesc.ScanlineOrdering;
|
||||
DXGI_MODE_DESC displayModes;
|
||||
displayModes.Format = d3dpp.BufferDesc.Format;
|
||||
displayModes.Height = d3dpp.BufferDesc.Height;
|
||||
displayModes.Width = d3dpp.BufferDesc.Width;
|
||||
displayModes.RefreshRate = d3dpp.BufferDesc.RefreshRate;
|
||||
displayModes.Scaling = d3dpp.BufferDesc.Scaling;
|
||||
displayModes.ScanlineOrdering = d3dpp.BufferDesc.ScanlineOrdering;
|
||||
|
||||
HRESULT hr;
|
||||
if (!d3dpp.Windowed)
|
||||
|
|
@ -520,79 +523,79 @@ void GFXD3D11Device::reset(DXGI_SWAP_CHAIN_DESC &d3dpp)
|
|||
}
|
||||
}
|
||||
|
||||
// First release all the stuff we allocated from D3DPOOL_DEFAULT
|
||||
releaseDefaultPoolResources();
|
||||
// First release all the stuff we allocated from D3DPOOL_DEFAULT
|
||||
releaseDefaultPoolResources();
|
||||
|
||||
//release the backbuffer, depthstencil, and their views
|
||||
SAFE_RELEASE(mDeviceBackBufferView);
|
||||
SAFE_RELEASE(mDeviceBackbuffer);
|
||||
SAFE_RELEASE(mDeviceDepthStencilView);
|
||||
SAFE_RELEASE(mDeviceDepthStencil);
|
||||
//release the backbuffer, depthstencil, and their views
|
||||
SAFE_RELEASE(mDeviceBackBufferView);
|
||||
SAFE_RELEASE(mDeviceBackbuffer);
|
||||
SAFE_RELEASE(mDeviceDepthStencilView);
|
||||
SAFE_RELEASE(mDeviceDepthStencil);
|
||||
|
||||
hr = mSwapChain->ResizeBuffers(d3dpp.BufferCount, d3dpp.BufferDesc.Width, d3dpp.BufferDesc.Height, d3dpp.BufferDesc.Format, d3dpp.Windowed ? 0 : DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "D3D11Device::reset - failed to resize back buffer!");
|
||||
}
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "D3D11Device::reset - failed to resize back buffer!");
|
||||
}
|
||||
|
||||
//recreate backbuffer view. depth stencil view and texture
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.Width = d3dpp.BufferDesc.Width;
|
||||
desc.Height = d3dpp.BufferDesc.Height;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.MiscFlags = 0;
|
||||
//recreate backbuffer view. depth stencil view and texture
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.Width = d3dpp.BufferDesc.Width;
|
||||
desc.Height = d3dpp.BufferDesc.Height;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.MiscFlags = 0;
|
||||
|
||||
hr = mD3DDevice->CreateTexture2D(&desc, NULL, &mDeviceDepthStencil);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::reset - couldn't create device's depth-stencil surface.");
|
||||
}
|
||||
hr = mD3DDevice->CreateTexture2D(&desc, NULL, &mDeviceDepthStencil);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::reset - couldn't create device's depth-stencil surface.");
|
||||
}
|
||||
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC depthDesc;
|
||||
depthDesc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
depthDesc.Flags = 0;
|
||||
depthDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
depthDesc.Texture2D.MipSlice = 0;
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC depthDesc;
|
||||
depthDesc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
depthDesc.Flags = 0;
|
||||
depthDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
depthDesc.Texture2D.MipSlice = 0;
|
||||
|
||||
hr = mD3DDevice->CreateDepthStencilView(mDeviceDepthStencil, &depthDesc, &mDeviceDepthStencilView);
|
||||
hr = mD3DDevice->CreateDepthStencilView(mDeviceDepthStencil, &depthDesc, &mDeviceDepthStencilView);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::reset - couldn't create depth stencil view");
|
||||
}
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::reset - couldn't create depth stencil view");
|
||||
}
|
||||
|
||||
hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mDeviceBackbuffer);
|
||||
if (FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::reset - coudln't retrieve backbuffer ref");
|
||||
hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mDeviceBackbuffer);
|
||||
if (FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::reset - coudln't retrieve backbuffer ref");
|
||||
|
||||
//create back buffer view
|
||||
D3D11_RENDER_TARGET_VIEW_DESC RTDesc;
|
||||
//create back buffer view
|
||||
D3D11_RENDER_TARGET_VIEW_DESC RTDesc;
|
||||
|
||||
RTDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
RTDesc.Texture2D.MipSlice = 0;
|
||||
RTDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
RTDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
RTDesc.Texture2D.MipSlice = 0;
|
||||
RTDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
|
||||
hr = mD3DDevice->CreateRenderTargetView(mDeviceBackbuffer, &RTDesc, &mDeviceBackBufferView);
|
||||
hr = mD3DDevice->CreateRenderTargetView(mDeviceBackbuffer, &RTDesc, &mDeviceBackBufferView);
|
||||
|
||||
if (FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::reset - couldn't create back buffer target view");
|
||||
if (FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::reset - couldn't create back buffer target view");
|
||||
|
||||
mD3DDeviceContext->OMSetRenderTargets(1, &mDeviceBackBufferView, mDeviceDepthStencilView);
|
||||
|
||||
hr = mSwapChain->SetFullscreenState(!d3dpp.Windowed, NULL);
|
||||
hr = mSwapChain->SetFullscreenState(!d3dpp.Windowed, NULL);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "D3D11Device::reset - failed to change screen states!");
|
||||
}
|
||||
}
|
||||
|
||||
//Microsoft recommend this, see DXGI documentation
|
||||
if (!d3dpp.Windowed)
|
||||
|
|
@ -607,13 +610,13 @@ void GFXD3D11Device::reset(DXGI_SWAP_CHAIN_DESC &d3dpp)
|
|||
}
|
||||
}
|
||||
|
||||
mInitialized = true;
|
||||
mInitialized = true;
|
||||
|
||||
// Now re aquire all the resources we trashed earlier
|
||||
reacquireDefaultPoolResources();
|
||||
// Now re aquire all the resources we trashed earlier
|
||||
reacquireDefaultPoolResources();
|
||||
|
||||
// Mark everything dirty and flush to card, for sanity.
|
||||
updateStates(true);
|
||||
// Mark everything dirty and flush to card, for sanity.
|
||||
updateStates(true);
|
||||
}
|
||||
|
||||
class GFXPCD3D11RegisterDevice
|
||||
|
|
@ -896,20 +899,20 @@ void GFXD3D11Device::_updateRenderTargets()
|
|||
mRTDirty = false;
|
||||
}
|
||||
|
||||
if (mViewportDirty)
|
||||
{
|
||||
D3D11_VIEWPORT viewport;
|
||||
if (mViewportDirty)
|
||||
{
|
||||
D3D11_VIEWPORT viewport;
|
||||
|
||||
viewport.TopLeftX = mViewport.point.x;
|
||||
viewport.TopLeftY = mViewport.point.y;
|
||||
viewport.Width = mViewport.extent.x;
|
||||
viewport.Height = mViewport.extent.y;
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
viewport.TopLeftX = mViewport.point.x;
|
||||
viewport.TopLeftY = mViewport.point.y;
|
||||
viewport.Width = mViewport.extent.x;
|
||||
viewport.Height = mViewport.extent.y;
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
|
||||
mD3DDeviceContext->RSSetViewports(1, &viewport);
|
||||
mD3DDeviceContext->RSSetViewports(1, &viewport);
|
||||
|
||||
mViewportDirty = false;
|
||||
mViewportDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -967,35 +970,35 @@ void GFXD3D11Device::releaseDefaultPoolResources()
|
|||
|
||||
void GFXD3D11Device::reacquireDefaultPoolResources()
|
||||
{
|
||||
// Now do the dynamic index buffers
|
||||
if( mDynamicPB == NULL )
|
||||
mDynamicPB = new GFXD3D11PrimitiveBuffer(this, 0, 0, GFXBufferTypeDynamic);
|
||||
// Now do the dynamic index buffers
|
||||
if( mDynamicPB == NULL )
|
||||
mDynamicPB = new GFXD3D11PrimitiveBuffer(this, 0, 0, GFXBufferTypeDynamic);
|
||||
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = sizeof(U16) * MAX_DYNAMIC_INDICES;
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = sizeof(U16) * MAX_DYNAMIC_INDICES;
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &mDynamicPB->ib);
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &mDynamicPB->ib);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate dynamic IB");
|
||||
}
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate dynamic IB");
|
||||
}
|
||||
|
||||
// Walk the resource list and zombify everything.
|
||||
GFXResource *walk = mResourceListHead;
|
||||
while(walk)
|
||||
{
|
||||
walk->resurrect();
|
||||
walk = walk->getNextResource();
|
||||
}
|
||||
// Walk the resource list and zombify everything.
|
||||
GFXResource *walk = mResourceListHead;
|
||||
while(walk)
|
||||
{
|
||||
walk->resurrect();
|
||||
walk = walk->getNextResource();
|
||||
}
|
||||
|
||||
if(mTextureManager)
|
||||
mTextureManager->resurrect();
|
||||
if(mTextureManager)
|
||||
mTextureManager->resurrect();
|
||||
}
|
||||
|
||||
GFXD3D11VertexBuffer* GFXD3D11Device::findVBPool( const GFXVertexFormat *vertexFormat, U32 vertsNeeded )
|
||||
|
|
@ -1011,40 +1014,40 @@ GFXD3D11VertexBuffer* GFXD3D11Device::findVBPool( const GFXVertexFormat *vertexF
|
|||
|
||||
GFXD3D11VertexBuffer * GFXD3D11Device::createVBPool( const GFXVertexFormat *vertexFormat, U32 vertSize )
|
||||
{
|
||||
PROFILE_SCOPE( GFXD3D11Device_createVBPool );
|
||||
PROFILE_SCOPE( GFXD3D11Device_createVBPool );
|
||||
|
||||
// this is a bit funky, but it will avoid problems with (lack of) copy constructors
|
||||
// with a push_back() situation
|
||||
mVolatileVBList.increment();
|
||||
StrongRefPtr<GFXD3D11VertexBuffer> newBuff;
|
||||
mVolatileVBList.last() = new GFXD3D11VertexBuffer();
|
||||
newBuff = mVolatileVBList.last();
|
||||
// this is a bit funky, but it will avoid problems with (lack of) copy constructors
|
||||
// with a push_back() situation
|
||||
mVolatileVBList.increment();
|
||||
StrongRefPtr<GFXD3D11VertexBuffer> newBuff;
|
||||
mVolatileVBList.last() = new GFXD3D11VertexBuffer();
|
||||
newBuff = mVolatileVBList.last();
|
||||
|
||||
newBuff->mNumVerts = 0;
|
||||
newBuff->mBufferType = GFXBufferTypeVolatile;
|
||||
newBuff->mVertexFormat.copy( *vertexFormat );
|
||||
newBuff->mVertexSize = vertSize;
|
||||
newBuff->mDevice = this;
|
||||
newBuff->mNumVerts = 0;
|
||||
newBuff->mBufferType = GFXBufferTypeVolatile;
|
||||
newBuff->mVertexFormat.copy( *vertexFormat );
|
||||
newBuff->mVertexSize = vertSize;
|
||||
newBuff->mDevice = this;
|
||||
|
||||
// Requesting it will allocate it.
|
||||
vertexFormat->getDecl();
|
||||
// Requesting it will allocate it.
|
||||
vertexFormat->getDecl();
|
||||
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = vertSize * MAX_DYNAMIC_VERTS;
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = vertSize * MAX_DYNAMIC_VERTS;
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &newBuff->vb);
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &newBuff->vb);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate dynamic VB");
|
||||
}
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate dynamic VB");
|
||||
}
|
||||
|
||||
return newBuff;
|
||||
return newBuff;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -1100,30 +1103,30 @@ void GFXD3D11Device::setClipRect( const RectI &inRect )
|
|||
|
||||
void GFXD3D11Device::setVertexStream( U32 stream, GFXVertexBuffer *buffer )
|
||||
{
|
||||
GFXD3D11VertexBuffer *d3dBuffer = static_cast<GFXD3D11VertexBuffer*>( buffer );
|
||||
GFXD3D11VertexBuffer *d3dBuffer = static_cast<GFXD3D11VertexBuffer*>( buffer );
|
||||
|
||||
if ( stream == 0 )
|
||||
{
|
||||
// Set the volatile buffer which is used to
|
||||
// offset the start index when doing draw calls.
|
||||
if ( d3dBuffer && d3dBuffer->mVolatileStart > 0 )
|
||||
mVolatileVB = d3dBuffer;
|
||||
else
|
||||
mVolatileVB = NULL;
|
||||
}
|
||||
if ( stream == 0 )
|
||||
{
|
||||
// Set the volatile buffer which is used to
|
||||
// offset the start index when doing draw calls.
|
||||
if ( d3dBuffer && d3dBuffer->mVolatileStart > 0 )
|
||||
mVolatileVB = d3dBuffer;
|
||||
else
|
||||
mVolatileVB = NULL;
|
||||
}
|
||||
|
||||
// NOTE: We do not use the stream offset here for stream 0
|
||||
// as that feature is *supposedly* not as well supported as
|
||||
// using the start index in drawPrimitive.
|
||||
//
|
||||
// If we can verify that this is not the case then we should
|
||||
// start using this method exclusively for all streams.
|
||||
// NOTE: We do not use the stream offset here for stream 0
|
||||
// as that feature is *supposedly* not as well supported as
|
||||
// using the start index in drawPrimitive.
|
||||
//
|
||||
// If we can verify that this is not the case then we should
|
||||
// start using this method exclusively for all streams.
|
||||
|
||||
U32 strides[1] = { d3dBuffer ? d3dBuffer->mVertexSize : 0 };
|
||||
U32 offset = d3dBuffer && stream != 0 ? d3dBuffer->mVolatileStart * d3dBuffer->mVertexSize : 0;
|
||||
ID3D11Buffer* buff = d3dBuffer ? d3dBuffer->vb : NULL;
|
||||
U32 strides[1] = { d3dBuffer ? d3dBuffer->mVertexSize : 0 };
|
||||
U32 offset = d3dBuffer && stream != 0 ? d3dBuffer->mVolatileStart * d3dBuffer->mVertexSize : 0;
|
||||
ID3D11Buffer* buff = d3dBuffer ? d3dBuffer->vb : NULL;
|
||||
|
||||
getDeviceContext()->IASetVertexBuffers(stream, 1, &buff, strides, &offset);
|
||||
getDeviceContext()->IASetVertexBuffers(stream, 1, &buff, strides, &offset);
|
||||
}
|
||||
|
||||
void GFXD3D11Device::setVertexStreamFrequency( U32 stream, U32 frequency )
|
||||
|
|
@ -1176,7 +1179,7 @@ void GFXD3D11Device::drawPrimitive( GFXPrimitiveType primType, U32 vertexStart,
|
|||
setShaderConstBufferInternal(mCurrentShaderConstBuffer);
|
||||
|
||||
if ( mVolatileVB )
|
||||
vertexStart += mVolatileVB->mVolatileStart;
|
||||
vertexStart += mVolatileVB->mVolatileStart;
|
||||
|
||||
mD3DDeviceContext->IASetPrimitiveTopology(GFXD3D11PrimType[primType]);
|
||||
|
||||
|
|
@ -1240,23 +1243,23 @@ void GFXD3D11Device::setShader(GFXShader *shader, bool force)
|
|||
{
|
||||
if(shader)
|
||||
{
|
||||
GFXD3D11Shader *d3dShader = static_cast<GFXD3D11Shader*>(shader);
|
||||
GFXD3D11Shader *d3dShader = static_cast<GFXD3D11Shader*>(shader);
|
||||
|
||||
if (d3dShader->mPixShader != mLastPixShader || force)
|
||||
{
|
||||
mD3DDeviceContext->PSSetShader( d3dShader->mPixShader, NULL, 0);
|
||||
mLastPixShader = d3dShader->mPixShader;
|
||||
}
|
||||
{
|
||||
mD3DDeviceContext->PSSetShader( d3dShader->mPixShader, NULL, 0);
|
||||
mLastPixShader = d3dShader->mPixShader;
|
||||
}
|
||||
|
||||
if (d3dShader->mVertShader != mLastVertShader || force)
|
||||
{
|
||||
mD3DDeviceContext->VSSetShader( d3dShader->mVertShader, NULL, 0);
|
||||
mLastVertShader = d3dShader->mVertShader;
|
||||
}
|
||||
{
|
||||
mD3DDeviceContext->VSSetShader( d3dShader->mVertShader, NULL, 0);
|
||||
mLastVertShader = d3dShader->mVertShader;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setupGenericShaders();
|
||||
setupGenericShaders();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1283,7 +1286,7 @@ GFXPrimitiveBuffer * GFXD3D11Device::allocPrimitiveBuffer(U32 numIndices, U32 nu
|
|||
|
||||
case GFXBufferTypeDynamic:
|
||||
case GFXBufferTypeVolatile:
|
||||
usage = D3D11_USAGE_DYNAMIC;
|
||||
usage = D3D11_USAGE_DYNAMIC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1301,24 +1304,24 @@ GFXPrimitiveBuffer * GFXD3D11Device::allocPrimitiveBuffer(U32 numIndices, U32 nu
|
|||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, get it as a seperate buffer...
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = sizeof(U16) * numIndices;
|
||||
desc.Usage = usage;
|
||||
if(bufferType == GFXBufferTypeDynamic)
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // We never allow reading from a primitive buffer.
|
||||
else
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
// Otherwise, get it as a seperate buffer...
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = sizeof(U16) * numIndices;
|
||||
desc.Usage = usage;
|
||||
if(bufferType == GFXBufferTypeDynamic)
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // We never allow reading from a primitive buffer.
|
||||
else
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &res->ib);
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &res->ib);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate an index buffer.");
|
||||
}
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate an index buffer.");
|
||||
}
|
||||
}
|
||||
|
||||
if (data)
|
||||
|
|
@ -1362,7 +1365,7 @@ GFXVertexBuffer * GFXD3D11Device::allocVertexBuffer(U32 numVerts, const GFXVerte
|
|||
|
||||
case GFXBufferTypeDynamic:
|
||||
case GFXBufferTypeVolatile:
|
||||
usage = D3D11_USAGE_DYNAMIC;
|
||||
usage = D3D11_USAGE_DYNAMIC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1377,27 +1380,27 @@ GFXVertexBuffer * GFXD3D11Device::allocVertexBuffer(U32 numVerts, const GFXVerte
|
|||
}
|
||||
else
|
||||
{
|
||||
// Requesting it will allocate it.
|
||||
vertexFormat->getDecl(); //-ALEX disabled to postpone until after shader is actually set...
|
||||
// Requesting it will allocate it.
|
||||
vertexFormat->getDecl(); //-ALEX disabled to postpone until after shader is actually set...
|
||||
|
||||
// Get a new buffer...
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = vertSize * numVerts;
|
||||
desc.Usage = usage;
|
||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
if(bufferType == GFXBufferTypeDynamic)
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // We never allow reading from a vertex buffer.
|
||||
else
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
// Get a new buffer...
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = vertSize * numVerts;
|
||||
desc.Usage = usage;
|
||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
if(bufferType == GFXBufferTypeDynamic)
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // We never allow reading from a vertex buffer.
|
||||
else
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &res->vb);
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &res->vb);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate VB");
|
||||
}
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate VB");
|
||||
}
|
||||
}
|
||||
|
||||
res->mNumVerts = numVerts;
|
||||
|
|
@ -1595,7 +1598,6 @@ GFXVertexDecl* GFXD3D11Device::allocVertexDecl( const GFXVertexFormat *vertexFor
|
|||
S32 elemIndex = 0;
|
||||
for (S32 i = 0; i < elemCount; i++, elemIndex++)
|
||||
{
|
||||
|
||||
const GFXVertexElement &element = vertexFormat->getElement(elemIndex);
|
||||
|
||||
stream = element.getStreamIndex();
|
||||
|
|
@ -1687,9 +1689,9 @@ void GFXD3D11Device::setTextureInternal( U32 textureUnit, const GFXTextureObject
|
|||
{
|
||||
if( texture == NULL )
|
||||
{
|
||||
ID3D11ShaderResourceView *pView = NULL;
|
||||
mD3DDeviceContext->PSSetShaderResources(textureUnit, 1, &pView);
|
||||
return;
|
||||
ID3D11ShaderResourceView *pView = NULL;
|
||||
mD3DDeviceContext->PSSetShaderResources(textureUnit, 1, &pView);
|
||||
return;
|
||||
}
|
||||
|
||||
GFXD3D11TextureObject *tex = (GFXD3D11TextureObject*)(texture);
|
||||
|
|
@ -1701,23 +1703,23 @@ GFXFence *GFXD3D11Device::createFence()
|
|||
// Figure out what fence type we should be making if we don't know
|
||||
if( mCreateFenceType == -1 )
|
||||
{
|
||||
D3D11_QUERY_DESC desc;
|
||||
desc.MiscFlags = 0;
|
||||
desc.Query = D3D11_QUERY_EVENT;
|
||||
D3D11_QUERY_DESC desc;
|
||||
desc.MiscFlags = 0;
|
||||
desc.Query = D3D11_QUERY_EVENT;
|
||||
|
||||
ID3D11Query *testQuery = NULL;
|
||||
ID3D11Query *testQuery = NULL;
|
||||
|
||||
HRESULT hRes = mD3DDevice->CreateQuery(&desc, &testQuery);
|
||||
HRESULT hRes = mD3DDevice->CreateQuery(&desc, &testQuery);
|
||||
|
||||
if(FAILED(hRes))
|
||||
{
|
||||
mCreateFenceType = true;
|
||||
}
|
||||
if(FAILED(hRes))
|
||||
{
|
||||
mCreateFenceType = true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
mCreateFenceType = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mCreateFenceType = false;
|
||||
}
|
||||
|
||||
SAFE_RELEASE(testQuery);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@
|
|||
|
||||
class PlatformWindow;
|
||||
class GFXD3D11ShaderConstBuffer;
|
||||
class OculusVRHMDDevice;
|
||||
class D3D11OculusTexture;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -53,6 +55,8 @@ class GFXD3D11Device : public GFXDevice
|
|||
friend class GFXD3D11TextureObject;
|
||||
friend class GFXD3D11TextureTarget;
|
||||
friend class GFXD3D11WindowTarget;
|
||||
friend class OculusVRHMDDevice;
|
||||
friend class D3D11OculusTexture;
|
||||
|
||||
virtual GFXFormat selectSupportedFormat(GFXTextureProfile *profile,
|
||||
const Vector<GFXFormat> &formats, bool texture, bool mustblend, bool mustfilter);
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ void GFXD3D11EnumTranslate::init()
|
|||
GFXD3D11TextureFormat[GFXFormatD24FS8] = DXGI_FORMAT_UNKNOWN;
|
||||
GFXD3D11TextureFormat[GFXFormatD16] = DXGI_FORMAT_D16_UNORM;
|
||||
GFXD3D11TextureFormat[GFXFormatR8G8B8A8_SRGB] = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
|
||||
GFXD3D11TextureFormat[GFXFormatR8G8B8A8_LINEAR_FORCE] = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
GFXD3D11TextureFilter[GFXTextureFilterNone] = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
|
|
|
|||
|
|
@ -97,9 +97,9 @@ void GFXD3D11TextureTarget::attachTexture( RenderSlot slot, GFXTextureObject *te
|
|||
if( tex == GFXTextureTarget::sDefaultDepthStencil )
|
||||
{
|
||||
mTargets[slot] = D3D11->mDeviceDepthStencil;
|
||||
mTargetViews[slot] = D3D11->mDeviceDepthStencilView;
|
||||
mTargets[slot]->AddRef();
|
||||
mTargetViews[slot]->AddRef();
|
||||
mTargetViews[slot] = D3D11->mDeviceDepthStencilView;
|
||||
mTargets[slot]->AddRef();
|
||||
mTargetViews[slot]->AddRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -110,14 +110,14 @@ void GFXD3D11TextureTarget::attachTexture( RenderSlot slot, GFXTextureObject *te
|
|||
|
||||
// Grab the surface level.
|
||||
if( slot == DepthStencil )
|
||||
{
|
||||
{
|
||||
mTargets[slot] = d3dto->getSurface();
|
||||
if ( mTargets[slot] )
|
||||
mTargets[slot]->AddRef();
|
||||
|
||||
mTargetViews[slot] = d3dto->getDSView();
|
||||
if( mTargetViews[slot])
|
||||
mTargetViews[slot]->AddRef();
|
||||
mTargetViews[slot] = d3dto->getDSView();
|
||||
if( mTargetViews[slot])
|
||||
mTargetViews[slot]->AddRef();
|
||||
|
||||
}
|
||||
else
|
||||
|
|
@ -126,12 +126,12 @@ void GFXD3D11TextureTarget::attachTexture( RenderSlot slot, GFXTextureObject *te
|
|||
// if the surface that it needs to render to is different than the mip level
|
||||
// in the actual texture. This will happen with MSAA.
|
||||
if( d3dto->getSurface() == NULL )
|
||||
{
|
||||
{
|
||||
|
||||
mTargets[slot] = d3dto->get2DTex();
|
||||
mTargets[slot]->AddRef();
|
||||
mTargetViews[slot] = d3dto->getRTView();
|
||||
mTargetViews[slot]->AddRef();
|
||||
mTargets[slot] = d3dto->get2DTex();
|
||||
mTargets[slot]->AddRef();
|
||||
mTargetViews[slot] = d3dto->getRTView();
|
||||
mTargetViews[slot]->AddRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -163,6 +163,13 @@ void GFXD3D11TextureTarget::attachTexture( RenderSlot slot, GFXTextureObject *te
|
|||
mTargetSize = Point2I(sd.Width, sd.Height);
|
||||
|
||||
S32 format = sd.Format;
|
||||
|
||||
if (format == DXGI_FORMAT_R8G8B8A8_TYPELESS || format == DXGI_FORMAT_B8G8R8A8_TYPELESS)
|
||||
{
|
||||
mTargetFormat = GFXFormatR8G8B8A8;
|
||||
return;
|
||||
}
|
||||
|
||||
GFXREVERSE_LOOKUP( GFXD3D11TextureFormat, GFXFormat, format );
|
||||
mTargetFormat = (GFXFormat)format;
|
||||
}
|
||||
|
|
@ -276,7 +283,7 @@ void GFXD3D11TextureTarget::resolve()
|
|||
if (mResolveTargets[i])
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
mTargets[i]->GetDesc(&desc);
|
||||
mTargets[i]->GetDesc(&desc);
|
||||
D3D11DEVICECONTEXT->CopySubresourceRegion(mResolveTargets[i]->get2DTex(), 0, 0, 0, 0, mTargets[i], 0, NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -400,10 +407,10 @@ void GFXD3D11WindowTarget::activate()
|
|||
|
||||
void GFXD3D11WindowTarget::resolveTo(GFXTextureObject *tex)
|
||||
{
|
||||
GFXDEBUGEVENT_SCOPE(GFXPCD3D11WindowTarget_resolveTo, ColorI::RED);
|
||||
GFXDEBUGEVENT_SCOPE(GFXPCD3D11WindowTarget_resolveTo, ColorI::RED);
|
||||
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
ID3D11Texture2D* surf = ((GFXD3D11TextureObject*)(tex))->get2DTex();
|
||||
surf->GetDesc(&desc);
|
||||
D3D11DEVICECONTEXT->ResolveSubresource(surf, 0, D3D11->mDeviceBackbuffer, 0, desc.Format);
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
ID3D11Texture2D* surf = ((GFXD3D11TextureObject*)(tex))->get2DTex();
|
||||
surf->GetDesc(&desc);
|
||||
D3D11DEVICECONTEXT->ResolveSubresource(surf, 0, D3D11->mDeviceBackbuffer, 0, desc.Format);
|
||||
}
|
||||
|
|
@ -180,8 +180,8 @@ bool GFXD3D11TextureObject::copyToBmp(GBitmap* bmp)
|
|||
// check format limitations
|
||||
// at the moment we only support RGBA for the source (other 4 byte formats should
|
||||
// be easy to add though)
|
||||
AssertFatal(mFormat == GFXFormatR8G8B8A8, "copyToBmp: invalid format");
|
||||
if (mFormat != GFXFormatR8G8B8A8)
|
||||
AssertFatal(mFormat == GFXFormatR8G8B8A8 || mFormat == GFXFormatR8G8B8A8_LINEAR_FORCE, "copyToBmp: invalid format");
|
||||
if (mFormat != GFXFormatR8G8B8A8 && mFormat != GFXFormatR8G8B8A8_LINEAR_FORCE)
|
||||
return false;
|
||||
|
||||
PROFILE_START(GFXD3D11TextureObject_copyToBmp);
|
||||
|
|
@ -197,7 +197,7 @@ bool GFXD3D11TextureObject::copyToBmp(GBitmap* bmp)
|
|||
const U32 sourceBytesPerPixel = 4;
|
||||
U32 destBytesPerPixel = 0;
|
||||
|
||||
if(bmp->getFormat() == GFXFormatR8G8B8A8)
|
||||
if (bmp->getFormat() == GFXFormatR8G8B8A8 || bmp->getFormat() == GFXFormatR8G8B8A8_LINEAR_FORCE)
|
||||
destBytesPerPixel = 4;
|
||||
else if(bmp->getFormat() == GFXFormatR8G8B8)
|
||||
destBytesPerPixel = 3;
|
||||
|
|
|
|||
|
|
@ -176,7 +176,6 @@ bool GFXD3D9ShaderBufferLayout::setMatrix(const ParamDesc& pd, const GFXShaderCo
|
|||
}
|
||||
else if (pd.constType == GFXSCT_Float4x3)
|
||||
{
|
||||
F32 buffer[4*4];
|
||||
const U32 csize = 48;
|
||||
|
||||
// Loop through and copy
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ void GFXD3D9EnumTranslate::init()
|
|||
GFXD3D9TextureFormat[GFXFormatD24FS8] = D3DFMT_D24FS8;
|
||||
GFXD3D9TextureFormat[GFXFormatD16] = D3DFMT_D16;
|
||||
GFXD3D9TextureFormat[GFXFormatR8G8B8A8_SRGB] = D3DFMT_UNKNOWN;
|
||||
|
||||
GFXD3D9TextureFormat[GFXFormatR8G8B8A8_LINEAR_FORCE] = D3DFMT_A8R8G8B8;
|
||||
VALIDATE_LOOKUPTABLE( GFXD3D9TextureFormat, GFXFormat);
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -293,6 +293,7 @@ void GBitmap::allocateBitmap(const U32 in_width, const U32 in_height, const bool
|
|||
break;
|
||||
case GFXFormatR8G8B8: mBytesPerPixel = 3;
|
||||
break;
|
||||
case GFXFormatR8G8B8A8_LINEAR_FORCE:
|
||||
case GFXFormatR8G8B8X8:
|
||||
case GFXFormatR8G8B8A8: mBytesPerPixel = 4;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -328,13 +328,14 @@ static bool _writePNG(GBitmap *bitmap, Stream &stream, U32 compressionLevel, U32
|
|||
format == GFXFormatR8G8B8A8 ||
|
||||
format == GFXFormatR8G8B8X8 ||
|
||||
format == GFXFormatA8 ||
|
||||
format == GFXFormatR5G6B5, "_writePNG: ONLY RGB bitmap writing supported at this time.");
|
||||
format == GFXFormatR5G6B5 ||
|
||||
format == GFXFormatR8G8B8A8_LINEAR_FORCE, "_writePNG: ONLY RGB bitmap writing supported at this time.");
|
||||
|
||||
if ( format != GFXFormatR8G8B8 &&
|
||||
format != GFXFormatR8G8B8A8 &&
|
||||
format != GFXFormatR8G8B8X8 &&
|
||||
format != GFXFormatA8 &&
|
||||
format != GFXFormatR5G6B5 )
|
||||
format != GFXFormatR5G6B5 && format != GFXFormatR8G8B8A8_LINEAR_FORCE)
|
||||
return false;
|
||||
|
||||
png_structp png_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING,
|
||||
|
|
@ -381,7 +382,7 @@ static bool _writePNG(GBitmap *bitmap, Stream &stream, U32 compressionLevel, U32
|
|||
NULL, // compression type
|
||||
NULL); // filter type
|
||||
}
|
||||
else if (format == GFXFormatR8G8B8A8 || format == GFXFormatR8G8B8X8)
|
||||
else if (format == GFXFormatR8G8B8A8 || format == GFXFormatR8G8B8X8 || format == GFXFormatR8G8B8A8_LINEAR_FORCE)
|
||||
{
|
||||
png_set_IHDR(png_ptr, info_ptr,
|
||||
width, height, // the width & height
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@
|
|||
#include "core/util/delegate.h"
|
||||
#endif
|
||||
|
||||
struct GFXAdapterLUID
|
||||
{
|
||||
unsigned long LowPart;
|
||||
long HighPart;
|
||||
};
|
||||
|
||||
struct GFXAdapter
|
||||
{
|
||||
public:
|
||||
|
|
@ -58,6 +64,9 @@ public:
|
|||
/// Supported shader model. 0.f means none supported.
|
||||
F32 mShaderModel;
|
||||
|
||||
/// LUID for windows oculus support
|
||||
GFXAdapterLUID mLUID;
|
||||
|
||||
const char * getName() const { return mName; }
|
||||
const char * getOutputName() const { return mOutputName; }
|
||||
GFXAdapterType mType;
|
||||
|
|
@ -72,6 +81,7 @@ public:
|
|||
mOutputName[0] = 0;
|
||||
mShaderModel = 0.f;
|
||||
mIndex = 0;
|
||||
dMemset(&mLUID, '\0', sizeof(mLUID));
|
||||
}
|
||||
|
||||
~GFXAdapter()
|
||||
|
|
|
|||
|
|
@ -232,3 +232,14 @@ DefineEngineStaticMethod( GFXCardProfilerAPI, queryProfile, S32, ( const char *n
|
|||
{
|
||||
return (S32)GFX->getCardProfiler()->queryProfile( name, (U32)defaultValue );
|
||||
}
|
||||
|
||||
|
||||
DefineEngineStaticMethod( GFXCardProfilerAPI, getBestDepthFormat, String, (),,
|
||||
"Returns the card name." )
|
||||
{
|
||||
if (GFX->getCardProfiler()->queryProfile("GL::Workaround::intel_mac_depth", false))
|
||||
return "GFXFormatD16";
|
||||
else
|
||||
return "GFXFormatD24S8";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,8 @@ GFXDevice::GFXDevice()
|
|||
// misc
|
||||
mAllowRender = true;
|
||||
mCurrentRenderStyle = RS_Standard;
|
||||
mCurrentProjectionOffset = Point2F::Zero;
|
||||
mCurrentStereoTarget = -1;
|
||||
mStereoHeadTransform = MatrixF(1);
|
||||
mCanCurrentlyRender = false;
|
||||
mInitialized = false;
|
||||
|
||||
|
|
@ -1320,7 +1321,7 @@ DefineEngineFunction( getBestHDRFormat, GFXFormat, (),,
|
|||
// Figure out the best HDR format. This is the smallest
|
||||
// format which supports blending and filtering.
|
||||
Vector<GFXFormat> formats;
|
||||
formats.push_back( GFXFormatR10G10B10A2 );
|
||||
//formats.push_back( GFXFormatR10G10B10A2 ); TODO: replace with SRGB format once DX9 is gone - BJR
|
||||
formats.push_back( GFXFormatR16G16B16A16F );
|
||||
formats.push_back( GFXFormatR16G16B16A16 );
|
||||
GFXFormat format = GFX->selectSupportedFormat( &GFXDefaultRenderTargetProfile,
|
||||
|
|
|
|||
|
|
@ -219,6 +219,12 @@ public:
|
|||
/// The device has started rendering a frame's field (such as for side-by-side rendering)
|
||||
deStartOfField,
|
||||
|
||||
/// left stereo frame has been rendered
|
||||
deLeftStereoFrameRendered,
|
||||
|
||||
/// right stereo frame has been rendered
|
||||
deRightStereoFrameRendered,
|
||||
|
||||
/// The device is about to finish rendering a frame's field
|
||||
deEndOfField,
|
||||
};
|
||||
|
|
@ -248,6 +254,7 @@ public:
|
|||
{
|
||||
RS_Standard = 0,
|
||||
RS_StereoSideBySide = (1<<0), // Render into current Render Target side-by-side
|
||||
RS_StereoSeparate = (1<<1) // Render in two separate passes (then combined by vr compositor)
|
||||
};
|
||||
|
||||
enum GFXDeviceLimits
|
||||
|
|
@ -281,13 +288,19 @@ protected:
|
|||
/// The style of rendering that is to be performed, based on GFXDeviceRenderStyles
|
||||
U32 mCurrentRenderStyle;
|
||||
|
||||
/// The current projection offset. May be used during side-by-side rendering, for example.
|
||||
Point2F mCurrentProjectionOffset;
|
||||
/// Current stereo target being rendered to
|
||||
S32 mCurrentStereoTarget;
|
||||
|
||||
/// Eye offset used when using a stereo rendering style
|
||||
Point3F mStereoEyeOffset[NumStereoPorts];
|
||||
|
||||
/// Center matrix for head
|
||||
MatrixF mStereoHeadTransform;
|
||||
|
||||
/// Left and right matrix for eyes
|
||||
MatrixF mStereoEyeTransforms[NumStereoPorts];
|
||||
|
||||
/// Inverse of mStereoEyeTransforms
|
||||
MatrixF mInverseStereoEyeTransforms[NumStereoPorts];
|
||||
|
||||
/// Fov port settings
|
||||
|
|
@ -338,21 +351,25 @@ public:
|
|||
/// Retrieve the current rendering style based on GFXDeviceRenderStyles
|
||||
U32 getCurrentRenderStyle() const { return mCurrentRenderStyle; }
|
||||
|
||||
/// Retrieve the current stereo target being rendered to
|
||||
S32 getCurrentStereoTarget() const { return mCurrentStereoTarget; }
|
||||
|
||||
/// Set the current rendering style, based on GFXDeviceRenderStyles
|
||||
void setCurrentRenderStyle(U32 style) { mCurrentRenderStyle = style; }
|
||||
|
||||
/// Set the current projection offset used during stereo rendering
|
||||
const Point2F& getCurrentProjectionOffset() { return mCurrentProjectionOffset; }
|
||||
|
||||
/// Get the current projection offset used during stereo rendering
|
||||
void setCurrentProjectionOffset(const Point2F& offset) { mCurrentProjectionOffset = offset; }
|
||||
/// Set the current stereo target being rendered to (in case we're doing anything with postfx)
|
||||
void setCurrentStereoTarget(const F32 targetId) { mCurrentStereoTarget = targetId; }
|
||||
|
||||
/// Get the current eye offset used during stereo rendering
|
||||
const Point3F* getStereoEyeOffsets() { return mStereoEyeOffset; }
|
||||
|
||||
const MatrixF& getStereoHeadTransform() { return mStereoHeadTransform; }
|
||||
const MatrixF* getStereoEyeTransforms() { return mStereoEyeTransforms; }
|
||||
const MatrixF* getInverseStereoEyeTransforms() { return mInverseStereoEyeTransforms; }
|
||||
|
||||
/// Sets the head matrix for stereo rendering
|
||||
void setStereoHeadTransform(const MatrixF &mat) { mStereoHeadTransform = mat; }
|
||||
|
||||
/// Set the current eye offset used during stereo rendering
|
||||
void setStereoEyeOffsets(Point3F *offsets) { dMemcpy(mStereoEyeOffset, offsets, sizeof(Point3F) * NumStereoPorts); }
|
||||
|
||||
|
|
@ -391,6 +408,8 @@ public:
|
|||
}
|
||||
setViewport(mStereoViewports[eyeId]);
|
||||
}
|
||||
|
||||
mCurrentStereoTarget = eyeId;
|
||||
}
|
||||
|
||||
GFXCardProfiler* getCardProfiler() const { return mCardProfiler; }
|
||||
|
|
@ -462,7 +481,7 @@ public:
|
|||
/// Returns the first format from the list which meets all
|
||||
/// the criteria of the texture profile and query options.
|
||||
virtual GFXFormat selectSupportedFormat(GFXTextureProfile *profile,
|
||||
const Vector<GFXFormat> &formats, bool texture, bool mustblend, bool mustfilter) = 0;
|
||||
const Vector<GFXFormat> &formats, bool texture, bool mustblend, bool mustfilter) = 0;
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ void GFXDrawUtil::_setupStateBlocks()
|
|||
bitmapStretchSR.setZReadWrite(false);
|
||||
bitmapStretchSR.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
|
||||
bitmapStretchSR.samplersDefined = true;
|
||||
bitmapStretchSR.setColorWrites(true, true, true, false); // NOTE: comment this out if alpha write is needed
|
||||
|
||||
// Linear: Create wrap SB
|
||||
bitmapStretchSR.samplers[0] = GFXSamplerStateDesc::getWrapLinear();
|
||||
|
|
|
|||
|
|
@ -192,6 +192,12 @@ enum GFXFormat
|
|||
GFXFormatD24S8,
|
||||
GFXFormatD24FS8,
|
||||
|
||||
// sRGB formats
|
||||
GFXFormatR8G8B8A8_SRGB,
|
||||
|
||||
// Guaranteed RGBA8 (for apis which really dont like bgr)
|
||||
GFXFormatR8G8B8A8_LINEAR_FORCE,
|
||||
|
||||
// 64 bit texture formats...
|
||||
GFXFormatR16G16B16A16,// first in group...
|
||||
GFXFormatR16G16B16A16F,
|
||||
|
|
@ -206,9 +212,6 @@ enum GFXFormat
|
|||
GFXFormatDXT4,
|
||||
GFXFormatDXT5,
|
||||
|
||||
// sRGB formats
|
||||
GFXFormatR8G8B8A8_SRGB,
|
||||
|
||||
GFXFormat_COUNT,
|
||||
|
||||
GFXFormat_8BIT = GFXFormatA8,
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ FontRenderBatcher::FontRenderBatcher() : mStorage(8096)
|
|||
// result in the text always being black. This may not be the case in OpenGL
|
||||
// so it may have to change. -bramage
|
||||
f.samplers[0].textureColorOp = GFXTOPAdd;
|
||||
|
||||
f.setColorWrites(true, true, true, false); // NOTE: comment this out if alpha write is needed
|
||||
mFontSB = GFX->createStateBlock(f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,6 +198,22 @@ GFXAdapter* GFXInit::getAdapterOfType( GFXAdapterType type, const char* outputDe
|
|||
return NULL;
|
||||
}
|
||||
|
||||
GFXAdapter* GFXInit::getAdapterOfType(GFXAdapterType type, S32 outputDeviceIndex)
|
||||
{
|
||||
for (U32 i = 0; i < smAdapters.size(); i++)
|
||||
{
|
||||
if (smAdapters[i]->mType == type)
|
||||
{
|
||||
if (smAdapters[i]->mIndex == outputDeviceIndex)
|
||||
{
|
||||
return smAdapters[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GFXAdapter* GFXInit::chooseAdapter( GFXAdapterType type, const char* outputDevice)
|
||||
{
|
||||
GFXAdapter* adapter = GFXInit::getAdapterOfType(type, outputDevice);
|
||||
|
|
@ -219,6 +235,27 @@ GFXAdapter* GFXInit::chooseAdapter( GFXAdapterType type, const char* outputDevic
|
|||
return adapter;
|
||||
}
|
||||
|
||||
GFXAdapter* GFXInit::chooseAdapter(GFXAdapterType type, S32 outputDeviceIndex)
|
||||
{
|
||||
GFXAdapter* adapter = GFXInit::getAdapterOfType(type, outputDeviceIndex);
|
||||
|
||||
if (!adapter && type != OpenGL)
|
||||
{
|
||||
Con::errorf("The requested renderer, %s, doesn't seem to be available."
|
||||
" Trying the default, OpenGL.", getAdapterNameFromType(type));
|
||||
adapter = GFXInit::getAdapterOfType(OpenGL, outputDeviceIndex);
|
||||
}
|
||||
|
||||
if (!adapter)
|
||||
{
|
||||
Con::errorf("The OpenGL renderer doesn't seem to be available. Trying the GFXNulDevice.");
|
||||
adapter = GFXInit::getAdapterOfType(NullDevice, 0);
|
||||
}
|
||||
|
||||
AssertFatal(adapter, "There is no rendering device available whatsoever.");
|
||||
return adapter;
|
||||
}
|
||||
|
||||
const char* GFXInit::getAdapterNameFromType(GFXAdapterType type)
|
||||
{
|
||||
// must match GFXAdapterType order
|
||||
|
|
@ -256,8 +293,23 @@ GFXAdapter *GFXInit::getBestAdapterChoice()
|
|||
// Get the user's preference for device...
|
||||
const String renderer = Con::getVariable("$pref::Video::displayDevice");
|
||||
const String outputDevice = Con::getVariable("$pref::Video::displayOutputDevice");
|
||||
GFXAdapterType adapterType = getAdapterTypeFromName(renderer.c_str());
|
||||
GFXAdapter *adapter = chooseAdapter(adapterType, outputDevice.c_str());
|
||||
const String adapterDevice = Con::getVariable("$Video::forceDisplayAdapter");
|
||||
|
||||
GFXAdapterType adapterType = getAdapterTypeFromName(renderer.c_str());;
|
||||
GFXAdapter *adapter = NULL;
|
||||
|
||||
if (adapterDevice.isEmpty())
|
||||
{
|
||||
adapter = chooseAdapter(adapterType, outputDevice.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
S32 adapterIdx = dAtoi(adapterDevice.c_str());
|
||||
if (adapterIdx == -1)
|
||||
adapter = chooseAdapter(adapterType, outputDevice.c_str());
|
||||
else
|
||||
adapter = chooseAdapter(adapterType, adapterIdx);
|
||||
}
|
||||
|
||||
// Did they have one? Return it.
|
||||
if(adapter)
|
||||
|
|
|
|||
|
|
@ -74,10 +74,16 @@ public:
|
|||
/// This method never returns NULL.
|
||||
static GFXAdapter *chooseAdapter( GFXAdapterType type, const char* outputDevice);
|
||||
|
||||
/// Override which chooses an adapter based on an index instead
|
||||
static GFXAdapter *chooseAdapter( GFXAdapterType type, S32 outputDeviceIndex );
|
||||
|
||||
/// Gets the first adapter of the requested type (and on the requested output device)
|
||||
/// from the list of enumerated adapters. Should only call this after a call to
|
||||
/// enumerateAdapters.
|
||||
static GFXAdapter *getAdapterOfType( GFXAdapterType type, const char* outputDevice );
|
||||
|
||||
/// Override which gets an adapter based on an index instead
|
||||
static GFXAdapter *getAdapterOfType( GFXAdapterType type, S32 outputDeviceIndex );
|
||||
|
||||
/// Converts a GFXAdapterType to a string name. Useful for writing out prefs
|
||||
static const char *getAdapterNameFromType( GFXAdapterType type );
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class GFXOcclusionQueryHandle
|
|||
public:
|
||||
|
||||
GFXOcclusionQueryHandle()
|
||||
: mLastStatus(GFXOcclusionQuery::Unset), mLastData(0), mQuery(NULL), mWaiting(false)
|
||||
: mLastStatus(GFXOcclusionQuery::Unset), mLastData(0), mWaiting(false) , mQuery(NULL)
|
||||
{}
|
||||
|
||||
~GFXOcclusionQueryHandle()
|
||||
|
|
|
|||
|
|
@ -100,7 +100,10 @@ public:
|
|||
/// of a target texture after presentation or deactivated.
|
||||
///
|
||||
/// This is mainly a depth buffer optimization.
|
||||
NoDiscard = BIT(10)
|
||||
NoDiscard = BIT(10),
|
||||
|
||||
/// Texture is managed by another process, thus should not be modified
|
||||
NoModify = BIT(11)
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -164,6 +167,7 @@ public:
|
|||
inline bool noMip() const { return testFlag(NoMipmap); }
|
||||
inline bool isPooled() const { return testFlag(Pooled); }
|
||||
inline bool canDiscard() const { return !testFlag(NoDiscard); }
|
||||
inline bool canModify() const { return !testFlag(NoModify); }
|
||||
|
||||
private:
|
||||
/// These constants control the packing for the profile; if you add flags, types, or
|
||||
|
|
|
|||
|
|
@ -64,11 +64,11 @@ public:
|
|||
const GFXVertexFormat *vertexFormat,
|
||||
U32 vertexSize,
|
||||
GFXBufferType bufferType )
|
||||
: mDevice( device ),
|
||||
mVolatileStart( 0 ),
|
||||
mNumVerts( numVerts ),
|
||||
: mNumVerts( numVerts ),
|
||||
mVertexSize( vertexSize ),
|
||||
mBufferType( bufferType )
|
||||
mBufferType( bufferType ),
|
||||
mDevice( device ),
|
||||
mVolatileStart( 0 )
|
||||
{
|
||||
if ( vertexFormat )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,26 +27,9 @@
|
|||
void GFXGLCardProfiler::init()
|
||||
{
|
||||
mChipSet = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
|
||||
|
||||
// get the major and minor parts of the GL version. These are defined to be
|
||||
// in the order "[major].[minor] [other]|[major].[minor].[release] [other] in the spec
|
||||
const char *versionStart = reinterpret_cast<const char*>(glGetString(GL_VERSION));
|
||||
const char *versionEnd = versionStart;
|
||||
// get the text for the version "x.x.xxxx "
|
||||
for( S32 tok = 0; tok < 2; ++tok )
|
||||
{
|
||||
char *text = dStrdup( versionEnd );
|
||||
dStrtok(text, ". ");
|
||||
versionEnd += dStrlen( text ) + 1;
|
||||
dFree( text );
|
||||
}
|
||||
|
||||
mRendererString = "GL";
|
||||
mRendererString += String::SpanToString(versionStart, versionEnd - 1);
|
||||
|
||||
mRendererString = "OpenGL";
|
||||
mCardDescription = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
|
||||
mVersionString = reinterpret_cast<const char*>(glGetString(GL_VERSION));
|
||||
|
||||
mVersionString = reinterpret_cast<const char*>(glGetString(GL_VERSION));
|
||||
mVideoMemory = static_cast<GFXGLDevice*>(GFX)->getTotalVideoMemory();
|
||||
|
||||
Parent::init();
|
||||
|
|
@ -85,7 +68,8 @@ void GFXGLCardProfiler::setupCardCapabilities()
|
|||
setCapability("GL_ARB_copy_image", gglHasExtension(ARB_copy_image));
|
||||
|
||||
// Check for vertex attrib binding
|
||||
setCapability("GL_ARB_vertex_attrib_binding", gglHasExtension(ARB_vertex_attrib_binding));
|
||||
setCapability("GL_ARB_vertex_attrib_binding", gglHasExtension(ARB_vertex_attrib_binding));
|
||||
|
||||
}
|
||||
|
||||
bool GFXGLCardProfiler::_queryCardCap(const String& query, U32& foundResult)
|
||||
|
|
|
|||
|
|
@ -103,27 +103,6 @@ void STDCALL glAmdDebugCallback(GLuint id, GLenum category, GLenum severity, GLs
|
|||
Con::printf("AMDOPENGL: %s", message);
|
||||
}
|
||||
|
||||
|
||||
// >>>> OPENGL INTEL WORKAROUND @todo OPENGL INTEL remove
|
||||
PFNGLBINDFRAMEBUFFERPROC __openglBindFramebuffer = NULL;
|
||||
|
||||
void STDCALL _t3d_glBindFramebuffer(GLenum target, GLuint framebuffer)
|
||||
{
|
||||
if( target == GL_FRAMEBUFFER )
|
||||
{
|
||||
if( GFXGL->getOpenglCache()->getCacheBinded( GL_DRAW_FRAMEBUFFER ) == framebuffer
|
||||
&& GFXGL->getOpenglCache()->getCacheBinded( GL_READ_FRAMEBUFFER ) == framebuffer )
|
||||
return;
|
||||
}
|
||||
else if( GFXGL->getOpenglCache()->getCacheBinded( target ) == framebuffer )
|
||||
return;
|
||||
|
||||
__openglBindFramebuffer(target, framebuffer);
|
||||
GFXGL->getOpenglCache()->setCacheBinded( target, framebuffer);
|
||||
}
|
||||
// <<<< OPENGL INTEL WORKAROUND
|
||||
|
||||
|
||||
void GFXGLDevice::initGLState()
|
||||
{
|
||||
// We don't currently need to sync device state with a known good place because we are
|
||||
|
|
@ -157,14 +136,11 @@ void GFXGLDevice::initGLState()
|
|||
String vendorStr = (const char*)glGetString( GL_VENDOR );
|
||||
if( vendorStr.find("NVIDIA", 0, String::NoCase | String::Left) != String::NPos)
|
||||
mUseGlMap = false;
|
||||
|
||||
|
||||
if( vendorStr.find("INTEL", 0, String::NoCase | String::Left ) != String::NPos)
|
||||
{
|
||||
// @todo OPENGL INTEL - This is a workaround for a warning spam or even crashes with actual framebuffer code, remove when implemented TGL layer.
|
||||
__openglBindFramebuffer = glBindFramebuffer;
|
||||
glBindFramebuffer = &_t3d_glBindFramebuffer;
|
||||
}
|
||||
|
||||
// Workaround for all Mac's, has a problem using glMap* with volatile buffers
|
||||
#ifdef TORQUE_OS_MAC
|
||||
mUseGlMap = false;
|
||||
#endif
|
||||
|
||||
#if TORQUE_DEBUG
|
||||
if( gglHasExtension(ARB_debug_output) )
|
||||
|
|
@ -200,8 +176,10 @@ void GFXGLDevice::initGLState()
|
|||
|
||||
GFXGLDevice::GFXGLDevice(U32 adapterIndex) :
|
||||
mAdapterIndex(adapterIndex),
|
||||
mNeedUpdateVertexAttrib(false),
|
||||
mCurrentPB(NULL),
|
||||
mDrawInstancesCount(0),
|
||||
mCurrentShader( NULL ),
|
||||
m_mCurrentWorld(true),
|
||||
m_mCurrentView(true),
|
||||
mContext(NULL),
|
||||
|
|
@ -211,8 +189,6 @@ GFXGLDevice::GFXGLDevice(U32 adapterIndex) :
|
|||
mMaxFFTextures(2),
|
||||
mMaxTRColors(1),
|
||||
mClip(0, 0, 0, 0),
|
||||
mCurrentShader( NULL ),
|
||||
mNeedUpdateVertexAttrib(false),
|
||||
mWindowRT(NULL),
|
||||
mUseGlMap(true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,343 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Don't include Apple's GL header
|
||||
#define __gl_h_
|
||||
// Include our GL header before Apple headers.
|
||||
#include "gfx/gl/ggl/ggl.h"
|
||||
|
||||
#include "platform/tmm_off.h"
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include "gfx/gl/gfxGLDevice.h"
|
||||
#include "platform/tmm_on.h"
|
||||
|
||||
#include "gfx/gl/gfxGLTextureTarget.h"
|
||||
#include "gfx/gl/gfxGLCardProfiler.h"
|
||||
#include "gfx/gl/gfxGLAppleFence.h"
|
||||
#include "gfx/gl/gfxGLWindowTarget.h"
|
||||
#include "platformMac/macGLUtils.h"
|
||||
#include "windowManager/mac/macWindow.h"
|
||||
|
||||
extern void loadGLCore();
|
||||
extern void loadGLExtensions(void* context);
|
||||
|
||||
static String _getRendererForDisplay(CGDirectDisplayID display)
|
||||
{
|
||||
Vector<NSOpenGLPixelFormatAttribute> attributes = _createStandardPixelFormatAttributesForDisplay(display);
|
||||
|
||||
NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes.address()];
|
||||
AssertFatal(fmt, "_getRendererForDisplay - Unable to create a pixel format object");
|
||||
|
||||
NSOpenGLContext* ctx = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
|
||||
AssertFatal(ctx, "_getRendererForDisplay - Unable to create an OpenGL context");
|
||||
|
||||
// Save the current context, just in case
|
||||
NSOpenGLContext* currCtx = [NSOpenGLContext currentContext];
|
||||
[ctx makeCurrentContext];
|
||||
|
||||
// CodeReview [ags 12/19/07] This is a hack. We should call loadGLCore somewhere else, before we reach here.
|
||||
// On Macs we can safely assume access to the OpenGL framework at anytime, perhaps this should go in main()?
|
||||
loadGLCore();
|
||||
|
||||
// get the renderer string
|
||||
String ret((const char*)glGetString(GL_RENDERER));
|
||||
|
||||
// Restore our old context, release the context and pixel format.
|
||||
[currCtx makeCurrentContext];
|
||||
[ctx release];
|
||||
[fmt release];
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void _createInitialContextAndFormat(void* &ctx, void* &fmt)
|
||||
{
|
||||
AssertFatal(!fmt && !ctx, "_createInitialContextAndFormat - Already created initial context and format");
|
||||
|
||||
fmt = _createStandardPixelFormat();
|
||||
AssertFatal(fmt, "_createInitialContextAndFormat - Unable to create an OpenGL pixel format");
|
||||
|
||||
ctx = [[NSOpenGLContext alloc] initWithFormat: (NSOpenGLPixelFormat*)fmt shareContext: nil];
|
||||
AssertFatal(ctx, "_createInitialContextAndFormat - Unable to create an OpenGL context");
|
||||
}
|
||||
|
||||
static NSOpenGLContext* _createContextForWindow(PlatformWindow *window, void* &context, void* &pixelFormat)
|
||||
{
|
||||
NSOpenGLView* view = (NSOpenGLView*)window->getPlatformDrawable();
|
||||
AssertFatal([view isKindOfClass:[NSOpenGLView class]], avar("_createContextForWindow - Supplied a %s instead of a NSOpenGLView", [[view className] UTF8String]));
|
||||
|
||||
NSOpenGLContext* ctx = NULL;
|
||||
if(!context || !pixelFormat)
|
||||
{
|
||||
// Create the initial opengl context that the device and the first window will hold.
|
||||
_createInitialContextAndFormat(context, pixelFormat);
|
||||
ctx = (NSOpenGLContext*)context;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a context which shares its resources with the device's initial context
|
||||
ctx = [[NSOpenGLContext alloc] initWithFormat: (NSOpenGLPixelFormat*)pixelFormat shareContext: (NSOpenGLContext*)context];
|
||||
AssertFatal(ctx, "Unable to create a shared OpenGL context");
|
||||
}
|
||||
|
||||
[view setPixelFormat: (NSOpenGLPixelFormat*)pixelFormat];
|
||||
[view setOpenGLContext: ctx];
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window )
|
||||
{
|
||||
if(mInitialized)
|
||||
return;
|
||||
|
||||
NSOpenGLContext* ctx = _createContextForWindow(window, mContext, mPixelFormat);
|
||||
[ctx makeCurrentContext];
|
||||
|
||||
loadGLCore();
|
||||
loadGLExtensions(ctx);
|
||||
|
||||
initGLState();
|
||||
|
||||
mInitialized = true;
|
||||
deviceInited();
|
||||
}
|
||||
|
||||
void GFXGLDevice::enumerateAdapters( Vector<GFXAdapter*> &adapterList )
|
||||
{
|
||||
GFXAdapter *toAdd;
|
||||
|
||||
Vector<GFXVideoMode> videoModes;
|
||||
|
||||
CGDirectDisplayID display = CGMainDisplayID();
|
||||
|
||||
// Enumerate all available resolutions:
|
||||
NSArray* modeArray = (NSArray*)CGDisplayAvailableModes(display);
|
||||
|
||||
GFXVideoMode vmAdd;
|
||||
NSEnumerator* enumerator = [modeArray objectEnumerator];
|
||||
NSDictionary* mode;
|
||||
while((mode = [enumerator nextObject]))
|
||||
{
|
||||
vmAdd.resolution.x = [[mode valueForKey:@"Width"] intValue];
|
||||
vmAdd.resolution.y = [[mode valueForKey:@"Height"] intValue];
|
||||
vmAdd.bitDepth = [[mode valueForKey:@"BitsPerPixel"] intValue];
|
||||
vmAdd.refreshRate = [[mode valueForKey:@"RefreshRate"] intValue];
|
||||
|
||||
vmAdd.fullScreen = false;
|
||||
|
||||
// skip if mode claims to be 8bpp
|
||||
if( vmAdd.bitDepth == 8 )
|
||||
continue;
|
||||
|
||||
// Only add this resolution if it is not already in the list:
|
||||
bool alreadyInList = false;
|
||||
for(Vector<GFXVideoMode>::iterator i = videoModes.begin(); i != videoModes.end(); i++)
|
||||
{
|
||||
if(vmAdd == *i)
|
||||
{
|
||||
alreadyInList = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !alreadyInList )
|
||||
{
|
||||
videoModes.push_back( vmAdd );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get number of displays
|
||||
CGDisplayCount dispCnt;
|
||||
CGGetActiveDisplayList(0, NULL, &dispCnt);
|
||||
|
||||
// Take advantage of GNU-C
|
||||
CGDirectDisplayID displays[dispCnt];
|
||||
|
||||
CGGetActiveDisplayList(dispCnt, displays, &dispCnt);
|
||||
for(U32 i = 0; i < dispCnt; i++)
|
||||
{
|
||||
toAdd = new GFXAdapter();
|
||||
toAdd->mType = OpenGL;
|
||||
toAdd->mIndex = (U32)displays[i];
|
||||
toAdd->mCreateDeviceInstanceDelegate = mCreateDeviceInstance;
|
||||
String renderer = _getRendererForDisplay(displays[i]);
|
||||
AssertFatal(dStrlen(renderer.c_str()) < GFXAdapter::MaxAdapterNameLen, "GFXGLDevice::enumerateAdapter - renderer name too long, increae the size of GFXAdapter::MaxAdapterNameLen (or use String!)");
|
||||
dStrncpy(toAdd->mName, renderer.c_str(), GFXAdapter::MaxAdapterNameLen);
|
||||
adapterList.push_back(toAdd);
|
||||
|
||||
for (S32 j = videoModes.size() - 1 ; j >= 0 ; j--)
|
||||
toAdd->mAvailableModes.push_back(videoModes[j]);
|
||||
}
|
||||
}
|
||||
|
||||
void GFXGLDevice::enumerateVideoModes()
|
||||
{
|
||||
mVideoModes.clear();
|
||||
|
||||
CGDirectDisplayID display = CGMainDisplayID();
|
||||
|
||||
// Enumerate all available resolutions:
|
||||
NSArray* modeArray = (NSArray*)CGDisplayAvailableModes(display);
|
||||
|
||||
GFXVideoMode toAdd;
|
||||
NSEnumerator* enumerator = [modeArray objectEnumerator];
|
||||
NSDictionary* mode;
|
||||
while((mode = [enumerator nextObject]))
|
||||
{
|
||||
toAdd.resolution.x = [[mode valueForKey:@"Width"] intValue];
|
||||
toAdd.resolution.y = [[mode valueForKey:@"Height"] intValue];
|
||||
toAdd.bitDepth = [[mode valueForKey:@"BitsPerPixel"] intValue];
|
||||
toAdd.refreshRate = [[mode valueForKey:@"RefreshRate"] intValue];
|
||||
|
||||
toAdd.fullScreen = false;
|
||||
|
||||
// skip if mode claims to be 8bpp
|
||||
if( toAdd.bitDepth == 8 )
|
||||
continue;
|
||||
|
||||
// Only add this resolution if it is not already in the list:
|
||||
bool alreadyInList = false;
|
||||
for(Vector<GFXVideoMode>::iterator i = mVideoModes.begin(); i != mVideoModes.end(); i++)
|
||||
{
|
||||
if(toAdd == *i)
|
||||
{
|
||||
alreadyInList = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !alreadyInList )
|
||||
{
|
||||
mVideoModes.push_back( toAdd );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GFXGLDevice::beginSceneInternal()
|
||||
{
|
||||
// Nothing to do here for GL.
|
||||
mCanCurrentlyRender = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
U32 GFXGLDevice::getTotalVideoMemory()
|
||||
{
|
||||
// Convert our adapterIndex (i.e. our CGDirectDisplayID) into an OpenGL display mask
|
||||
GLuint display = CGDisplayIDToOpenGLDisplayMask((CGDirectDisplayID)mAdapterIndex);
|
||||
CGLRendererInfoObj rend;
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
|
||||
GLint nrend;
|
||||
#else
|
||||
long int nrend;
|
||||
#endif
|
||||
CGLQueryRendererInfo(display, &rend, &nrend);
|
||||
if(!nrend)
|
||||
return 0;
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
|
||||
GLint vidMem;
|
||||
#else
|
||||
long int vidMem;
|
||||
#endif
|
||||
CGLDescribeRenderer(rend, 0, kCGLRPVideoMemory, &vidMem);
|
||||
CGLDestroyRendererInfo(rend);
|
||||
|
||||
// convert bytes to MB
|
||||
vidMem /= (1024 * 1024);
|
||||
|
||||
return vidMem;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
GFXWindowTarget *GFXGLDevice::allocWindowTarget(PlatformWindow *window)
|
||||
{
|
||||
void *ctx = NULL;
|
||||
|
||||
// Init if needed, or create a new context
|
||||
if(!mInitialized)
|
||||
init(window->getVideoMode(), window);
|
||||
else
|
||||
ctx = _createContextForWindow(window, mContext, mPixelFormat);
|
||||
|
||||
// Allocate the wintarget and create a new context.
|
||||
GFXGLWindowTarget *gwt = new GFXGLWindowTarget(window, this);
|
||||
gwt->mContext = ctx ? ctx : mContext;
|
||||
|
||||
// And return...
|
||||
return gwt;
|
||||
}
|
||||
|
||||
GFXFence* GFXGLDevice::_createPlatformSpecificFence()
|
||||
{
|
||||
if(!mCardProfiler->queryProfile("GL::APPLE::suppFence"))
|
||||
return NULL;
|
||||
|
||||
return new GFXGLAppleFence(this);
|
||||
}
|
||||
|
||||
void GFXGLWindowTarget::_WindowPresent()
|
||||
{
|
||||
GFX->updateStates();
|
||||
mFullscreenContext ? [(NSOpenGLContext*)mFullscreenContext flushBuffer] : [(NSOpenGLContext*)mContext flushBuffer];
|
||||
return true;
|
||||
}
|
||||
|
||||
void GFXGLWindowTarget::_teardownCurrentMode()
|
||||
{
|
||||
GFX->setActiveRenderTarget(this);
|
||||
static_cast<GFXGLDevice*>(mDevice)->zombify();
|
||||
if(mFullscreenContext)
|
||||
{
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
[(NSOpenGLContext*)mFullscreenContext clearDrawable];
|
||||
}
|
||||
}
|
||||
|
||||
void GFXGLWindowTarget::_setupNewMode()
|
||||
{
|
||||
if(mWindow->getVideoMode().fullScreen && !mFullscreenContext)
|
||||
{
|
||||
// We have to create a fullscreen context.
|
||||
Vector<NSOpenGLPixelFormatAttribute> attributes = _beginPixelFormatAttributesForDisplay(static_cast<MacWindow*>(mWindow)->getDisplay());
|
||||
_addColorAlphaDepthStencilAttributes(attributes, 24, 8, 24, 8);
|
||||
_addFullscreenAttributes(attributes);
|
||||
_endAttributeList(attributes);
|
||||
|
||||
NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes.address()];
|
||||
mFullscreenContext = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
|
||||
[fmt release];
|
||||
[(NSOpenGLContext*)mFullscreenContext setFullScreen];
|
||||
[(NSOpenGLContext*)mFullscreenContext makeCurrentContext];
|
||||
// Restore resources in new context
|
||||
static_cast<GFXGLDevice*>(mDevice)->resurrect();
|
||||
GFX->updateStates(true);
|
||||
}
|
||||
else if(!mWindow->getVideoMode().fullScreen && mFullscreenContext)
|
||||
{
|
||||
[(NSOpenGLContext*)mFullscreenContext release];
|
||||
mFullscreenContext = NULL;
|
||||
[(NSOpenGLContext*)mContext makeCurrentContext];
|
||||
GFX->clear(GFXClearTarget | GFXClearZBuffer | GFXClearStencil, ColorI(0, 0, 0), 1.0f, 0);
|
||||
static_cast<GFXGLDevice*>(mDevice)->resurrect();
|
||||
GFX->updateStates(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ public:
|
|||
glGenQueries(1, &mQueryId);
|
||||
}
|
||||
|
||||
GLTimer() : mName(NULL), mQueryId(0), mData(NULL)
|
||||
GLTimer() : mName(NULL), mData(NULL), mQueryId(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
#include "gfx/gfxStructs.h"
|
||||
#include "console/console.h"
|
||||
|
||||
#define CHECK_AARG(pos, name) static StringTableEntry attr_##name = StringTable->insert(#name); if (argName == attr_##name) { glBindAttribLocation(mProgram, pos, attr_##name); continue; }
|
||||
|
||||
|
||||
class GFXGLShaderConstHandle : public GFXShaderConstHandle
|
||||
{
|
||||
|
|
@ -447,34 +449,62 @@ bool GFXGLShader::_init()
|
|||
// If either shader was present and failed to compile, bail.
|
||||
if(!compiledVertexShader || !compiledPixelShader)
|
||||
return false;
|
||||
|
||||
//bind vertex attributes
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_Position, "vPosition");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_Normal, "vNormal");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_Color, "vColor");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_Tangent, "vTangent");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TangentW, "vTangentW");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_Binormal, "vBinormal");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord0, "vTexCoord0");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord1, "vTexCoord1");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord2, "vTexCoord2");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord3, "vTexCoord3");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord4, "vTexCoord4");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord5, "vTexCoord5");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord6, "vTexCoord6");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord7, "vTexCoord7");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord8, "vTexCoord8");
|
||||
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord9, "vTexCoord9");
|
||||
|
||||
//bind fragment out color
|
||||
glBindFragDataLocation(mProgram, 0, "OUT_col");
|
||||
glBindFragDataLocation(mProgram, 1, "OUT_col1");
|
||||
glBindFragDataLocation(mProgram, 2, "OUT_col2");
|
||||
glBindFragDataLocation(mProgram, 3, "OUT_col3");
|
||||
|
||||
|
||||
// Link it!
|
||||
glLinkProgram( mProgram );
|
||||
|
||||
GLint activeAttribs = 0;
|
||||
glGetProgramiv(mProgram, GL_ACTIVE_ATTRIBUTES, &activeAttribs );
|
||||
|
||||
GLint maxLength;
|
||||
glGetProgramiv(mProgram, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxLength);
|
||||
|
||||
FrameTemp<GLchar> tempData(maxLength+1);
|
||||
*tempData.address() = '\0';
|
||||
// Check atributes
|
||||
for (U32 i=0; i<activeAttribs; i++)
|
||||
{
|
||||
GLint size;
|
||||
GLenum type;
|
||||
|
||||
glGetActiveAttrib(mProgram, i, maxLength + 1, NULL, &size, &type, tempData.address());
|
||||
|
||||
StringTableEntry argName = StringTable->insert(tempData.address());
|
||||
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_Position, vPosition);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_Normal, vNormal);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_Color, vColor);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_Tangent, vTangent);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_TangentW, vTangentW);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_Binormal, vBinormal);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord0, vTexCoord0);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord1, vTexCoord1);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord2, vTexCoord2);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord3, vTexCoord3);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord4, vTexCoord4);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord5, vTexCoord5);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord6, vTexCoord6);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord7, vTexCoord7);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord8, vTexCoord8);
|
||||
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord9, vTexCoord9);
|
||||
}
|
||||
|
||||
//always have OUT_col
|
||||
glBindFragDataLocation(mProgram, 0, "OUT_col");
|
||||
// Check OUT_colN
|
||||
for(U32 i=1;i<4;i++)
|
||||
{
|
||||
char buffer[10];
|
||||
dSprintf(buffer, sizeof(buffer), "OUT_col%u",i);
|
||||
GLint location = glGetFragDataLocation(mProgram, buffer);
|
||||
if(location>0)
|
||||
glBindFragDataLocation(mProgram, i, buffer);
|
||||
|
||||
}
|
||||
|
||||
// Link it again!
|
||||
glLinkProgram( mProgram );
|
||||
|
||||
GLint linkStatus;
|
||||
glGetProgramiv( mProgram, GL_LINK_STATUS, &linkStatus );
|
||||
|
||||
|
|
@ -486,23 +516,24 @@ bool GFXGLShader::_init()
|
|||
FrameAllocatorMarker fam;
|
||||
char* log = (char*)fam.alloc( logLength );
|
||||
glGetProgramInfoLog( mProgram, logLength, NULL, log );
|
||||
|
||||
|
||||
if ( linkStatus == GL_FALSE )
|
||||
{
|
||||
if ( smLogErrors )
|
||||
{
|
||||
Con::errorf( "GFXGLShader::init - Error linking shader!" );
|
||||
Con::errorf( "Program %s / %s: %s",
|
||||
mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str(), log);
|
||||
Con::errorf( "Program %s / %s: %s",
|
||||
mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str(), log);
|
||||
}
|
||||
}
|
||||
else if ( smLogWarnings )
|
||||
{
|
||||
Con::warnf( "Program %s / %s: %s",
|
||||
mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str(), log);
|
||||
Con::warnf( "Program %s / %s: %s",
|
||||
mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str(), log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If we failed to link, bail.
|
||||
if ( linkStatus == GL_FALSE )
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ void _GFXGLTextureTargetFBOImpl::applyState()
|
|||
{
|
||||
// Certain drivers have issues with depth only FBOs. That and the next two asserts assume we have a color target.
|
||||
AssertFatal(hasColor, "GFXGLTextureTarget::applyState() - Cannot set DepthStencil target without Color0 target!");
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthStecil->getBinding(), depthStecil->getHandle(), depthStecil->getMipLevel());
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, depthStecil->getBinding(), depthStecil->getHandle(), depthStecil->getMipLevel());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,10 +41,11 @@ GFXGLVertexBuffer::GFXGLVertexBuffer( GFXDevice *device,
|
|||
const GFXVertexFormat *vertexFormat,
|
||||
U32 vertexSize,
|
||||
GFXBufferType bufferType )
|
||||
: GFXVertexBuffer( device, numVerts, vertexFormat, vertexSize, bufferType ),
|
||||
mZombieCache(NULL),
|
||||
: GFXVertexBuffer( device, numVerts, vertexFormat, vertexSize, bufferType ),
|
||||
mBufferOffset(0),
|
||||
mBufferVertexOffset(0)
|
||||
mBufferVertexOffset(0),
|
||||
mZombieCache(NULL)
|
||||
|
||||
{
|
||||
if( mBufferType == GFXBufferTypeVolatile )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -118,11 +118,14 @@ inline void GFXGLWindowTarget::_setupAttachments()
|
|||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color->getHandle(), 0);
|
||||
mBackBufferDepthTex.set(dstSize.x, dstSize.y, GFXFormatD24S8, &BackBufferDepthProfile, "backBuffer");
|
||||
GFXGLTextureObject *depth = static_cast<GFXGLTextureObject*>(mBackBufferDepthTex.getPointer());
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth->getHandle(), 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depth->getHandle(), 0);
|
||||
}
|
||||
|
||||
void GFXGLWindowTarget::makeActive()
|
||||
{
|
||||
//make the rendering context active on this window
|
||||
_makeContextCurrent();
|
||||
|
||||
if(mBackBufferFBO)
|
||||
{
|
||||
glBindFramebuffer( GL_FRAMEBUFFER, mBackBufferFBO);
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ private:
|
|||
void _setupNewMode();
|
||||
void _setupAttachments();
|
||||
void _WindowPresent();
|
||||
//set this windows context to be current
|
||||
void _makeContextCurrent();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -157,12 +157,12 @@ void GFXGLDevice::enumerateVideoModes()
|
|||
void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window )
|
||||
{
|
||||
AssertFatal(window, "GFXGLDevice::init - no window specified, can't init device without a window!");
|
||||
PlatformWindowSDL* x11Window = dynamic_cast<PlatformWindowSDL*>(window);
|
||||
AssertFatal(x11Window, "Window is not a valid PlatformWindowSDL object");
|
||||
PlatformWindowSDL* sdlWindow = dynamic_cast<PlatformWindowSDL*>(window);
|
||||
AssertFatal(sdlWindow, "Window is not a valid PlatformWindowSDL object");
|
||||
|
||||
// Create OpenGL context
|
||||
mContext = PlatformGL::CreateContextGL( x11Window );
|
||||
PlatformGL::MakeCurrentGL( x11Window, mContext );
|
||||
mContext = PlatformGL::CreateContextGL( sdlWindow );
|
||||
PlatformGL::MakeCurrentGL( sdlWindow, mContext );
|
||||
|
||||
loadGLCore();
|
||||
loadGLExtensions(mContext);
|
||||
|
|
@ -228,4 +228,9 @@ void GFXGLWindowTarget::_setupNewMode()
|
|||
{
|
||||
}
|
||||
|
||||
void GFXGLWindowTarget::_makeContextCurrent()
|
||||
{
|
||||
PlatformGL::MakeCurrentGL(mWindow, mContext);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -363,3 +363,16 @@ void GFXGLWindowTarget::_teardownCurrentMode()
|
|||
void GFXGLWindowTarget::_setupNewMode()
|
||||
{
|
||||
}
|
||||
|
||||
void GFXGLWindowTarget::_makeContextCurrent()
|
||||
{
|
||||
HWND hwnd = GETHWND(getWindow());
|
||||
HDC hdc = GetDC(hwnd);
|
||||
if (!wglMakeCurrent(hdc, (HGLRC)mContext))
|
||||
{
|
||||
//HRESULT if needed for debug
|
||||
//HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
AssertFatal(false, "GFXGLWindowTarget::_makeContextCurrent() - cannot make our context current.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,78 @@ void DebugDrawer::setupStateBlocks()
|
|||
mRenderAlpha = GFX->createStateBlock(d);
|
||||
}
|
||||
|
||||
void DebugDrawer::render()
|
||||
void DebugDrawer::drawBoxOutline(const Point3F &a, const Point3F &b, const ColorF &color)
|
||||
{
|
||||
Point3F point0(a.x, a.y, a.z);
|
||||
Point3F point1(a.x, b.y, a.z);
|
||||
Point3F point2(b.x, b.y, a.z);
|
||||
Point3F point3(b.x, a.y, a.z);
|
||||
|
||||
Point3F point4(a.x, a.y, b.z);
|
||||
Point3F point5(a.x, b.y, b.z);
|
||||
Point3F point6(b.x, b.y, b.z);
|
||||
Point3F point7(b.x, a.y, b.z);
|
||||
|
||||
// Draw one plane
|
||||
drawLine(point0, point1, color);
|
||||
drawLine(point1, point2, color);
|
||||
drawLine(point2, point3, color);
|
||||
drawLine(point3, point0, color);
|
||||
|
||||
// Draw the other plane
|
||||
drawLine(point4, point5, color);
|
||||
drawLine(point5, point6, color);
|
||||
drawLine(point6, point7, color);
|
||||
drawLine(point7, point4, color);
|
||||
|
||||
// Draw the connecting corners
|
||||
drawLine(point0, point4, color);
|
||||
drawLine(point1, point5, color);
|
||||
drawLine(point2, point6, color);
|
||||
drawLine(point3, point7, color);
|
||||
}
|
||||
|
||||
void DebugDrawer::drawTransformedBoxOutline(const Point3F &a, const Point3F &b, const ColorF &color, const MatrixF& transform)
|
||||
{
|
||||
Point3F point0(a.x, a.y, a.z);
|
||||
Point3F point1(a.x, b.y, a.z);
|
||||
Point3F point2(b.x, b.y, a.z);
|
||||
Point3F point3(b.x, a.y, a.z);
|
||||
|
||||
Point3F point4(a.x, a.y, b.z);
|
||||
Point3F point5(a.x, b.y, b.z);
|
||||
Point3F point6(b.x, b.y, b.z);
|
||||
Point3F point7(b.x, a.y, b.z);
|
||||
|
||||
transform.mulP(point0);
|
||||
transform.mulP(point1);
|
||||
transform.mulP(point2);
|
||||
transform.mulP(point3);
|
||||
transform.mulP(point4);
|
||||
transform.mulP(point5);
|
||||
transform.mulP(point6);
|
||||
transform.mulP(point7);
|
||||
|
||||
// Draw one plane
|
||||
drawLine(point0, point1, color);
|
||||
drawLine(point1, point2, color);
|
||||
drawLine(point2, point3, color);
|
||||
drawLine(point3, point0, color);
|
||||
|
||||
// Draw the other plane
|
||||
drawLine(point4, point5, color);
|
||||
drawLine(point5, point6, color);
|
||||
drawLine(point6, point7, color);
|
||||
drawLine(point7, point4, color);
|
||||
|
||||
// Draw the connecting corners
|
||||
drawLine(point0, point4, color);
|
||||
drawLine(point1, point5, color);
|
||||
drawLine(point2, point6, color);
|
||||
drawLine(point3, point7, color);
|
||||
}
|
||||
|
||||
void DebugDrawer::render(bool clear)
|
||||
{
|
||||
#ifdef ENABLE_DEBUGDRAW
|
||||
if(!isDrawing)
|
||||
|
|
@ -264,7 +335,7 @@ void DebugDrawer::render()
|
|||
shouldToggleFreeze = false;
|
||||
}
|
||||
|
||||
if(p->dieTime <= curTime && !isFrozen && p->dieTime != U32_MAX)
|
||||
if(clear && p->dieTime <= curTime && !isFrozen && p->dieTime != U32_MAX)
|
||||
{
|
||||
*walk = p->next;
|
||||
mPrimChunker.free(p);
|
||||
|
|
|
|||
|
|
@ -105,7 +105,9 @@ public:
|
|||
static void init();
|
||||
|
||||
/// Called globally to render debug draw state. Also does state updates.
|
||||
void render();
|
||||
void render(bool clear=true);
|
||||
|
||||
bool willDraw() { return isDrawing && mHead; }
|
||||
|
||||
void toggleFreeze() { shouldToggleFreeze = true; };
|
||||
void toggleDrawing()
|
||||
|
|
@ -120,8 +122,11 @@ public:
|
|||
///
|
||||
/// @{
|
||||
|
||||
void drawBoxOutline(const Point3F &a, const Point3F &b, const ColorF &color = ColorF(1.0f, 1.0f, 1.0f));
|
||||
void drawTransformedBoxOutline(const Point3F &a, const Point3F &b, const ColorF &color, const MatrixF& transform);
|
||||
|
||||
void drawBox(const Point3F &a, const Point3F &b, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
void drawLine(const Point3F &a, const Point3F &b, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
void drawLine(const Point3F &a, const Point3F &b, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
void drawTri(const Point3F &a, const Point3F &b, const Point3F &c, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
void drawText(const Point3F& pos, const String& text, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
void drawCapsule(const Point3F &a, const F32 &radius, const F32 &height, const ColorF &color = ColorF(1.0f, 1.0f, 1.0f));
|
||||
|
|
@ -143,7 +148,8 @@ public:
|
|||
/// Set the TTL for the last item we entered...
|
||||
///
|
||||
/// Primitives default to lasting one frame (ie, ttl=0)
|
||||
enum {
|
||||
enum : U32
|
||||
{
|
||||
DD_INFINITE = U32_MAX
|
||||
};
|
||||
// How long should this primitive be draw for, 0 = one frame, DD_INFINITE = draw forever
|
||||
|
|
@ -176,7 +182,7 @@ private:
|
|||
DirectionLine,
|
||||
OutlinedText,
|
||||
Capsule,
|
||||
} type; ///< Type of the primitive. The meanings of a,b,c are determined by this.
|
||||
} type; ///< Type of the primitive. The meanings of a,b,c are determined by this.
|
||||
|
||||
SimTime dieTime; ///< Time at which we should remove this from the list.
|
||||
bool useZ; ///< If true, do z-checks for this primitive.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue