Revert "Update OBS to D3D11"

This reverts commit fb3188a7cd.

This was a change that was added to fix support for certain intel
devices, but ultimately I feel like it's just not needed and is trying
to fix something that isn't broken.
master
jp9000 2015-01-23 14:52:22 -08:00
parent ed58b5b46e
commit 691c251d89
17 changed files with 283 additions and 299 deletions

View File

@ -120,7 +120,7 @@
</ClCompile>
<Link>
<AdditionalOptions>/ignore:4049 /ignore:4217 /ignore:4099 %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>Avrt.lib;dwmapi.lib;comctl32.lib;dxgi.lib;dxguid.lib;d3d11.lib;d3dx11.lib;ws2_32.lib;Iphlpapi.lib;Winmm.lib;librtmp.lib;libmp3lame-static.lib;libfaac.lib;dsound.lib;obsapi.lib;shell32.lib;gdiplus.lib;mfplat.lib;Mfuuid.lib;Winhttp.lib;libx264.lib;UxTheme.lib;Xinput9_1_0.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Avrt.lib;dwmapi.lib;comctl32.lib;dxgi.lib;dxguid.lib;d3d10_1.lib;d3dx10.lib;ws2_32.lib;Iphlpapi.lib;Winmm.lib;librtmp.lib;libmp3lame-static.lib;libfaac.lib;dsound.lib;obsapi.lib;shell32.lib;gdiplus.lib;mfplat.lib;Mfuuid.lib;Winhttp.lib;libx264.lib;UxTheme.lib;Xinput9_1_0.lib;%(AdditionalDependencies)</AdditionalDependencies>
<Version>
</Version>
<AdditionalLibraryDirectories>OBSApi/Debug;x264/libs/32bit;librtmp/debug;lame/output/32bit;libfaac/debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -160,7 +160,7 @@
<PrecompiledHeaderFile>Main.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<AdditionalDependencies>Avrt.lib;dwmapi.lib;comctl32.lib;dxgi.lib;dxguid.lib;d3d11.lib;d3dx11.lib;ws2_32.lib;Iphlpapi.lib;Winmm.lib;librtmp.lib;libmp3lame-static.lib;libfaac.lib;dsound.lib;obsapi.lib;shell32.lib;gdiplus.lib;mfplat.lib;Mfuuid.lib;Winhttp.lib;libx264.lib;UxTheme.lib;Xinput9_1_0.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Avrt.lib;dwmapi.lib;comctl32.lib;dxgi.lib;dxguid.lib;d3d10_1.lib;d3dx10.lib;ws2_32.lib;Iphlpapi.lib;Winmm.lib;librtmp.lib;libmp3lame-static.lib;libfaac.lib;dsound.lib;obsapi.lib;shell32.lib;gdiplus.lib;mfplat.lib;Mfuuid.lib;Winhttp.lib;libx264.lib;UxTheme.lib;Xinput9_1_0.lib;%(AdditionalDependencies)</AdditionalDependencies>
<Version>
</Version>
<AdditionalLibraryDirectories>OBSApi/x64/Debug;x264/libs/64bit;librtmp/x64/debug;lame/output/64bit;libfaac/x64/debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -197,7 +197,7 @@
</ClCompile>
<Link>
<AdditionalOptions>/ignore:4049 /ignore:4217 %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>Avrt.lib;dwmapi.lib;comctl32.lib;dxgi.lib;dxguid.lib;d3d11.lib;d3dx11.lib;ws2_32.lib;Iphlpapi.lib;Winmm.lib;librtmp.lib;libmp3lame-static.lib;libfaac.lib;dsound.lib;obsapi.lib;shell32.lib;gdiplus.lib;mfplat.lib;Mfuuid.lib;Winhttp.lib;libx264.lib;UxTheme.lib;Xinput9_1_0.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Avrt.lib;dwmapi.lib;comctl32.lib;dxgi.lib;dxguid.lib;d3d10_1.lib;d3dx10.lib;ws2_32.lib;Iphlpapi.lib;Winmm.lib;librtmp.lib;libmp3lame-static.lib;libfaac.lib;dsound.lib;obsapi.lib;shell32.lib;gdiplus.lib;mfplat.lib;Mfuuid.lib;Winhttp.lib;libx264.lib;UxTheme.lib;Xinput9_1_0.lib;%(AdditionalDependencies)</AdditionalDependencies>
<Version>
</Version>
<AdditionalLibraryDirectories>OBSApi/Release;x264/libs/32bit;librtmp/release;lame/output/32bit;libfaac/release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -239,7 +239,7 @@
<AdditionalOptions>/d2Zi+ %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>Avrt.lib;dwmapi.lib;comctl32.lib;dxgi.lib;dxguid.lib;d3d11.lib;d3dx11.lib;ws2_32.lib;Iphlpapi.lib;Winmm.lib;librtmp.lib;libmp3lame-static.lib;libfaac.lib;dsound.lib;obsapi.lib;shell32.lib;gdiplus.lib;mfplat.lib;Mfuuid.lib;Winhttp.lib;libx264.lib;UxTheme.lib;Xinput9_1_0.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Avrt.lib;dwmapi.lib;comctl32.lib;dxgi.lib;dxguid.lib;d3d10_1.lib;d3dx10.lib;ws2_32.lib;Iphlpapi.lib;Winmm.lib;librtmp.lib;libmp3lame-static.lib;libfaac.lib;dsound.lib;obsapi.lib;shell32.lib;gdiplus.lib;mfplat.lib;Mfuuid.lib;Winhttp.lib;libx264.lib;UxTheme.lib;Xinput9_1_0.lib;%(AdditionalDependencies)</AdditionalDependencies>
<Version>
</Version>
<AdditionalLibraryDirectories>OBSApi/x64/Release;x264/libs/64bit;librtmp/x64/release;lame/output/64bit;libfaac/x64/release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -320,7 +320,7 @@
<ClInclude Include="Source\CodeTokenizer.h" />
<ClInclude Include="Source\CrashDumpHandler.h" />
<ClInclude Include="Source\D3D10System.h" />
<ClInclude Include="Source\DataPacketHelpers.h" />
<ClInclude Include="Source\DataPacketHelpers.h"/>
<ClInclude Include="Source\HTTPClient.h" />
<ClInclude Include="Source\libnsgif.h" />
<ClInclude Include="Source\LogUploader.h" />
@ -359,4 +359,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -210,9 +210,9 @@
<ClInclude Include="Source\LogUploader.h">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="Source\DataPacketHelpers.h">
<ClCompile Include="Source\DataPacketHelpers.h">
<Filter>Headers</Filter>
</ClInclude>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="cursor1.cur">
@ -293,4 +293,4 @@
<Filter>Resources</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
</Project>

View File

@ -608,9 +608,6 @@ public:
private:
virtual void CreateVertexShaderBlob(ShaderBlob &blob, CTSTR lpShader, CTSTR lpFileName) = 0;
virtual void CreatePixelShaderBlob(ShaderBlob &blob, CTSTR lpShader, CTSTR lpFileName) = 0;
public:
virtual LPVOID GetContext()=0;
};

View File

@ -507,8 +507,8 @@ bool STDCALL ConfigureBitmapSource(XElement *element, bool bCreating)
{
CTSTR lpBitmap = data->GetString(TEXT("path"));
D3DX11_IMAGE_INFO ii;
if(SUCCEEDED(D3DX11GetImageInfoFromFile(lpBitmap, NULL, &ii, NULL)))
D3DX10_IMAGE_INFO ii;
if(SUCCEEDED(D3DX10GetImageInfoFromFile(lpBitmap, NULL, &ii, NULL)))
{
element->SetInt(TEXT("cx"), ii.Width);
element->SetInt(TEXT("cy"), ii.Height);

View File

@ -448,8 +448,8 @@ INT_PTR CALLBACK ConfigureBitmapTransitionProc(HWND hwnd, UINT message, WPARAM w
ConfigBitmapInfo *configInfo = (ConfigBitmapInfo*)GetWindowLongPtr(hwnd, DWLP_USER);
D3DX11_IMAGE_INFO ii;
if(SUCCEEDED(D3DX11GetImageInfoFromFile(bitmapList[0], NULL, &ii, NULL)))
D3DX10_IMAGE_INFO ii;
if(SUCCEEDED(D3DX10GetImageInfoFromFile(bitmapList[0], NULL, &ii, NULL)))
{
configInfo->cx = ii.Width;
configInfo->cy = ii.Height;

View File

@ -101,8 +101,8 @@ DuplicatorInfo D3D10OutputDuplicator::AcquireNextFrame(UINT timeout)
//------------------------------------------
ID3D11Texture2D *texVal;
if(FAILED(hRes = tempResource->QueryInterface(__uuidof(ID3D11Texture2D), (void**)&texVal)))
ID3D10Texture2D *texVal;
if(FAILED(hRes = tempResource->QueryInterface(__uuidof(ID3D10Texture2D), (void**)&texVal)))
{
SafeRelease(tempResource);
AppWarning(TEXT("D3D10OutputDuplicator::AcquireNextFrame: could not query interface, result = 0x%08lX"), hRes);
@ -113,7 +113,7 @@ DuplicatorInfo D3D10OutputDuplicator::AcquireNextFrame(UINT timeout)
//------------------------------------------
D3D11_TEXTURE2D_DESC texDesc;
D3D10_TEXTURE2D_DESC texDesc;
texVal->GetDesc(&texDesc);
if(!copyTex || copyTex->Width() != texDesc.Width || copyTex->Height() != texDesc.Height)
@ -127,7 +127,7 @@ DuplicatorInfo D3D10OutputDuplicator::AcquireNextFrame(UINT timeout)
if(copyTex)
{
D3D10Texture *d3dCopyTex = (D3D10Texture*)copyTex;
GetD3DCtx()->CopyResource(d3dCopyTex->texture, texVal);
GetD3D()->CopyResource(d3dCopyTex->texture, texVal);
}
SafeRelease(texVal);

View File

@ -58,13 +58,13 @@ bool D3D10Shader::ProcessData(ShaderProcessor &processor, CTSTR lpFileName)
if(constantSize)
{
D3D11_BUFFER_DESC bd;
D3D10_BUFFER_DESC bd;
zero(&bd, sizeof(bd));
bd.ByteWidth = (constantSize+15)&0xFFFFFFF0; //align to 128bit boundry
bd.Usage = D3D11_USAGE_DYNAMIC;
bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
bd.Usage = D3D10_USAGE_DYNAMIC;
bd.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
bd.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
HRESULT err = GetD3D()->CreateBuffer(&bd, NULL, &constantBuffer);
if(FAILED(err))
@ -89,7 +89,7 @@ void D3D10VertexShader::CreateVertexShaderBlob(ShaderBlob &blob, CTSTR lpShader,
LPSTR lpAnsiShader = tstr_createUTF8(lpShader);
LPSTR lpAnsiFileName = tstr_createUTF8(lpFileName);
HRESULT err = D3DX11CompileFromMemory(lpAnsiShader, strlen(lpAnsiShader), lpAnsiFileName, NULL, NULL, "main", lpVSType, D3D10_SHADER_OPTIMIZATION_LEVEL3, 0, NULL, shaderBlob.Assign(), errorMessages.Assign(), NULL);
HRESULT err = D3DX10CompileFromMemory(lpAnsiShader, strlen(lpAnsiShader), lpAnsiFileName, NULL, NULL, "main", lpVSType, D3D10_SHADER_OPTIMIZATION_LEVEL3, 0, NULL, shaderBlob.Assign(), errorMessages.Assign(), NULL);
Free(lpAnsiFileName);
Free(lpAnsiShader);
@ -123,10 +123,10 @@ Shader* D3D10VertexShader::CreateVertexShaderFromBlob(ShaderBlob const &blob, CT
if (!blob.size())
return nullptr;
ComPtr<ID3D11VertexShader> vShader;
ID3D11InputLayout *vShaderLayout;
ComPtr<ID3D10VertexShader> vShader;
ID3D10InputLayout *vShaderLayout;
HRESULT err = GetD3D()->CreateVertexShader(&blob.front(), blob.size(), NULL, vShader.Assign());
HRESULT err = GetD3D()->CreateVertexShader(&blob.front(), blob.size(), vShader.Assign());
if (FAILED(err))
{
CrashError(TEXT("Unable to create vertex shader '%s', result = %08lX"), lpFileName, err);
@ -177,7 +177,7 @@ void D3D10PixelShader::CreatePixelShaderBlob(ShaderBlob &blob, CTSTR lpShader, C
LPSTR lpAnsiShader = tstr_createUTF8(lpShader);
LPSTR lpAnsiFileName = tstr_createUTF8(lpFileName);
HRESULT err = D3DX11CompileFromMemory(lpAnsiShader, strlen(lpAnsiShader), lpAnsiFileName, NULL, NULL, "main", lpPSType, D3D10_SHADER_OPTIMIZATION_LEVEL3, 0, NULL, shaderBlob.Assign(), errorMessages.Assign(), NULL);
HRESULT err = D3DX10CompileFromMemory(lpAnsiShader, strlen(lpAnsiShader), lpAnsiFileName, NULL, NULL, "main", lpPSType, D3D10_SHADER_OPTIMIZATION_LEVEL3, 0, NULL, shaderBlob.Assign(), errorMessages.Assign(), NULL);
Free(lpAnsiFileName);
Free(lpAnsiShader);
@ -211,9 +211,9 @@ Shader *D3D10PixelShader::CreatePixelShaderFromBlob(ShaderBlob const &blob, CTST
if (!blob.size())
return nullptr;
ID3D11PixelShader *pShader;
ID3D10PixelShader *pShader;
HRESULT err = GetD3D()->CreatePixelShader(&blob.front(), blob.size(), NULL, &pShader);
HRESULT err = GetD3D()->CreatePixelShader(&blob.front(), blob.size(), &pShader);
if (FAILED(err))
{
CrashError(TEXT("Unable to create pixel shader '%s', result = %08lX"), lpFileName, err);
@ -442,16 +442,16 @@ void D3D10Shader::UpdateParams()
if(bUpload)
{
D3D11_MAPPED_SUBRESOURCE map;
BYTE *outData;
HRESULT err;
if(FAILED(err = GetD3DCtx()->Map(constantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map)))
if(FAILED(err = constantBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&outData)))
{
AppWarning(TEXT("D3D10Shader::UpdateParams: could not map constant buffer, result = %08lX"), err);
return;
}
mcpy(map.pData, shaderConstantData.Array(), shaderConstantData.Num());
GetD3DCtx()->Unmap(constantBuffer, 0);
mcpy(outData, shaderConstantData.Array(), shaderConstantData.Num());
constantBuffer->Unmap();
}
}

View File

@ -161,12 +161,12 @@ BOOL ShaderProcessor::ProcessShader(CTSTR input, CTSTR filename)
break;
}
D3D11_INPUT_ELEMENT_DESC inputElement;
D3D10_INPUT_ELEMENT_DESC inputElement;
inputElement.SemanticName = semanticInfo.lpName;
inputElement.SemanticIndex = semanticInfo.index;
inputElement.InputSlot = 0;
inputElement.AlignedByteOffset = 0;
inputElement.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
inputElement.InputSlotClass = D3D10_INPUT_PER_VERTEX_DATA;
inputElement.InstanceDataStepRate = 0;
if(strSemantic.CompareI(TEXT("color")))

View File

@ -174,14 +174,6 @@ static void HandleNvidiaOptimus(IDXGIFactory1 *factory, IDXGIAdapter1 *&adapter,
}
}
const static D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_3,
};
D3D10System::D3D10System()
{
HRESULT err;
@ -234,11 +226,11 @@ D3D10System::D3D10System()
bDisableCompatibilityMode = 1;//AppConfig->GetInt(TEXT("Video"), TEXT("DisableD3DCompatibilityMode"), 1) != 0;
UINT createFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
UINT createFlags = D3D10_CREATE_DEVICE_BGRA_SUPPORT;
if(GlobalConfig->GetInt(TEXT("General"), TEXT("UseDebugD3D")))
createFlags |= D3D11_CREATE_DEVICE_DEBUG;
createFlags |= D3D10_CREATE_DEVICE_DEBUG;
D3D_FEATURE_LEVEL level;
D3D10_FEATURE_LEVEL1 level = bDisableCompatibilityMode ? D3D10_FEATURE_LEVEL_10_1 : D3D10_FEATURE_LEVEL_9_3;
String adapterName;
DXGI_ADAPTER_DESC desc;
@ -249,22 +241,31 @@ D3D10System::D3D10System()
adapterName.KillSpaces();
Log(TEXT("Loading up D3D11 on %s (Adapter %u)..."), adapterName.Array(), adapterID+1);
Log(TEXT("Loading up D3D10 on %s (Adapter %u)..."), adapterName.Array(), adapterID+1);
//D3D11_CREATE_DEVICE_DEBUG
//D3D10_CREATE_DEVICE_DEBUG
//D3D11_DRIVER_TYPE_REFERENCE, D3D11_DRIVER_TYPE_HARDWARE
err = D3D11CreateDeviceAndSwapChain(adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, createFlags, featureLevels, sizeof(featureLevels) / sizeof(featureLevels[0]), D3D11_SDK_VERSION, &swapDesc, &swap, &d3d, &level, &context);
err = D3D10CreateDeviceAndSwapChain1(adapter, D3D10_DRIVER_TYPE_HARDWARE, NULL, createFlags, level, D3D10_1_SDK_VERSION, &swapDesc, &swap, &d3d);
if(FAILED(err))
{
Log (TEXT("D3D11CreateDeviceAndSwapChain: Failed on %s: 0x%08x"), adapterName.Array(), err);
CrashError(TEXT("Could not initialize DirectX 11 on %s. This error can happen for one of the following reasons:\r\n\r\n1.) Your GPU is not supported (DirectX 11 is required - note that many integrated laptop GPUs do not support DX11)\r\n2.) You're running Windows Vista without the \"Platform Update\"\r\n3.) Your video card drivers are out of date\r\n\r\nIf you are using a laptop with NVIDIA Optimus or AMD Switchable Graphics, make sure OBS is set to run on the high performance GPU in your driver settings."), adapterName.Array());
Log (TEXT("D3D10CreateDeviceAndSwapChain1: Failed on %s: 0x%08x. Trying compatibility mode"), adapterName.Array(), err);
bDisableCompatibilityMode = !bDisableCompatibilityMode;
level = bDisableCompatibilityMode ? D3D10_FEATURE_LEVEL_10_1 : D3D10_FEATURE_LEVEL_9_3;
err = D3D10CreateDeviceAndSwapChain1(adapter, D3D10_DRIVER_TYPE_HARDWARE, NULL, createFlags, level, D3D10_1_SDK_VERSION, &swapDesc, &swap, &d3d);
}
if(FAILED(err))
{
Log (TEXT("D3D10CreateDeviceAndSwapChain1: Failed on %s: 0x%08x"), adapterName.Array(), err);
CrashError(TEXT("Could not initialize DirectX 10 on %s. This error can happen for one of the following reasons:\r\n\r\n1.) Your GPU is not supported (DirectX 10 is required - note that many integrated laptop GPUs do not support DX10)\r\n2.) You're running Windows Vista without the \"Platform Update\"\r\n3.) Your video card drivers are out of date\r\n\r\nIf you are using a laptop with NVIDIA Optimus or AMD Switchable Graphics, make sure OBS is set to run on the high performance GPU in your driver settings."), adapterName.Array());
}
adapter->Release();
//------------------------------------------------------------------
D3D11_DEPTH_STENCIL_DESC depthDesc;
D3D10_DEPTH_STENCIL_DESC depthDesc;
zero(&depthDesc, sizeof(depthDesc));
depthDesc.DepthEnable = FALSE;
@ -272,14 +273,14 @@ D3D10System::D3D10System()
if(FAILED(err))
CrashError(TEXT("Unable to create depth state"));
context->OMSetDepthStencilState(depthState, 0);
d3d->OMSetDepthStencilState(depthState, 0);
//------------------------------------------------------------------
D3D11_RASTERIZER_DESC rasterizerDesc;
D3D10_RASTERIZER_DESC rasterizerDesc;
zero(&rasterizerDesc, sizeof(rasterizerDesc));
rasterizerDesc.FillMode = D3D11_FILL_SOLID;
rasterizerDesc.CullMode = D3D11_CULL_NONE;
rasterizerDesc.FillMode = D3D10_FILL_SOLID;
rasterizerDesc.CullMode = D3D10_CULL_NONE;
rasterizerDesc.FrontCounterClockwise = FALSE;
rasterizerDesc.DepthClipEnable = TRUE;
@ -287,7 +288,7 @@ D3D10System::D3D10System()
if(FAILED(err))
CrashError(TEXT("Unable to create rasterizer state"));
context->RSSetState(rasterizerState);
d3d->RSSetState(rasterizerState);
//------------------------------------------------------------------
@ -299,8 +300,8 @@ D3D10System::D3D10System()
//------------------------------------------------------------------
ID3D11Texture2D *backBuffer = NULL;
err = swap->GetBuffer(0, IID_ID3D11Texture2D, (void**)&backBuffer);
ID3D10Texture2D *backBuffer = NULL;
err = swap->GetBuffer(0, IID_ID3D10Texture2D, (void**)&backBuffer);
if(FAILED(err))
CrashError(TEXT("Unable to get back buffer from swap chain"));
@ -312,19 +313,19 @@ D3D10System::D3D10System()
//------------------------------------------------------------------
D3D11_BLEND_DESC disabledBlendDesc;
D3D10_BLEND_DESC disabledBlendDesc;
zero(&disabledBlendDesc, sizeof(disabledBlendDesc));
for(int i=0; i<8; i++)
{
disabledBlendDesc.RenderTarget[i].BlendEnable = TRUE;
disabledBlendDesc.RenderTarget[i].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
disabledBlendDesc.RenderTarget[i].BlendOpAlpha = D3D11_BLEND_OP_ADD;
disabledBlendDesc.RenderTarget[i].BlendOp = D3D11_BLEND_OP_ADD;
disabledBlendDesc.RenderTarget[i].SrcBlendAlpha = D3D11_BLEND_ONE;
disabledBlendDesc.RenderTarget[i].DestBlendAlpha = D3D11_BLEND_ZERO;
disabledBlendDesc.RenderTarget[i].SrcBlend = D3D11_BLEND_ONE;
disabledBlendDesc.RenderTarget[i].DestBlend = D3D11_BLEND_ZERO;
disabledBlendDesc.BlendEnable[i] = TRUE;
disabledBlendDesc.RenderTargetWriteMask[i] = D3D10_COLOR_WRITE_ENABLE_ALL;
}
disabledBlendDesc.BlendOpAlpha = D3D10_BLEND_OP_ADD;
disabledBlendDesc.BlendOp = D3D10_BLEND_OP_ADD;
disabledBlendDesc.SrcBlendAlpha = D3D10_BLEND_ONE;
disabledBlendDesc.DestBlendAlpha = D3D10_BLEND_ZERO;
disabledBlendDesc.SrcBlend = D3D10_BLEND_ONE;
disabledBlendDesc.DestBlend = D3D10_BLEND_ZERO;
err = d3d->CreateBlendState(&disabledBlendDesc, &disabledBlend);
if(FAILED(err))
@ -348,7 +349,6 @@ D3D10System::~D3D10System()
SafeRelease(disabledBlend);
SafeRelease(swapRenderView);
SafeRelease(swap);
SafeRelease(context);
SafeRelease(d3d);
SafeRelease(factory);
}
@ -370,19 +370,19 @@ void D3D10System::UnloadAllData()
zero(nullBuff, sizeof(nullBuff));
context->VSSetConstantBuffers(0, 1, (ID3D11Buffer**)nullBuff);
context->PSSetConstantBuffers(0, 1, (ID3D11Buffer**)nullBuff);
context->OMSetDepthStencilState(NULL, 0);
context->PSSetSamplers(0, 1, (ID3D11SamplerState**)nullBuff);
context->OMSetBlendState(NULL, bla, 0xFFFFFFFF);
context->OMSetRenderTargets(1, (ID3D11RenderTargetView**)nullBuff, NULL);
context->IASetVertexBuffers(0, 8, (ID3D11Buffer**)nullBuff, &zeroVal, &zeroVal);
context->PSSetShaderResources(0, 8, (ID3D11ShaderResourceView**)nullBuff);
context->IASetInputLayout(NULL);
context->PSSetShader(NULL, NULL, 0);
context->VSSetShader(NULL, NULL, 0);
context->RSSetState(NULL);
context->RSSetScissorRects(0, NULL);
d3d->VSSetConstantBuffers(0, 1, (ID3D10Buffer**)nullBuff);
d3d->PSSetConstantBuffers(0, 1, (ID3D10Buffer**)nullBuff);
d3d->OMSetDepthStencilState(NULL, 0);
d3d->PSSetSamplers(0, 1, (ID3D10SamplerState**)nullBuff);
d3d->OMSetBlendState(NULL, bla, 0xFFFFFFFF);
d3d->OMSetRenderTargets(1, (ID3D10RenderTargetView**)nullBuff, NULL);
d3d->IASetVertexBuffers(0, 8, (ID3D10Buffer**)nullBuff, &zeroVal, &zeroVal);
d3d->PSSetShaderResources(0, 8, (ID3D10ShaderResourceView**)nullBuff);
d3d->IASetInputLayout(NULL);
d3d->PSSetShader(NULL);
d3d->VSSetShader(NULL);
d3d->RSSetState(NULL);
d3d->RSSetScissorRects(0, NULL);
}
LPVOID D3D10System::GetDevice()
@ -390,11 +390,6 @@ LPVOID D3D10System::GetDevice()
return (LPVOID)d3d;
}
LPVOID D3D10System::GetContext()
{
return (LPVOID)context;
}
void D3D10System::Init()
{
@ -452,8 +447,8 @@ Texture* D3D10System::CreateGDITexture(unsigned int width, unsigned int height)
bool D3D10System::GetTextureFileInfo(CTSTR lpFile, TextureInfo &info)
{
D3DX11_IMAGE_INFO ii;
if(SUCCEEDED(D3DX11GetImageInfoFromFile(lpFile, NULL, &ii, NULL)))
D3DX10_IMAGE_INFO ii;
if(SUCCEEDED(D3DX10GetImageInfoFromFile(lpFile, NULL, &ii, NULL)))
{
info.width = ii.Width;
info.height = ii.Height;
@ -573,7 +568,7 @@ void D3D10System::LoadVertexBuffer(VertexBuffer* vb)
D3D10VertexBuffer *d3dVB = static_cast<D3D10VertexBuffer*>(vb);
if(curVertexShader)
{
List<ID3D11Buffer*> buffers;
List<ID3D10Buffer*> buffers;
List<UINT> strides;
List<UINT> offsets;
@ -587,7 +582,7 @@ void D3D10System::LoadVertexBuffer(VertexBuffer* vb)
}
offsets.SetSize(buffers.Num());
context->IASetVertexBuffers(0, buffers.Num(), buffers.Array(), strides.Array(), offsets.Array());
d3d->IASetVertexBuffers(0, buffers.Num(), buffers.Array(), strides.Array(), offsets.Array());
}
curVertexBuffer = d3dVB;
@ -600,11 +595,11 @@ void D3D10System::LoadTexture(Texture *texture, UINT idTexture)
{
D3D10Texture *d3dTex = static_cast<D3D10Texture*>(texture);
if(d3dTex)
context->PSSetShaderResources(idTexture, 1, &d3dTex->resource);
d3d->PSSetShaderResources(idTexture, 1, &d3dTex->resource);
else
{
LPVOID lpNull = NULL;
context->PSSetShaderResources(idTexture, 1, (ID3D11ShaderResourceView**)&lpNull);
d3d->PSSetShaderResources(idTexture, 1, (ID3D10ShaderResourceView**)&lpNull);
}
curTextures[idTexture] = d3dTex;
@ -617,11 +612,11 @@ void D3D10System::LoadSamplerState(SamplerState *sampler, UINT idSampler)
{
D3D10SamplerState *d3dSampler = static_cast<D3D10SamplerState*>(sampler);
if(d3dSampler)
context->PSSetSamplers(idSampler, 1, &d3dSampler->state);
d3d->PSSetSamplers(idSampler, 1, &d3dSampler->state);
else
{
LPVOID lpNull = NULL;
context->PSSetSamplers(idSampler, 1, (ID3D11SamplerState**)&lpNull);
d3d->PSSetSamplers(idSampler, 1, (ID3D10SamplerState**)&lpNull);
}
curSamplers[idSampler] = d3dSampler;
}
@ -639,9 +634,9 @@ void D3D10System::LoadVertexShader(Shader *vShader)
D3D10VertexShader *shader = static_cast<D3D10VertexShader*>(vShader);
context->VSSetShader(shader->vertexShader, NULL, 0);
context->IASetInputLayout(shader->inputLayout);
context->VSSetConstantBuffers(0, 1, &shader->constantBuffer);
d3d->VSSetShader(shader->vertexShader);
d3d->IASetInputLayout(shader->inputLayout);
d3d->VSSetConstantBuffers(0, 1, &shader->constantBuffer);
if(lastVertexBuffer)
LoadVertexBuffer(lastVertexBuffer);
@ -650,8 +645,8 @@ void D3D10System::LoadVertexShader(Shader *vShader)
{
LPVOID lpNULL = NULL;
context->VSSetShader(NULL, NULL, 0);
context->VSSetConstantBuffers(0, 1, (ID3D11Buffer**)&lpNULL);
d3d->VSSetShader(NULL);
d3d->VSSetConstantBuffers(0, 1, (ID3D10Buffer**)&lpNULL);
}
curVertexShader = static_cast<D3D10VertexShader*>(vShader);
@ -666,8 +661,8 @@ void D3D10System::LoadPixelShader(Shader *pShader)
{
D3D10PixelShader *shader = static_cast<D3D10PixelShader*>(pShader);
context->PSSetShader(shader->pixelShader, NULL, 0);
context->PSSetConstantBuffers(0, 1, &shader->constantBuffer);
d3d->PSSetShader(shader->pixelShader);
d3d->PSSetConstantBuffers(0, 1, &shader->constantBuffer);
for(UINT i=0; i<shader->Samplers.Num(); i++)
LoadSamplerState(shader->Samplers[i].sampler, i);
@ -676,15 +671,15 @@ void D3D10System::LoadPixelShader(Shader *pShader)
{
LPVOID lpNULL = NULL;
context->PSSetShader(NULL, NULL, 0);
context->PSSetConstantBuffers(0, 1, (ID3D11Buffer**)&lpNULL);
d3d->PSSetShader(NULL);
d3d->PSSetConstantBuffers(0, 1, (ID3D10Buffer**)&lpNULL);
for(UINT i=0; i<8; i++)
curSamplers[i] = NULL;
ID3D11SamplerState *states[8];
ID3D10SamplerState *states[8];
zero(states, sizeof(states));
context->PSSetSamplers(0, 8, states);
d3d->PSSetSamplers(0, 8, states);
}
curPixelShader = static_cast<D3D10PixelShader*>(pShader);
@ -707,23 +702,23 @@ void D3D10System::SetRenderTarget(Texture *texture)
{
if(texture)
{
ID3D11RenderTargetView *view = static_cast<D3D10Texture*>(texture)->renderTarget;
ID3D10RenderTargetView *view = static_cast<D3D10Texture*>(texture)->renderTarget;
if(!view)
{
AppWarning(TEXT("tried to set a texture that wasn't a render target as a render target"));
return;
}
context->OMSetRenderTargets(1, &view, NULL);
d3d->OMSetRenderTargets(1, &view, NULL);
}
else
context->OMSetRenderTargets(1, &swapRenderView, NULL);
d3d->OMSetRenderTargets(1, &swapRenderView, NULL);
curRenderTarget = static_cast<D3D10Texture*>(texture);
}
}
const D3D11_PRIMITIVE_TOPOLOGY topologies[] = {D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, D3D11_PRIMITIVE_TOPOLOGY_LINELIST, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP};
const D3D10_PRIMITIVE_TOPOLOGY topologies[] = {D3D10_PRIMITIVE_TOPOLOGY_POINTLIST, D3D10_PRIMITIVE_TOPOLOGY_LINELIST, D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP};
void D3D10System::Draw(GSDrawMode drawMode, DWORD startVert, DWORD nVerts)
{
@ -750,33 +745,33 @@ void D3D10System::Draw(GSDrawMode drawMode, DWORD startVert, DWORD nVerts)
curVertexShader->UpdateParams();
curPixelShader->UpdateParams();
D3D11_PRIMITIVE_TOPOLOGY newTopology = topologies[(int)drawMode];
D3D10_PRIMITIVE_TOPOLOGY newTopology = topologies[(int)drawMode];
if(newTopology != curTopology)
{
context->IASetPrimitiveTopology(newTopology);
d3d->IASetPrimitiveTopology(newTopology);
curTopology = newTopology;
}
if(nVerts == 0)
nVerts = static_cast<D3D10VertexBuffer*>(curVertexBuffer)->numVerts;
context->Draw(nVerts, startVert);
d3d->Draw(nVerts, startVert);
}
////////////////////////////
//Drawing mode functions
const D3D11_BLEND blendConvert[] = {D3D11_BLEND_ZERO, D3D11_BLEND_ONE, D3D11_BLEND_SRC_COLOR, D3D11_BLEND_INV_SRC_COLOR, D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_DEST_COLOR, D3D11_BLEND_INV_DEST_COLOR, D3D11_BLEND_DEST_ALPHA, D3D11_BLEND_INV_DEST_ALPHA, D3D11_BLEND_BLEND_FACTOR, D3D11_BLEND_INV_BLEND_FACTOR};
const D3D10_BLEND blendConvert[] = {D3D10_BLEND_ZERO, D3D10_BLEND_ONE, D3D10_BLEND_SRC_COLOR, D3D10_BLEND_INV_SRC_COLOR, D3D10_BLEND_SRC_ALPHA, D3D10_BLEND_INV_SRC_ALPHA, D3D10_BLEND_DEST_COLOR, D3D10_BLEND_INV_DEST_COLOR, D3D10_BLEND_DEST_ALPHA, D3D10_BLEND_INV_DEST_ALPHA, D3D10_BLEND_BLEND_FACTOR, D3D10_BLEND_INV_BLEND_FACTOR};
void D3D10System::EnableBlending(BOOL bEnable)
{
if(bBlendingEnabled != bEnable)
{
if(bBlendingEnabled = bEnable)
context->OMSetBlendState(curBlendState, curBlendFactor, 0xFFFFFFFF);
d3d->OMSetBlendState(curBlendState, curBlendFactor, 0xFFFFFFFF);
else
context->OMSetBlendState(disabledBlend, curBlendFactor, 0xFFFFFFFF);
d3d->OMSetBlendState(disabledBlend, curBlendFactor, 0xFFFFFFFF);
}
}
@ -794,7 +789,7 @@ void D3D10System::BlendFunction(GSBlendType srcFactor, GSBlendType destFactor, f
{
if(bUseFactor || curBlendState != blendInfo.blendState)
{
context->OMSetBlendState(blendInfo.blendState, curBlendFactor, 0xFFFFFFFF);
d3d->OMSetBlendState(blendInfo.blendState, curBlendFactor, 0xFFFFFFFF);
curBlendState = blendInfo.blendState;
}
return;
@ -802,19 +797,19 @@ void D3D10System::BlendFunction(GSBlendType srcFactor, GSBlendType destFactor, f
}
//blend wasn't found, create a new one and save it for later
D3D11_BLEND_DESC blendDesc;
D3D10_BLEND_DESC blendDesc;
zero(&blendDesc, sizeof(blendDesc));
for(int i=0; i<8; i++)
{
blendDesc.RenderTarget[i].BlendEnable = TRUE;
blendDesc.RenderTarget[i].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
blendDesc.RenderTarget[i].BlendOpAlpha = D3D11_BLEND_OP_ADD;
blendDesc.RenderTarget[i].BlendOp = D3D11_BLEND_OP_ADD;
blendDesc.RenderTarget[i].SrcBlendAlpha = D3D11_BLEND_ONE;
blendDesc.RenderTarget[i].DestBlendAlpha = D3D11_BLEND_ZERO;
blendDesc.RenderTarget[i].SrcBlend = blendConvert[srcFactor];
blendDesc.RenderTarget[i].DestBlend = blendConvert[destFactor];
blendDesc.BlendEnable[i] = TRUE;
blendDesc.RenderTargetWriteMask[i] = D3D10_COLOR_WRITE_ENABLE_ALL;
}
blendDesc.BlendOpAlpha = D3D10_BLEND_OP_ADD;
blendDesc.BlendOp = D3D10_BLEND_OP_ADD;
blendDesc.SrcBlendAlpha = D3D10_BLEND_ONE;
blendDesc.DestBlendAlpha = D3D10_BLEND_ZERO;
blendDesc.SrcBlend = blendConvert[srcFactor];
blendDesc.DestBlend = blendConvert[destFactor];
SavedBlendState *savedBlend = blends.CreateNew();
savedBlend->destFactor = destFactor;
@ -824,7 +819,7 @@ void D3D10System::BlendFunction(GSBlendType srcFactor, GSBlendType destFactor, f
CrashError(TEXT("Could not set blend state"));
if(bBlendingEnabled)
context->OMSetBlendState(savedBlend->blendState, curBlendFactor, 0xFFFFFFFF);
d3d->OMSetBlendState(savedBlend->blendState, curBlendFactor, 0xFFFFFFFF);
curBlendState = savedBlend->blendState;
}
@ -836,9 +831,9 @@ void D3D10System::ClearColorBuffer(DWORD color)
D3D10Texture *d3dTex = static_cast<D3D10Texture*>(curRenderTarget);
if(d3dTex)
context->ClearRenderTargetView(d3dTex->renderTarget, floatColor.ptr);
d3d->ClearRenderTargetView(d3dTex->renderTarget, floatColor.ptr);
else
context->ClearRenderTargetView(swapRenderView, floatColor.ptr);
d3d->ClearRenderTargetView(swapRenderView, floatColor.ptr);
}
@ -859,28 +854,28 @@ void D3D10System::Frustum(float left, float right, float top, float bottom, floa
void D3D10System::SetViewport(float x, float y, float width, float height)
{
D3D11_VIEWPORT vp;
D3D10_VIEWPORT vp;
zero(&vp, sizeof(vp));
vp.MaxDepth = 1.0f;
vp.TopLeftX = FLOAT(x);
vp.TopLeftY = FLOAT(y);
vp.Width = FLOAT(width);
vp.Height = FLOAT(height);
context->RSSetViewports(1, &vp);
vp.TopLeftX = INT(x);
vp.TopLeftY = INT(y);
vp.Width = UINT(width);
vp.Height = UINT(height);
d3d->RSSetViewports(1, &vp);
}
void D3D10System::SetScissorRect(XRect *pRect)
{
if(pRect)
{
context->RSSetState(scissorState);
D3D11_RECT rc = {pRect->x, pRect->y, pRect->x+pRect->cx, pRect->y+pRect->cy};
context->RSSetScissorRects(1, &rc);
d3d->RSSetState(scissorState);
D3D10_RECT rc = {pRect->x, pRect->y, pRect->x+pRect->cx, pRect->y+pRect->cy};
d3d->RSSetScissorRects(1, &rc);
}
else
{
context->RSSetState(rasterizerState);
context->RSSetScissorRects(0, NULL);
d3d->RSSetState(rasterizerState);
d3d->RSSetScissorRects(0, NULL);
}
}
@ -1049,14 +1044,14 @@ void D3D10System::ResetViewMatrix()
void D3D10System::ResizeView()
{
LPVOID nullVal = NULL;
context->OMSetRenderTargets(1, (ID3D11RenderTargetView**)&nullVal, NULL);
d3d->OMSetRenderTargets(1, (ID3D10RenderTargetView**)&nullVal, NULL);
SafeRelease(swapRenderView);
swap->ResizeBuffers(2, 0, 0, DXGI_FORMAT_B8G8R8A8_UNORM, 0);
ID3D11Texture2D *backBuffer = NULL;
HRESULT err = swap->GetBuffer(0, IID_ID3D11Texture2D, (void**)&backBuffer);
ID3D10Texture2D *backBuffer = NULL;
HRESULT err = swap->GetBuffer(0, IID_ID3D10Texture2D, (void**)&backBuffer);
if(FAILED(err))
CrashError(TEXT("Unable to get back buffer from swap chain"));
@ -1072,5 +1067,5 @@ void D3D10System::CopyTexture(Texture *texDest, Texture *texSrc)
D3D10Texture *d3d10Dest = static_cast<D3D10Texture*>(texDest);
D3D10Texture *d3d10Src = static_cast<D3D10Texture*>(texSrc);
context->CopyResource(d3d10Dest->texture, d3d10Src->texture);
d3d->CopyResource(d3d10Dest->texture, d3d10Src->texture);
}

View File

@ -47,11 +47,11 @@ class D3D10VertexBuffer : public VertexBuffer
friend class D3D10System;
friend class OBS;
ID3D11Buffer *vertexBuffer;
ID3D11Buffer *normalBuffer;
ID3D11Buffer *colorBuffer;
ID3D11Buffer *tangentBuffer;
List<ID3D11Buffer*> UVBuffers;
ID3D10Buffer *vertexBuffer;
ID3D10Buffer *normalBuffer;
ID3D10Buffer *colorBuffer;
ID3D10Buffer *tangentBuffer;
List<ID3D10Buffer*> UVBuffers;
UINT vertexSize;
UINT normalSize;
@ -65,7 +65,7 @@ class D3D10VertexBuffer : public VertexBuffer
static VertexBuffer* CreateVertexBuffer(VBData *vbData, BOOL bStatic);
void MakeBufferList(D3D10VertexShader *vShader, List<ID3D11Buffer*> &bufferList, List<UINT> &strides) const;
void MakeBufferList(D3D10VertexShader *vShader, List<ID3D10Buffer*> &bufferList, List<UINT> &strides) const;
public:
~D3D10VertexBuffer();
@ -81,7 +81,7 @@ class D3D10SamplerState : public SamplerState
friend class D3D10System;
friend class OBS;
ID3D11SamplerState *state;
ID3D10SamplerState *state;
static SamplerState* CreateSamplerState(SamplerInfo &info);
@ -97,9 +97,9 @@ class D3D10Texture : public Texture
friend class D3D10System;
friend class OBS;
ID3D11Texture2D *texture;
ID3D11ShaderResourceView *resource;
ID3D11RenderTargetView *renderTarget;
ID3D10Texture2D *texture;
ID3D10ShaderResourceView *resource;
ID3D10RenderTargetView *renderTarget;
UINT width, height;
GSColorFormat format;
@ -183,7 +183,7 @@ struct ShaderProcessor : CodeTokenizer
List<ShaderSampler> Samplers;
List<ShaderParam> Params;
List<D3D11_INPUT_ELEMENT_DESC> generatedLayout;
List<D3D10_INPUT_ELEMENT_DESC> generatedLayout;
bool bHasNormals;
bool bHasColors;
@ -226,7 +226,7 @@ class D3D10Shader : public Shader
List<ShaderParam> Params;
List<ShaderSampler> Samplers;
ID3D11Buffer *constantBuffer;
ID3D10Buffer *constantBuffer;
UINT constantSize;
protected:
@ -263,8 +263,8 @@ class D3D10VertexShader : public D3D10Shader
friend class D3D10VertexBuffer;
friend class OBS;
ID3D11VertexShader *vertexShader;
ID3D11InputLayout *inputLayout;
ID3D10VertexShader *vertexShader;
ID3D10InputLayout *inputLayout;
bool bHasNormals;
bool bHasColors;
@ -298,7 +298,7 @@ class D3D10PixelShader : public D3D10Shader
{
friend class D3D10System;
ID3D11PixelShader *pixelShader;
ID3D10PixelShader *pixelShader;
static Shader* CreatePixelShaderFromBlob(ShaderBlob const &blob, CTSTR lpShader, CTSTR lpFileName);
static Shader* CreatePixelShader(CTSTR lpShader, CTSTR lpFileName);
@ -336,7 +336,7 @@ public:
struct SavedBlendState
{
GSBlendType srcFactor, destFactor;
ID3D11BlendState *blendState;
ID3D10BlendState *blendState;
};
class D3D10System : public GraphicsSystem
@ -346,14 +346,13 @@ class D3D10System : public GraphicsSystem
friend class D3D10PixelShader;
IDXGIFactory1 *factory;
ID3D11Device *d3d;
ID3D11DeviceContext *context;
ID3D10Device1 *d3d;
IDXGISwapChain *swap;
ID3D11RenderTargetView *swapRenderView;
ID3D10RenderTargetView *swapRenderView;
ID3D11DepthStencilState *depthState;
ID3D11RasterizerState *rasterizerState;
ID3D11RasterizerState *scissorState;
ID3D10DepthStencilState *depthState;
ID3D10RasterizerState *rasterizerState;
ID3D10RasterizerState *scissorState;
bool bDisableCompatibilityMode;
@ -369,8 +368,8 @@ class D3D10System : public GraphicsSystem
D3D10_PRIMITIVE_TOPOLOGY curTopology;
List<SavedBlendState> blends;
ID3D11BlendState *curBlendState;
ID3D11BlendState *disabledBlend;
ID3D10BlendState *curBlendState;
ID3D10BlendState *disabledBlend;
BOOL bBlendingEnabled;
//---------------------------
@ -475,12 +474,6 @@ public:
// To prevent breaking the API, put this at the end instead of with the other Texture functions
virtual Texture* CreateSharedTexture(unsigned int width, unsigned int height);
virtual LPVOID GetContext();
inline ID3D11Device *GetDeviceInline() const {return d3d;}
inline ID3D11DeviceContext *GetContextInline() const {return context;}
};
inline ID3D11Device* GetD3D() {return static_cast<D3D10System*>(GS)->GetDeviceInline();}
inline ID3D11DeviceContext* GetD3DCtx() {return static_cast<D3D10System*>(GS)->GetContextInline();}
inline ID3D10Device* GetD3D() {return static_cast<ID3D10Device*>(GS->GetDevice());}

View File

@ -29,8 +29,8 @@ inline bool IsPow2(UINT num)
const DXGI_FORMAT convertFormat[] = {DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_B8G8R8X8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_B5G5R5A1_UNORM, DXGI_FORMAT_B5G6R5_UNORM, DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_BC5_UNORM};
const UINT formatPitch[] = {0, 1, 1, 4, 4, 4, 4, 8, 16, 0, 0, 0};
const D3D11_TEXTURE_ADDRESS_MODE convertAddressMode[] = {D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_WRAP, D3D11_TEXTURE_ADDRESS_MIRROR, D3D11_TEXTURE_ADDRESS_BORDER, D3D11_TEXTURE_ADDRESS_MIRROR_ONCE};
const D3D11_FILTER convertFilter[] = {D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_FILTER_ANISOTROPIC, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR, D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT, D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR, D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT, D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR, D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT};
const D3D10_TEXTURE_ADDRESS_MODE convertAddressMode[] = {D3D10_TEXTURE_ADDRESS_CLAMP, D3D10_TEXTURE_ADDRESS_WRAP, D3D10_TEXTURE_ADDRESS_MIRROR, D3D10_TEXTURE_ADDRESS_BORDER, D3D10_TEXTURE_ADDRESS_MIRROR_ONCE};
const D3D10_FILTER convertFilter[] = {D3D10_FILTER_MIN_MAG_MIP_LINEAR, D3D10_FILTER_MIN_MAG_MIP_POINT, D3D10_FILTER_ANISOTROPIC, D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR, D3D10_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT, D3D10_FILTER_MIN_POINT_MAG_MIP_LINEAR, D3D10_FILTER_MIN_LINEAR_MAG_MIP_POINT, D3D10_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR, D3D10_FILTER_MIN_MAG_LINEAR_MIP_POINT};
inline GSColorFormat GetGSFormatFromDXGIFormat(DXGI_FORMAT dxgiFormat)
{
@ -46,18 +46,18 @@ inline GSColorFormat GetGSFormatFromDXGIFormat(DXGI_FORMAT dxgiFormat)
SamplerState* D3D10SamplerState::CreateSamplerState(SamplerInfo &info)
{
D3D11_SAMPLER_DESC sampDesc;
D3D10_SAMPLER_DESC sampDesc;
zero(&sampDesc, sizeof(sampDesc));
sampDesc.AddressU = convertAddressMode[(UINT)info.addressU];
sampDesc.AddressV = convertAddressMode[(UINT)info.addressV];
sampDesc.AddressW = convertAddressMode[(UINT)info.addressW];
sampDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
sampDesc.ComparisonFunc = D3D10_COMPARISON_ALWAYS;
sampDesc.Filter = convertFilter[(UINT)info.filter];
sampDesc.MaxAnisotropy = 1;//info.maxAnisotropy;
sampDesc.MaxLOD = FLT_MAX;
mcpy(sampDesc.BorderColor, info.borderColor.ptr, sizeof(Color4));
ID3D11SamplerState *state;
ID3D10SamplerState *state;
HRESULT err = GetD3D()->CreateSamplerState(&sampDesc, &state);
if(FAILED(err))
{
@ -90,15 +90,15 @@ Texture* D3D10Texture::CreateFromSharedHandle(unsigned int width, unsigned int h
return NULL;
}
ID3D11Resource *tempResource;
if(FAILED(err = GetD3D()->OpenSharedResource(handle, __uuidof(ID3D11Resource), (void**)&tempResource)))
ID3D10Resource *tempResource;
if(FAILED(err = GetD3D()->OpenSharedResource(handle, __uuidof(ID3D10Resource), (void**)&tempResource)))
{
AppWarning(TEXT("D3D10Texture::CreateFromSharedHandle: Failed to open shared handle, result = 0x%08lX"), err);
return NULL;
}
ID3D11Texture2D *texVal;
if(FAILED(err = tempResource->QueryInterface(__uuidof(ID3D11Texture2D), (void**)&texVal)))
ID3D10Texture2D *texVal;
if(FAILED(err = tempResource->QueryInterface(__uuidof(ID3D10Texture2D), (void**)&texVal)))
{
SafeRelease(tempResource);
AppWarning(TEXT("D3D10Texture::CreateFromSharedHandle: could not query interface, result = 0x%08lX"), err);
@ -109,18 +109,18 @@ Texture* D3D10Texture::CreateFromSharedHandle(unsigned int width, unsigned int h
//------------------------------------------
D3D11_TEXTURE2D_DESC td;
D3D10_TEXTURE2D_DESC td;
texVal->GetDesc(&td);
//------------------------------------------
D3D11_SHADER_RESOURCE_VIEW_DESC resourceDesc;
D3D10_SHADER_RESOURCE_VIEW_DESC resourceDesc;
zero(&resourceDesc, sizeof(resourceDesc));
resourceDesc.Format = td.Format;
resourceDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
resourceDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
resourceDesc.Texture2D.MipLevels = 1;
ID3D11ShaderResourceView *resource = NULL;
ID3D10ShaderResourceView *resource = NULL;
if(FAILED(err = GetD3D()->CreateShaderResourceView(texVal, &resourceDesc, &resource)))
{
SafeRelease(texVal);
@ -159,20 +159,20 @@ Texture* D3D10Texture::CreateTexture(unsigned int width, unsigned int height, GS
bGenMipMaps = FALSE;
}
D3D11_TEXTURE2D_DESC td;
D3D10_TEXTURE2D_DESC td;
zero(&td, sizeof(td));
td.Width = width;
td.Height = height;
td.MipLevels = bGenMipMaps ? 0 : 1;
td.ArraySize = 1;
td.Format = format;
td.BindFlags = D3D11_BIND_SHADER_RESOURCE;
td.BindFlags = D3D10_BIND_SHADER_RESOURCE;
td.SampleDesc.Count = 1;
td.Usage = bStatic ? D3D11_USAGE_DEFAULT : D3D11_USAGE_DYNAMIC;
td.CPUAccessFlags = bStatic ? 0 : D3D11_CPU_ACCESS_WRITE;
td.Usage = bStatic ? D3D10_USAGE_DEFAULT : D3D10_USAGE_DYNAMIC;
td.CPUAccessFlags = bStatic ? 0 : D3D10_CPU_ACCESS_WRITE;
D3D11_SUBRESOURCE_DATA srd;
D3D11_SUBRESOURCE_DATA *lpSRD;
D3D10_SUBRESOURCE_DATA srd;
D3D10_SUBRESOURCE_DATA *lpSRD;
if(lpData)
{
srd.pSysMem = lpData;
@ -183,7 +183,7 @@ Texture* D3D10Texture::CreateTexture(unsigned int width, unsigned int height, GS
else
lpSRD = NULL;
ID3D11Texture2D *texVal;
ID3D10Texture2D *texVal;
if(FAILED(err = GetD3D()->CreateTexture2D(&td, lpSRD, &texVal)))
{
AppWarning(TEXT("D3D10Texture::CreateTexture: CreateTexture2D failed, result = 0x%08lX"), err);
@ -192,13 +192,13 @@ Texture* D3D10Texture::CreateTexture(unsigned int width, unsigned int height, GS
//------------------------------------------
D3D11_SHADER_RESOURCE_VIEW_DESC resourceDesc;
D3D10_SHADER_RESOURCE_VIEW_DESC resourceDesc;
zero(&resourceDesc, sizeof(resourceDesc));
resourceDesc.Format = format;
resourceDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
resourceDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
resourceDesc.Texture2D.MipLevels = bGenMipMaps ? -1 : 1;
ID3D11ShaderResourceView *resource;
ID3D10ShaderResourceView *resource;
if(FAILED(err = GetD3D()->CreateShaderResourceView(texVal, &resourceDesc, &resource)))
{
SafeRelease(texVal);
@ -223,8 +223,8 @@ Texture* D3D10Texture::CreateFromFile(CTSTR lpFile, BOOL bBuildMipMaps)
{
HRESULT err;
D3DX11_IMAGE_INFO ii;
if(FAILED(D3DX11GetImageInfoFromFile(lpFile, NULL, &ii, NULL)))
D3DX10_IMAGE_INFO ii;
if(FAILED(D3DX10GetImageInfoFromFile(lpFile, NULL, &ii, NULL)))
{
AppWarning(TEXT("D3D10Texture::CreateFromFile: Could not get information about texture file '%s'"), lpFile);
return NULL;
@ -235,23 +235,23 @@ Texture* D3D10Texture::CreateFromFile(CTSTR lpFile, BOOL bBuildMipMaps)
if(bBuildMipMaps && (!IsPow2(ii.Width) || !IsPow2(ii.Height)))
bBuildMipMaps = FALSE;
D3DX11_IMAGE_LOAD_INFO ili;
ili.Width = D3DX11_DEFAULT;
ili.Height = D3DX11_DEFAULT;
ili.Depth = D3DX11_DEFAULT;
ili.FirstMipLevel = D3DX11_DEFAULT;
D3DX10_IMAGE_LOAD_INFO ili;
ili.Width = D3DX10_DEFAULT;
ili.Height = D3DX10_DEFAULT;
ili.Depth = D3DX10_DEFAULT;
ili.FirstMipLevel = D3DX10_DEFAULT;
ili.MipLevels = bBuildMipMaps ? 0 : 1;
ili.Usage = (D3D11_USAGE)D3DX11_DEFAULT;
ili.BindFlags = D3DX11_DEFAULT;
ili.CpuAccessFlags = D3DX11_DEFAULT;
ili.MiscFlags = D3DX11_DEFAULT;
ili.Format = (DXGI_FORMAT)D3DX11_DEFAULT;
ili.Filter = D3DX11_DEFAULT;
ili.MipFilter = D3DX11_DEFAULT;
ili.Usage = (D3D10_USAGE)D3DX10_DEFAULT;
ili.BindFlags = D3DX10_DEFAULT;
ili.CpuAccessFlags = D3DX10_DEFAULT;
ili.MiscFlags = D3DX10_DEFAULT;
ili.Format = (DXGI_FORMAT)D3DX10_DEFAULT;
ili.Filter = D3DX10_DEFAULT;
ili.MipFilter = D3DX10_DEFAULT;
ili.pSrcInfo = NULL;
ID3D11Resource *texResource;
if(FAILED(err = D3DX11CreateTextureFromFile(GetD3D(), lpFile, &ili, NULL, &texResource, NULL)))
ID3D10Resource *texResource;
if(FAILED(err = D3DX10CreateTextureFromFile(GetD3D(), lpFile, &ili, NULL, &texResource, NULL)))
{
AppWarning(TEXT("D3D10Texture::CreateFromFile: failed to load '%s'"), lpFile);
return NULL;
@ -259,13 +259,13 @@ Texture* D3D10Texture::CreateFromFile(CTSTR lpFile, BOOL bBuildMipMaps)
//------------------------------------------
D3D11_SHADER_RESOURCE_VIEW_DESC resourceDesc;
D3D10_SHADER_RESOURCE_VIEW_DESC resourceDesc;
zero(&resourceDesc, sizeof(resourceDesc));
resourceDesc.Format = ii.Format;
resourceDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
resourceDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
resourceDesc.Texture2D.MipLevels = bBuildMipMaps ? -1 : 1;
ID3D11ShaderResourceView *resource;
ID3D10ShaderResourceView *resource;
if(FAILED(err = GetD3D()->CreateShaderResourceView(texResource, &resourceDesc, &resource)))
{
SafeRelease(texResource);
@ -275,8 +275,8 @@ Texture* D3D10Texture::CreateFromFile(CTSTR lpFile, BOOL bBuildMipMaps)
//------------------------------------------
ID3D11Texture2D *tex2D;
err = texResource->QueryInterface(__uuidof(ID3D11Texture2D), (void**)&tex2D);
ID3D10Texture2D *tex2D;
err = texResource->QueryInterface(__uuidof(ID3D10Texture2D), (void**)&tex2D);
if(FAILED(err))
{
SafeRelease(texResource);
@ -326,18 +326,18 @@ Texture* D3D10Texture::CreateRenderTarget(unsigned int width, unsigned int heigh
DXGI_FORMAT format = convertFormat[(UINT)colorFormat];
D3D11_TEXTURE2D_DESC td;
D3D10_TEXTURE2D_DESC td;
zero(&td, sizeof(td));
td.Width = width;
td.Height = height;
td.MipLevels = bGenMipMaps ? 0 : 1;
td.ArraySize = 1;
td.Format = format;
td.BindFlags = D3D11_BIND_SHADER_RESOURCE|D3D11_BIND_RENDER_TARGET;
td.BindFlags = D3D10_BIND_SHADER_RESOURCE|D3D10_BIND_RENDER_TARGET;
td.SampleDesc.Count = 1;
td.Usage = D3D11_USAGE_DEFAULT;
td.Usage = D3D10_USAGE_DEFAULT;
ID3D11Texture2D *texVal;
ID3D10Texture2D *texVal;
if(FAILED(err = GetD3D()->CreateTexture2D(&td, NULL, &texVal)))
{
AppWarning(TEXT("D3D10Texture::CreateRenderTarget: CreateTexture2D failed, result = 0x%08lX"), err);
@ -346,13 +346,13 @@ Texture* D3D10Texture::CreateRenderTarget(unsigned int width, unsigned int heigh
//------------------------------------------
D3D11_SHADER_RESOURCE_VIEW_DESC resourceDesc;
D3D10_SHADER_RESOURCE_VIEW_DESC resourceDesc;
zero(&resourceDesc, sizeof(resourceDesc));
resourceDesc.Format = format;
resourceDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
resourceDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
resourceDesc.Texture2D.MipLevels = bGenMipMaps ? -1 : 1;
ID3D11ShaderResourceView *resource;
ID3D10ShaderResourceView *resource;
if(FAILED(err = GetD3D()->CreateShaderResourceView(texVal, &resourceDesc, &resource)))
{
SafeRelease(texVal);
@ -362,7 +362,7 @@ Texture* D3D10Texture::CreateRenderTarget(unsigned int width, unsigned int heigh
//------------------------------------------
ID3D11RenderTargetView *view;
ID3D10RenderTargetView *view;
err = GetD3D()->CreateRenderTargetView(texVal, NULL, &view);
if(FAILED(err))
{
@ -389,22 +389,22 @@ Texture* D3D10Texture::CreateGDITexture(unsigned int width, unsigned int height)
{
HRESULT err;
D3D11_TEXTURE2D_DESC td;
D3D10_TEXTURE2D_DESC td;
zero(&td, sizeof(td));
td.Width = width;
td.Height = height;
td.MipLevels = 1;
td.ArraySize = 1;
td.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
td.BindFlags = D3D11_BIND_SHADER_RESOURCE|D3D11_BIND_RENDER_TARGET;
td.BindFlags = D3D10_BIND_SHADER_RESOURCE|D3D10_BIND_RENDER_TARGET;
td.SampleDesc.Count = 1;
td.Usage = D3D11_USAGE_DEFAULT;
td.MiscFlags = D3D11_RESOURCE_MISC_GDI_COMPATIBLE;
td.Usage = D3D10_USAGE_DEFAULT;
td.MiscFlags = D3D10_RESOURCE_MISC_GDI_COMPATIBLE;
D3D11_SUBRESOURCE_DATA srd;
D3D10_SUBRESOURCE_DATA srd;
zero(&srd, sizeof(srd));
ID3D11Texture2D *texVal;
ID3D10Texture2D *texVal;
if(FAILED(err = GetD3D()->CreateTexture2D(&td, NULL, &texVal)))
{
AppWarning(TEXT("D3D10Texture::CreateGDITexture: CreateTexture2D failed, result = 0x%08lX"), err);
@ -413,13 +413,13 @@ Texture* D3D10Texture::CreateGDITexture(unsigned int width, unsigned int height)
//------------------------------------------
D3D11_SHADER_RESOURCE_VIEW_DESC resourceDesc;
D3D10_SHADER_RESOURCE_VIEW_DESC resourceDesc;
zero(&resourceDesc, sizeof(resourceDesc));
resourceDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
resourceDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
resourceDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
resourceDesc.Texture2D.MipLevels = 1;
ID3D11ShaderResourceView *resource;
ID3D10ShaderResourceView *resource;
if(FAILED(err = GetD3D()->CreateShaderResourceView(texVal, &resourceDesc, &resource)))
{
SafeRelease(texVal);
@ -444,20 +444,20 @@ Texture* D3D10Texture::CreateShared(unsigned int width, unsigned int height)
{
HRESULT err;
D3D11_TEXTURE2D_DESC td;
D3D10_TEXTURE2D_DESC td;
zero(&td, sizeof(td));
td.Width = width;
td.Height = height;
td.MipLevels = 1;
td.ArraySize = 1;
td.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
td.BindFlags = D3D11_BIND_SHADER_RESOURCE|D3D11_BIND_RENDER_TARGET;
td.BindFlags = D3D10_BIND_SHADER_RESOURCE|D3D10_BIND_RENDER_TARGET;
td.SampleDesc.Count = 1;
td.Usage = D3D11_USAGE_DEFAULT;
td.Usage = D3D10_USAGE_DEFAULT;
td.CPUAccessFlags = 0;
td.MiscFlags = D3D11_RESOURCE_MISC_SHARED;
td.MiscFlags = D3D10_RESOURCE_MISC_SHARED;
ID3D11Texture2D *texVal;
ID3D10Texture2D *texVal;
if(FAILED(err = GetD3D()->CreateTexture2D(&td, NULL, &texVal)))
{
AppWarning(TEXT("D3D10Texture::CreateShared: CreateTexture2D failed, result = 0x%08lX"), err);
@ -466,13 +466,13 @@ Texture* D3D10Texture::CreateShared(unsigned int width, unsigned int height)
//------------------------------------------
D3D11_SHADER_RESOURCE_VIEW_DESC resourceDesc;
D3D10_SHADER_RESOURCE_VIEW_DESC resourceDesc;
zero(&resourceDesc, sizeof(resourceDesc));
resourceDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
resourceDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
resourceDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
resourceDesc.Texture2D.MipLevels = 1;
ID3D11ShaderResourceView *resource;
ID3D10ShaderResourceView *resource;
if(FAILED(err = GetD3D()->CreateShaderResourceView(texVal, &resourceDesc, &resource)))
{
SafeRelease(texVal);
@ -482,7 +482,7 @@ Texture* D3D10Texture::CreateShared(unsigned int width, unsigned int height)
//------------------------------------------
ID3D11RenderTargetView *view;
ID3D10RenderTargetView *view;
err = GetD3D()->CreateRenderTargetView(texVal, NULL, &view);
if(FAILED(err))
{
@ -651,8 +651,8 @@ void D3D10Texture::SetImage(void *lpData, GSImageFormat imageFormat, UINT pitch)
HRESULT err;
D3D11_MAPPED_SUBRESOURCE map;
if(FAILED(err = GetD3DCtx()->Map(texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &map)))
D3D10_MAPPED_TEXTURE2D map;
if(FAILED(err = texture->Map(0, D3D10_MAP_WRITE_DISCARD, 0, &map)))
{
AppWarning(TEXT("D3D10Texture::SetImage: map failed, result = %08lX"), err);
return;
@ -693,15 +693,15 @@ void D3D10Texture::SetImage(void *lpData, GSImageFormat imageFormat, UINT pitch)
}
}
GetD3DCtx()->Unmap(texture, 0);
texture->Unmap(0);
}
bool D3D10Texture::Map(BYTE *&lpData, UINT &pitch)
{
HRESULT err;
D3D11_MAPPED_SUBRESOURCE map;
D3D10_MAPPED_TEXTURE2D map;
if(FAILED(err = GetD3DCtx()->Map(texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &map)))
if(FAILED(err = texture->Map(0, D3D10_MAP_WRITE_DISCARD, 0, &map)))
{
AppWarning(TEXT("D3D10Texture::Map: map failed, result = %08lX"), err);
return false;
@ -715,7 +715,7 @@ bool D3D10Texture::Map(BYTE *&lpData, UINT &pitch)
void D3D10Texture::Unmap()
{
GetD3DCtx()->Unmap(texture, 0);
texture->Unmap(0);
}
HANDLE D3D10Texture::GetSharedHandle()

View File

@ -33,14 +33,14 @@ VertexBuffer* D3D10VertexBuffer::CreateVertexBuffer(VBData *vbData, BOOL bStatic
D3D10VertexBuffer *buf = new D3D10VertexBuffer;
buf->numVerts = vbData->VertList.Num();
D3D11_BUFFER_DESC bd;
D3D11_SUBRESOURCE_DATA srd;
D3D10_BUFFER_DESC bd;
D3D10_SUBRESOURCE_DATA srd;
zero(&bd, sizeof(bd));
zero(&srd, sizeof(srd));
bd.Usage = bStatic ? D3D11_USAGE_DEFAULT : D3D11_USAGE_DYNAMIC;
bd.CPUAccessFlags = bStatic ? 0 : D3D11_CPU_ACCESS_WRITE;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.Usage = bStatic ? D3D10_USAGE_DEFAULT : D3D10_USAGE_DYNAMIC;
bd.CPUAccessFlags = bStatic ? 0 : D3D10_CPU_ACCESS_WRITE;
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
//----------------------------------------
@ -119,7 +119,7 @@ VertexBuffer* D3D10VertexBuffer::CreateVertexBuffer(VBData *vbData, BOOL bStatic
bd.ByteWidth = buf->UVSizes[i]*buf->numVerts;
srd.pSysMem = textureVerts.Array();
ID3D11Buffer *tvBuffer;
ID3D10Buffer *tvBuffer;
err = GetD3D()->CreateBuffer(&bd, &srd, &tvBuffer);
if(FAILED(err))
{
@ -173,58 +173,57 @@ void D3D10VertexBuffer::FlushBuffers()
//---------------------------------------------------
D3D11_MAPPED_SUBRESOURCE map;
if(FAILED(err = GetD3DCtx()->Map(vertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map)))
BYTE *outData;
if(FAILED(err = vertexBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&outData)))
{
AppWarning(TEXT("D3D10VertexBuffer::FlushBuffers: failed to map vertex buffer, result = %08lX"), err);
return;
}
mcpy(map.pData, data->VertList.Array(), sizeof(Vect)*numVerts);
mcpy(outData, data->VertList.Array(), sizeof(Vect)*numVerts);
GetD3DCtx()->Unmap(vertexBuffer, 0);
vertexBuffer->Unmap();
//---------------------------------------------------
if(normalBuffer)
{
if(FAILED(err = GetD3DCtx()->Map(normalBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map)))
if(FAILED(err = normalBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&outData)))
{
AppWarning(TEXT("D3D10VertexBuffer::FlushBuffers: failed to map normal buffer, result = %08lX"), err);
return;
}
mcpy(map.pData, data->NormalList.Array(), sizeof(Vect)*numVerts);
GetD3DCtx()->Unmap(normalBuffer, 0);
mcpy(outData, data->NormalList.Array(), sizeof(Vect)*numVerts);
normalBuffer->Unmap();
}
//---------------------------------------------------
if(colorBuffer)
{
if(FAILED(err = GetD3DCtx()->Map(colorBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map)))
if(FAILED(err = colorBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&outData)))
{
AppWarning(TEXT("D3D10VertexBuffer::FlushBuffers: failed to map color buffer, result = %08lX"), err);
return;
}
mcpy(map.pData, data->ColorList.Array(), sizeof(Vect)*numVerts);
GetD3DCtx()->Unmap(colorBuffer, 0);
mcpy(outData, data->ColorList.Array(), sizeof(Vect)*numVerts);
colorBuffer->Unmap();
}
//---------------------------------------------------
if(tangentBuffer)
{
if(FAILED(err = GetD3DCtx()->Map(tangentBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map)))
if(FAILED(err = tangentBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&outData)))
{
AppWarning(TEXT("D3D10VertexBuffer::FlushBuffers: failed to map tangent buffer, result = %08lX"), err);
return;
}
mcpy(map.pData, data->TangentList.Array(), sizeof(Vect)*numVerts);
GetD3DCtx()->Unmap(tangentBuffer, 0);
mcpy(outData, data->TangentList.Array(), sizeof(Vect)*numVerts);
tangentBuffer->Unmap();
}
//---------------------------------------------------
@ -235,16 +234,16 @@ void D3D10VertexBuffer::FlushBuffers()
{
List<UVCoord> &textureVerts = data->UVList[i];
ID3D11Buffer *buffer = UVBuffers[i];
ID3D10Buffer *buffer = UVBuffers[i];
if(FAILED(err = GetD3DCtx()->Map(buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map)))
if(FAILED(err = buffer->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&outData)))
{
AppWarning(TEXT("D3D10VertexBuffer::FlushBuffers: failed to map texture vertex buffer %d, result = %08lX"), i, err);
return;
}
mcpy(map.pData, textureVerts.Array(), sizeof(UVCoord)*numVerts);
GetD3DCtx()->Unmap(buffer, 0);
mcpy(outData, textureVerts.Array(), sizeof(UVCoord)*numVerts);
buffer->Unmap();
}
}
}
@ -260,7 +259,7 @@ VBData* D3D10VertexBuffer::GetData()
return data;
}
void D3D10VertexBuffer::MakeBufferList(D3D10VertexShader *vShader, List<ID3D11Buffer*> &bufferList, List<UINT> &strides) const
void D3D10VertexBuffer::MakeBufferList(D3D10VertexShader *vShader, List<ID3D10Buffer*> &bufferList, List<UINT> &strides) const
{
assert(vShader);

View File

@ -39,10 +39,10 @@
#pragma warning(default : 4265)
//-------------------------------------------
// direct3d 11
// direct3d 10.1
#include <D3D11.h>
#include <D3DX11.h>
#include <D3D10_1.h>
#include <D3DX10.h>
#include <DXGI.h>
#define USE_DXGI1_2 1

View File

@ -2072,15 +2072,15 @@ void OBS::ActuallyEnableProjector()
if (!bShutdownEncodeThread)
SetWindowPos(hwndProjector, NULL, projectorX, projectorY, projectorWidth, projectorHeight, SWP_SHOWWINDOW);
ID3D11Texture2D *backBuffer = NULL;
ID3D11RenderTargetView *target = NULL;
ID3D10Texture2D *backBuffer = NULL;
ID3D10RenderTargetView *target = NULL;
if (FAILED(sys->factory->CreateSwapChain(sys->d3d, &swapDesc, &projectorSwap))) {
AppWarning(L"Could not create projector swap chain");
goto exit;
}
if (FAILED(projectorSwap->GetBuffer(0, IID_ID3D11Texture2D, (void**)&backBuffer))) {
if (FAILED(projectorSwap->GetBuffer(0, IID_ID3D10Texture2D, (void**)&backBuffer))) {
AppWarning(TEXT("Unable to get projector back buffer"));
goto exit;
}

View File

@ -636,7 +636,7 @@ class OBS
// graphics stuff
IDXGISwapChain *projectorSwap;
ID3D11Texture2D *copyTextures[NUM_RENDER_BUFFERS];
ID3D10Texture2D *copyTextures[NUM_RENDER_BUFFERS];
Texture *mainRenderTextures[NUM_RENDER_BUFFERS];
Texture *yuvRenderTextures[NUM_RENDER_BUFFERS];

View File

@ -617,7 +617,7 @@ retryHookTestV2:
//-------------------------------------------------------------
D3D11_TEXTURE2D_DESC td;
D3D10_TEXTURE2D_DESC td;
zero(&td, sizeof(td));
td.Width = outputCX;
td.Height = outputCY;
@ -626,8 +626,8 @@ retryHookTestV2:
td.ArraySize = 1;
td.SampleDesc.Count = 1;
td.ArraySize = 1;
td.Usage = D3D11_USAGE_STAGING;
td.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
td.Usage = D3D10_USAGE_STAGING;
td.CPUAccessFlags = D3D10_CPU_ACCESS_READ;
for(UINT i=0; i<NUM_RENDER_BUFFERS; i++)
{

View File

@ -923,7 +923,7 @@ void OBS::MainCaptureLoop()
{
D3D10Texture *d3dTransitionTex = static_cast<D3D10Texture*>(lastRenderTexture);
D3D10Texture *d3dSceneTex = static_cast<D3D10Texture*>(mainRenderTextures[lastRenderTarget]);
GetD3DCtx()->CopyResource(d3dTransitionTex->texture, d3dSceneTex->texture);
GetD3D()->CopyResource(d3dTransitionTex->texture, d3dSceneTex->texture);
}
else
bTransitioning = false;
@ -1121,28 +1121,28 @@ void OBS::MainCaptureLoop()
{
UINT prevCopyTexture = (curCopyTexture == 0) ? NUM_RENDER_BUFFERS-1 : curCopyTexture-1;
ID3D11Texture2D *copyTexture = copyTextures[curCopyTexture];
ID3D10Texture2D *copyTexture = copyTextures[curCopyTexture];
profileIn("CopyResource");
if(!bFirstEncode && bUseThreaded420)
{
WaitForMultipleObjects(completeEvents.Num(), completeEvents.Array(), TRUE, INFINITE);
GetD3DCtx()->Unmap(copyTexture, 0);
copyTexture->Unmap(0);
}
D3D10Texture *d3dYUV = static_cast<D3D10Texture*>(yuvRenderTextures[curYUVTexture]);
GetD3DCtx()->CopyResource(copyTexture, d3dYUV->texture);
GetD3D()->CopyResource(copyTexture, d3dYUV->texture);
profileOut;
ID3D11Texture2D *prevTexture = copyTextures[prevCopyTexture];
ID3D10Texture2D *prevTexture = copyTextures[prevCopyTexture];
if(bFirstImage) //ignore the first frame
bFirstImage = false;
else
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE map;
if(SUCCEEDED(result = GetD3DCtx()->Map(prevTexture, 0, D3D11_MAP_READ, 0, &map)))
D3D10_MAPPED_TEXTURE2D map;
if(SUCCEEDED(result = prevTexture->Map(0, D3D10_MAP_READ, 0, &map)))
{
int prevOutBuffer = (curOutBuffer == 0) ? NUM_OUT_BUFFERS-1 : curOutBuffer-1;
int nextOutBuffer = (curOutBuffer == NUM_OUT_BUFFERS-1) ? 0 : curOutBuffer+1;
@ -1192,7 +1192,7 @@ void OBS::MainCaptureLoop()
}
else
Convert444toNV12((LPBYTE)map.pData, outputCX, map.RowPitch, outputCX, outputCY, 0, outputCY, picOut.picOut->img.plane);
GetD3DCtx()->Unmap(prevTexture, 0);
prevTexture->Unmap(0);
}
profileOut;
@ -1322,7 +1322,7 @@ void OBS::MainCaptureLoop()
//------------------------------------
// we're about to sleep so we should flush the d3d command queue
profileIn("flush");
GetD3DCtx()->Flush();
GetD3D()->Flush();
profileOut;
profileOut;
profileOut; //frame
@ -1378,8 +1378,8 @@ void OBS::MainCaptureLoop()
if(!bFirstEncode)
{
ID3D11Texture2D *copyTexture = copyTextures[curCopyTexture];
GetD3DCtx()->Unmap(copyTexture, 0);
ID3D10Texture2D *copyTexture = copyTextures[curCopyTexture];
copyTexture->Unmap(0);
}
}