mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-25 06:15:36 +00:00
Tidy up indentation in openvr changes
This commit is contained in:
parent
e6159a590a
commit
212ac36cc1
25 changed files with 2171 additions and 2172 deletions
|
|
@ -119,77 +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);
|
||||
|
||||
// LUID identifies adapter for oculus rift
|
||||
dMemcpy(&toAdd->mLUID, &desc.AdapterLuid, sizeof(toAdd->mLUID));
|
||||
// LUID identifies adapter for oculus rift
|
||||
dMemcpy(&toAdd->mLUID, &desc.AdapterLuid, sizeof(toAdd->mLUID));
|
||||
|
||||
size_t size=wcslen(desc.Description);
|
||||
char *str = new char[size+1];
|
||||
size_t size=wcslen(desc.Description);
|
||||
char *str = new char[size+1];
|
||||
|
||||
wcstombs(str, desc.Description,size);
|
||||
str[size]='\0';
|
||||
String Description=str;
|
||||
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);
|
||||
|
|
@ -210,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);
|
||||
}
|
||||
|
|
@ -263,7 +263,7 @@ void GFXD3D11Device::enumerateVideoModes()
|
|||
|
||||
IDXGISwapChain* GFXD3D11Device::getSwapChain()
|
||||
{
|
||||
return mSwapChain;
|
||||
return mSwapChain;
|
||||
}
|
||||
|
||||
void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window)
|
||||
|
|
@ -285,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;
|
||||
|
|
@ -315,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)
|
||||
|
|
@ -329,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";
|
||||
|
|
@ -419,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
|
||||
|
|
@ -489,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)
|
||||
|
|
@ -523,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)
|
||||
|
|
@ -610,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
|
||||
|
|
@ -899,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -970,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 )
|
||||
|
|
@ -1014,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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -1103,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 )
|
||||
|
|
@ -1179,7 +1179,7 @@ void GFXD3D11Device::drawPrimitive( GFXPrimitiveType primType, U32 vertexStart,
|
|||
setShaderConstBufferInternal(mCurrentShaderConstBuffer);
|
||||
|
||||
if ( mVolatileVB )
|
||||
vertexStart += mVolatileVB->mVolatileStart;
|
||||
vertexStart += mVolatileVB->mVolatileStart;
|
||||
|
||||
mD3DDeviceContext->IASetPrimitiveTopology(GFXD3D11PrimType[primType]);
|
||||
|
||||
|
|
@ -1243,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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1286,7 +1286,7 @@ GFXPrimitiveBuffer * GFXD3D11Device::allocPrimitiveBuffer(U32 numIndices, U32 nu
|
|||
|
||||
case GFXBufferTypeDynamic:
|
||||
case GFXBufferTypeVolatile:
|
||||
usage = D3D11_USAGE_DYNAMIC;
|
||||
usage = D3D11_USAGE_DYNAMIC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1304,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)
|
||||
|
|
@ -1365,7 +1365,7 @@ GFXVertexBuffer * GFXD3D11Device::allocVertexBuffer(U32 numVerts, const GFXVerte
|
|||
|
||||
case GFXBufferTypeDynamic:
|
||||
case GFXBufferTypeVolatile:
|
||||
usage = D3D11_USAGE_DYNAMIC;
|
||||
usage = D3D11_USAGE_DYNAMIC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1380,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;
|
||||
|
|
@ -1597,7 +1597,6 @@ GFXVertexDecl* GFXD3D11Device::allocVertexDecl( const GFXVertexFormat *vertexFor
|
|||
|
||||
S32 elemIndex = 0;
|
||||
for (S32 i = 0; i < elemCount; i++, elemIndex++)
|
||||
{
|
||||
|
||||
const GFXVertexElement &element = vertexFormat->getElement(elemIndex);
|
||||
|
||||
|
|
@ -1690,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);
|
||||
|
|
@ -1704,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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue