diff options
Diffstat (limited to 'src/angle/patches/0010-ANGLE-Enable-D3D11-for-feature-level-9-cards.patch')
-rw-r--r-- | src/angle/patches/0010-ANGLE-Enable-D3D11-for-feature-level-9-cards.patch | 859 |
1 files changed, 561 insertions, 298 deletions
diff --git a/src/angle/patches/0010-ANGLE-Enable-D3D11-for-feature-level-9-cards.patch b/src/angle/patches/0010-ANGLE-Enable-D3D11-for-feature-level-9-cards.patch index 34c881ba21..b17f07c00b 100644 --- a/src/angle/patches/0010-ANGLE-Enable-D3D11-for-feature-level-9-cards.patch +++ b/src/angle/patches/0010-ANGLE-Enable-D3D11-for-feature-level-9-cards.patch @@ -1,75 +1,224 @@ -From e84f947df4ae095eae600550749b3a4e8de5ee8b Mon Sep 17 00:00:00 2001 +From cda47c3e09db62c0af7d94537ec51aca5a728db9 Mon Sep 17 00:00:00 2001 From: Andrew Knight <andrew.knight@digia.com> -Date: Thu, 20 Feb 2014 16:51:36 +0200 -Subject: [PATCH] ANGLE: Enable D3D11 for feature level 9 cards +Date: Mon, 4 Aug 2014 23:51:59 +0300 +Subject: [PATCH 10/12] ANGLE: Enable D3D11 for feature level 9 cards Enable use of ANGLE on lower-end hardware, such as Surface RT and Windows Phone 8. -Based on https://codereview.appspot.com/12917046/ - Change-Id: Ice536802e4eedc1d264abd0dd65960638fce59e4 --- - .../angle/src/libGLESv2/renderer/d3d11/Image11.cpp | 7 +- - .../libGLESv2/renderer/d3d11/RenderStateCache.cpp | 5 +- - .../src/libGLESv2/renderer/d3d11/Renderer11.cpp | 90 ++++++++++++++++++++-- - .../src/libGLESv2/renderer/d3d11/Renderer11.h | 1 + - .../libGLESv2/renderer/d3d11/TextureStorage11.cpp | 10 +-- - .../libGLESv2/renderer/d3d11/renderer11_utils.cpp | 4 +- - .../libGLESv2/renderer/d3d11/renderer11_utils.h | 2 +- - 7 files changed, 100 insertions(+), 19 deletions(-) + src/3rdparty/angle/src/libGLESv2/angletypes.cpp | 4 +- + .../src/libGLESv2/renderer/d3d/d3d11/Blit11.cpp | 65 +++--- + .../src/libGLESv2/renderer/d3d/d3d11/Buffer11.cpp | 4 +- + .../src/libGLESv2/renderer/d3d/d3d11/Clear11.cpp | 8 +- + .../renderer/d3d/d3d11/PixelTransfer11.cpp | 7 +- + .../libGLESv2/renderer/d3d/d3d11/Renderer11.cpp | 246 ++++++++++++++------- + .../src/libGLESv2/renderer/d3d/d3d11/Renderer11.h | 1 + + .../renderer/d3d/d3d11/TextureStorage11.cpp | 2 +- + .../libGLESv2/renderer/d3d/d3d11/formatutils11.cpp | 4 +- + 9 files changed, 219 insertions(+), 122 deletions(-) -diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Image11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Image11.cpp -index 2b07b9d..5d039a3 100644 ---- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Image11.cpp -+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Image11.cpp -@@ -142,7 +142,7 @@ bool Image11::redefine(Renderer *renderer, GLint internalformat, GLsizei width, - mHeight = height; - mInternalFormat = internalformat; - // compute the d3d format that will be used -- mDXGIFormat = gl_d3d11::ConvertTextureFormat(internalformat); -+ mDXGIFormat = gl_d3d11::ConvertTextureFormat(internalformat, mRenderer->getFeatureLevel()); - mActualFormat = d3d11_gl::ConvertTextureInternalFormat(mDXGIFormat); - - if (mStagingTexture) -@@ -191,7 +191,10 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig - switch (mInternalFormat) +diff --git a/src/3rdparty/angle/src/libGLESv2/angletypes.cpp b/src/3rdparty/angle/src/libGLESv2/angletypes.cpp +index ec5521e..bc929c7 100644 +--- a/src/3rdparty/angle/src/libGLESv2/angletypes.cpp ++++ b/src/3rdparty/angle/src/libGLESv2/angletypes.cpp +@@ -23,8 +23,8 @@ SamplerState::SamplerState() + maxAnisotropy(1.0f), + baseLevel(0), + maxLevel(1000), +- minLod(-1000.0f), +- maxLod(1000.0f), ++ minLod(-FLT_MAX), ++ maxLod(FLT_MAX), + compareMode(GL_NONE), + compareFunc(GL_LEQUAL), + swizzleRed(GL_RED), +diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.cpp +index 79a6543..9b0f336 100644 +--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.cpp ++++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.cpp +@@ -210,7 +210,7 @@ Blit11::Blit11(rx::Renderer11 *renderer) + pointSamplerDesc.BorderColor[2] = 0.0f; + pointSamplerDesc.BorderColor[3] = 0.0f; + pointSamplerDesc.MinLOD = 0.0f; +- pointSamplerDesc.MaxLOD = 0.0f; ++ pointSamplerDesc.MaxLOD = mRenderer->isLevel9() ? FLT_MAX : 0.0f; + + result = device->CreateSamplerState(&pointSamplerDesc, &mPointSampler); + ASSERT(SUCCEEDED(result)); +@@ -229,7 +229,7 @@ Blit11::Blit11(rx::Renderer11 *renderer) + linearSamplerDesc.BorderColor[2] = 0.0f; + linearSamplerDesc.BorderColor[3] = 0.0f; + linearSamplerDesc.MinLOD = 0.0f; +- linearSamplerDesc.MaxLOD = 0.0f; ++ linearSamplerDesc.MaxLOD = mRenderer->isLevel9() ? FLT_MAX : 0.0f; + + result = device->CreateSamplerState(&linearSamplerDesc, &mLinearSampler); + ASSERT(SUCCEEDED(result)); +@@ -291,28 +291,32 @@ Blit11::Blit11(rx::Renderer11 *renderer) + ASSERT(SUCCEEDED(result)); + d3d11::SetDebugName(mQuad2DVS, "Blit11 2D vertex shader"); + +- result = device->CreatePixelShader(g_PS_PassthroughDepth2D, ArraySize(g_PS_PassthroughDepth2D), NULL, &mDepthPS); +- ASSERT(SUCCEEDED(result)); +- d3d11::SetDebugName(mDepthPS, "Blit11 2D depth pixel shader"); +- +- D3D11_INPUT_ELEMENT_DESC quad3DLayout[] = ++ if (!renderer->isLevel9()) { - case GL_ALPHA8_EXT: -- loadAlphaDataToNative(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); -+ if (mRenderer->getFeatureLevel() >= D3D_FEATURE_LEVEL_10_0) -+ loadAlphaDataToNative(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); -+ else -+ loadAlphaDataToBGRA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); +- { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +- { "LAYER", 0, DXGI_FORMAT_R32_UINT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +- { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +- }; ++ result = device->CreatePixelShader(g_PS_PassthroughDepth2D, ArraySize(g_PS_PassthroughDepth2D), NULL, &mDepthPS); ++ ASSERT(SUCCEEDED(result)); ++ d3d11::SetDebugName(mDepthPS, "Blit11 2D depth pixel shader"); + +- result = device->CreateInputLayout(quad3DLayout, ArraySize(quad3DLayout), g_VS_Passthrough3D, ArraySize(g_VS_Passthrough3D), &mQuad3DIL); +- ASSERT(SUCCEEDED(result)); +- d3d11::SetDebugName(mQuad3DIL, "Blit11 3D input layout"); ++ D3D11_INPUT_ELEMENT_DESC quad3DLayout[] = ++ { ++ { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, ++ { "LAYER", 0, DXGI_FORMAT_R32_UINT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 }, ++ { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, ++ }; + +- result = device->CreateVertexShader(g_VS_Passthrough3D, ArraySize(g_VS_Passthrough3D), NULL, &mQuad3DVS); +- ASSERT(SUCCEEDED(result)); +- d3d11::SetDebugName(mQuad3DVS, "Blit11 3D vertex shader"); ++ result = device->CreateInputLayout(quad3DLayout, ArraySize(quad3DLayout), g_VS_Passthrough3D, ArraySize(g_VS_Passthrough3D), &mQuad3DIL); ++ ASSERT(SUCCEEDED(result)); ++ d3d11::SetDebugName(mQuad3DIL, "Blit11 3D input layout"); + +- result = device->CreateGeometryShader(g_GS_Passthrough3D, ArraySize(g_GS_Passthrough3D), NULL, &mQuad3DGS); +- ASSERT(SUCCEEDED(result)); +- d3d11::SetDebugName(mQuad3DGS, "Renderer11 copy 3D texture geometry shader"); ++ result = device->CreateVertexShader(g_VS_Passthrough3D, ArraySize(g_VS_Passthrough3D), NULL, &mQuad3DVS); ++ ASSERT(SUCCEEDED(result)); ++ d3d11::SetDebugName(mQuad3DVS, "Blit11 3D vertex shader"); ++ ++ result = device->CreateGeometryShader(g_GS_Passthrough3D, ArraySize(g_GS_Passthrough3D), NULL, &mQuad3DGS); ++ ASSERT(SUCCEEDED(result)); ++ d3d11::SetDebugName(mQuad3DGS, "Renderer11 copy 3D texture geometry shader"); ++ ++ } + + buildShaderMap(); + +@@ -970,21 +974,27 @@ void Blit11::buildShaderMap() + ID3D11Device *device = mRenderer->getDevice(); + + add2DBlitShaderToMap(GL_RGBA, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2D, "Blit11 2D RGBA pixel shader" )); +- add2DBlitShaderToMap(GL_RGBA_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2DUI, "Blit11 2D RGBA UI pixel shader" )); +- add2DBlitShaderToMap(GL_RGBA_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughRGBA2DI, "Blit11 2D RGBA I pixel shader" )); + add2DBlitShaderToMap(GL_BGRA_EXT, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2D, "Blit11 2D BGRA pixel shader" )); + add2DBlitShaderToMap(GL_RGB, false, d3d11::CompilePS(device, g_PS_PassthroughRGB2D, "Blit11 2D RGB pixel shader" )); ++ add2DBlitShaderToMap(GL_RG, false, d3d11::CompilePS(device, g_PS_PassthroughRG2D, "Blit11 2D RG pixel shader" )); ++ add2DBlitShaderToMap(GL_RED, false, d3d11::CompilePS(device, g_PS_PassthroughR2D, "Blit11 2D R pixel shader" )); ++ add2DBlitShaderToMap(GL_ALPHA, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2D, "Blit11 2D alpha pixel shader" )); ++ add2DBlitShaderToMap(GL_LUMINANCE, false, d3d11::CompilePS(device, g_PS_PassthroughLum2D, "Blit11 2D lum pixel shader" )); ++ add2DBlitShaderToMap(GL_LUMINANCE_ALPHA, false, d3d11::CompilePS(device, g_PS_PassthroughLumAlpha2D, "Blit11 2D luminance alpha pixel shader")); ++ ++ addSwizzleShaderToMap(GL_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, d3d11::CompilePS(device, g_PS_SwizzleF2D, "Blit11 2D F swizzle pixel shader" )); ++ ++ if (mRenderer->isLevel9()) ++ return; ++ ++ add2DBlitShaderToMap(GL_RGBA_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2DUI, "Blit11 2D RGBA UI pixel shader" )); ++ add2DBlitShaderToMap(GL_RGBA_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughRGBA2DI, "Blit11 2D RGBA I pixel shader" )); + add2DBlitShaderToMap(GL_RGB_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughRGB2DUI, "Blit11 2D RGB UI pixel shader" )); + add2DBlitShaderToMap(GL_RGB_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughRGB2DI, "Blit11 2D RGB I pixel shader" )); +- add2DBlitShaderToMap(GL_RG, false, d3d11::CompilePS(device, g_PS_PassthroughRG2D, "Blit11 2D RG pixel shader" )); + add2DBlitShaderToMap(GL_RG_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughRG2DUI, "Blit11 2D RG UI pixel shader" )); + add2DBlitShaderToMap(GL_RG_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughRG2DI, "Blit11 2D RG I pixel shader" )); +- add2DBlitShaderToMap(GL_RED, false, d3d11::CompilePS(device, g_PS_PassthroughR2D, "Blit11 2D R pixel shader" )); + add2DBlitShaderToMap(GL_RED_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughR2DUI, "Blit11 2D R UI pixel shader" )); + add2DBlitShaderToMap(GL_RED_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughR2DI, "Blit11 2D R I pixel shader" )); +- add2DBlitShaderToMap(GL_ALPHA, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2D, "Blit11 2D alpha pixel shader" )); +- add2DBlitShaderToMap(GL_LUMINANCE, false, d3d11::CompilePS(device, g_PS_PassthroughLum2D, "Blit11 2D lum pixel shader" )); +- add2DBlitShaderToMap(GL_LUMINANCE_ALPHA, false, d3d11::CompilePS(device, g_PS_PassthroughLumAlpha2D, "Blit11 2D luminance alpha pixel shader")); + + add3DBlitShaderToMap(GL_RGBA, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA3D, "Blit11 3D RGBA pixel shader" )); + add3DBlitShaderToMap(GL_RGBA_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA3DUI, "Blit11 3D UI RGBA pixel shader" )); +@@ -1003,7 +1013,6 @@ void Blit11::buildShaderMap() + add3DBlitShaderToMap(GL_LUMINANCE, false, d3d11::CompilePS(device, g_PS_PassthroughLum3D, "Blit11 3D luminance pixel shader" )); + add3DBlitShaderToMap(GL_LUMINANCE_ALPHA, false, d3d11::CompilePS(device, g_PS_PassthroughLumAlpha3D, "Blit11 3D luminance alpha pixel shader")); + +- addSwizzleShaderToMap(GL_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, d3d11::CompilePS(device, g_PS_SwizzleF2D, "Blit11 2D F swizzle pixel shader" )); + addSwizzleShaderToMap(GL_UNSIGNED_INT, D3D_SRV_DIMENSION_TEXTURE2D, d3d11::CompilePS(device, g_PS_SwizzleUI2D, "Blit11 2D UI swizzle pixel shader")); + addSwizzleShaderToMap(GL_INT, D3D_SRV_DIMENSION_TEXTURE2D, d3d11::CompilePS(device, g_PS_SwizzleI2D, "Blit11 2D I swizzle pixel shader" )); + +diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.cpp +index b677fb5..352da96 100644 +--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.cpp ++++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.cpp +@@ -711,7 +711,9 @@ void Buffer11::NativeBuffer11::fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Ren + + case BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK: + bufferDesc->Usage = D3D11_USAGE_DEFAULT; +- bufferDesc->BindFlags = D3D11_BIND_VERTEX_BUFFER | D3D11_BIND_STREAM_OUTPUT; ++ bufferDesc->BindFlags = D3D11_BIND_VERTEX_BUFFER; ++ if (renderer->getMaxTransformFeedbackBuffers() > 0) ++ bufferDesc->BindFlags |= D3D11_BIND_STREAM_OUTPUT; + bufferDesc->CPUAccessFlags = 0; break; - case GL_LUMINANCE8_EXT: - loadLuminanceDataToNativeOrBGRA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData, false); -diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp -index 0047e04..a1c324c 100644 ---- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp -+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp -@@ -419,7 +419,8 @@ ID3D11SamplerState *RenderStateCache::getSamplerState(const gl::SamplerState &sa - samplerDesc.BorderColor[2] = 0.0f; - samplerDesc.BorderColor[3] = 0.0f; - samplerDesc.MinLOD = gl_d3d11::ConvertMinLOD(samplerState.minFilter, samplerState.lodOffset); -- samplerDesc.MaxLOD = gl_d3d11::ConvertMaxLOD(samplerState.minFilter, samplerState.lodOffset); -+ samplerDesc.MaxLOD = mDevice->GetFeatureLevel() >= D3D_FEATURE_LEVEL_10_0 -+ ? gl_d3d11::ConvertMaxLOD(samplerState.minFilter, samplerState.lodOffset) : FLT_MAX; - - ID3D11SamplerState *dx11SamplerState = NULL; - HRESULT result = mDevice->CreateSamplerState(&samplerDesc, &dx11SamplerState); -@@ -435,4 +436,4 @@ ID3D11SamplerState *RenderStateCache::getSamplerState(const gl::SamplerState &sa - } + +diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.cpp +index 9cd0b7d..8db5ea2 100644 +--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.cpp ++++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.cpp +@@ -105,7 +105,7 @@ Clear11::Clear11(Renderer11 *renderer) + rsDesc.DepthBias = 0; + rsDesc.DepthBiasClamp = 0.0f; + rsDesc.SlopeScaledDepthBias = 0.0f; +- rsDesc.DepthClipEnable = FALSE; ++ rsDesc.DepthClipEnable = mRenderer->isLevel9(); + rsDesc.ScissorEnable = FALSE; + rsDesc.MultisampleEnable = FALSE; + rsDesc.AntialiasedLineEnable = FALSE; +@@ -115,6 +115,12 @@ Clear11::Clear11(Renderer11 *renderer) + d3d11::SetDebugName(mRasterizerState, "Clear11 masked clear rasterizer state"); + + mFloatClearShader = CreateClearShader(device, DXGI_FORMAT_R32G32B32A32_FLOAT, g_VS_ClearFloat, g_PS_ClearFloat); ++ if (mRenderer->isLevel9()) { ++ mUintClearShader = { 0 }; ++ mIntClearShader = { 0 }; ++ return; ++ } ++ + mUintClearShader = CreateClearShader(device, DXGI_FORMAT_R32G32B32A32_UINT, g_VS_ClearUint, g_PS_ClearUint ); + mIntClearShader = CreateClearShader(device, DXGI_FORMAT_R32G32B32A32_SINT, g_VS_ClearSint, g_PS_ClearSint ); } +diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp +index 67540bb..0704034 100644 +--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp ++++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp +@@ -89,13 +89,16 @@ PixelTransfer11::PixelTransfer11(Renderer11 *renderer) + ASSERT(SUCCEEDED(result)); + d3d11::SetDebugName(mParamsConstantBuffer, "PixelTransfer11 constant buffer"); --} -\ No newline at end of file -+} -diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.cpp -index 7f166fd..31d976d 100644 ---- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.cpp -+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.cpp -@@ -164,6 +164,11 @@ EGLint Renderer11::initialize() ++ StructZero(&mParamsData); ++ + // init shaders ++ if (mRenderer->isLevel9()) ++ return; ++ + mBufferToTextureVS = d3d11::CompileVS(device, g_VS_BufferToTexture, "BufferToTexture VS"); + mBufferToTextureGS = d3d11::CompileGS(device, g_GS_BufferToTexture, "BufferToTexture GS"); + + buildShaderMap(); +- +- StructZero(&mParamsData); + } + + PixelTransfer11::~PixelTransfer11() +diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp +index 36d9a8f..17a13f9 100644 +--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp ++++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp +@@ -156,6 +156,11 @@ EGLint Renderer11::initialize() D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0, @@ -80,8 +229,258 @@ index 7f166fd..31d976d 100644 +#endif }; - HRESULT result = S_OK; -@@ -1533,7 +1538,7 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra + D3D_DRIVER_TYPE driverType = D3D_DRIVER_TYPE_HARDWARE; +@@ -1114,6 +1119,84 @@ void Renderer11::drawElements(GLenum mode, GLsizei count, GLenum type, const GLv + } + } + ++template<typename T> ++static void fillLineLoopIndices(GLenum type, GLsizei count, const GLvoid *indices, T *data) ++{ ++ switch (type) ++ { ++ case GL_NONE: // Non-indexed draw ++ for (int i = 0; i < count; i++) ++ { ++ data[i] = i; ++ } ++ data[count] = 0; ++ break; ++ case GL_UNSIGNED_BYTE: ++ for (int i = 0; i < count; i++) ++ { ++ data[i] = static_cast<const GLubyte*>(indices)[i]; ++ } ++ data[count] = static_cast<const GLubyte*>(indices)[0]; ++ break; ++ case GL_UNSIGNED_SHORT: ++ for (int i = 0; i < count; i++) ++ { ++ data[i] = static_cast<const GLushort*>(indices)[i]; ++ } ++ data[count] = static_cast<const GLushort*>(indices)[0]; ++ break; ++ case GL_UNSIGNED_INT: ++ for (int i = 0; i < count; i++) ++ { ++ data[i] = static_cast<const GLuint*>(indices)[i]; ++ } ++ data[count] = static_cast<const GLuint*>(indices)[0]; ++ break; ++ default: UNREACHABLE(); ++ } ++} ++ ++template<typename T> ++static void fillTriangleFanIndices(GLenum type, unsigned int numTris, const GLvoid *indices, T *data) ++{ ++ switch (type) ++ { ++ case GL_NONE: // Non-indexed draw ++ for (unsigned int i = 0; i < numTris; i++) ++ { ++ data[i*3 + 0] = 0; ++ data[i*3 + 1] = i + 1; ++ data[i*3 + 2] = i + 2; ++ } ++ break; ++ case GL_UNSIGNED_BYTE: ++ for (unsigned int i = 0; i < numTris; i++) ++ { ++ data[i*3 + 0] = static_cast<const GLubyte*>(indices)[0]; ++ data[i*3 + 1] = static_cast<const GLubyte*>(indices)[i + 1]; ++ data[i*3 + 2] = static_cast<const GLubyte*>(indices)[i + 2]; ++ } ++ break; ++ case GL_UNSIGNED_SHORT: ++ for (unsigned int i = 0; i < numTris; i++) ++ { ++ data[i*3 + 0] = static_cast<const GLushort*>(indices)[0]; ++ data[i*3 + 1] = static_cast<const GLushort*>(indices)[i + 1]; ++ data[i*3 + 2] = static_cast<const GLushort*>(indices)[i + 2]; ++ } ++ break; ++ case GL_UNSIGNED_INT: ++ for (unsigned int i = 0; i < numTris; i++) ++ { ++ data[i*3 + 0] = static_cast<const GLuint*>(indices)[0]; ++ data[i*3 + 1] = static_cast<const GLuint*>(indices)[i + 1]; ++ data[i*3 + 2] = static_cast<const GLuint*>(indices)[i + 2]; ++ } ++ break; ++ default: UNREACHABLE(); ++ } ++} ++ + void Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer) + { + // Get the raw indices for an indexed draw +@@ -1125,10 +1208,13 @@ void Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, + indices = static_cast<const GLubyte*>(storage->getData()) + offset; + } + ++ // TODO: some level 9 hardware supports 32-bit indices; test and store support instead ++ const int indexType = isLevel9() ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT; ++ + if (!mLineLoopIB) + { + mLineLoopIB = new StreamingIndexBufferInterface(this); +- if (!mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT)) ++ if (!mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, indexType)) + { + delete mLineLoopIB; + mLineLoopIB = NULL; +@@ -1141,14 +1227,15 @@ void Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, + // Checked by Renderer11::applyPrimitiveType + ASSERT(count >= 0); + +- if (static_cast<unsigned int>(count) + 1 > (std::numeric_limits<unsigned int>::max() / sizeof(unsigned int))) ++ int indexTypeSize = indexType == GL_UNSIGNED_SHORT ? sizeof(unsigned short) : sizeof(unsigned int); ++ if (static_cast<unsigned int>(count) + 1 > (std::numeric_limits<unsigned int>::max() / indexTypeSize)) + { + ERR("Could not create a 32-bit looping index buffer for GL_LINE_LOOP, too many indices required."); + return gl::error(GL_OUT_OF_MEMORY); + } + +- const unsigned int spaceNeeded = (static_cast<unsigned int>(count) + 1) * sizeof(unsigned int); +- if (!mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT)) ++ const unsigned int spaceNeeded = (static_cast<unsigned int>(count) + 1) * indexTypeSize; ++ if (!mLineLoopIB->reserveBufferSpace(spaceNeeded, indexType)) + { + ERR("Could not reserve enough space in looping index buffer for GL_LINE_LOOP."); + return gl::error(GL_OUT_OF_MEMORY); +@@ -1162,42 +1249,12 @@ void Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, + return gl::error(GL_OUT_OF_MEMORY); + } + +- unsigned int *data = reinterpret_cast<unsigned int*>(mappedMemory); ++ if (indexType == GL_UNSIGNED_SHORT) ++ fillLineLoopIndices(type, count, indices, reinterpret_cast<unsigned short*>(mappedMemory)); ++ else ++ fillLineLoopIndices(type, count, indices, reinterpret_cast<unsigned int*>(mappedMemory)); + unsigned int indexBufferOffset = offset; + +- switch (type) +- { +- case GL_NONE: // Non-indexed draw +- for (int i = 0; i < count; i++) +- { +- data[i] = i; +- } +- data[count] = 0; +- break; +- case GL_UNSIGNED_BYTE: +- for (int i = 0; i < count; i++) +- { +- data[i] = static_cast<const GLubyte*>(indices)[i]; +- } +- data[count] = static_cast<const GLubyte*>(indices)[0]; +- break; +- case GL_UNSIGNED_SHORT: +- for (int i = 0; i < count; i++) +- { +- data[i] = static_cast<const GLushort*>(indices)[i]; +- } +- data[count] = static_cast<const GLushort*>(indices)[0]; +- break; +- case GL_UNSIGNED_INT: +- for (int i = 0; i < count; i++) +- { +- data[i] = static_cast<const GLuint*>(indices)[i]; +- } +- data[count] = static_cast<const GLuint*>(indices)[0]; +- break; +- default: UNREACHABLE(); +- } +- + if (!mLineLoopIB->unmapBuffer()) + { + ERR("Could not unmap index buffer for GL_LINE_LOOP."); +@@ -1230,10 +1287,12 @@ void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indic + indices = static_cast<const GLubyte*>(storage->getData()) + offset; + } + ++ const int indexType = isLevel9() ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT; ++ + if (!mTriangleFanIB) + { + mTriangleFanIB = new StreamingIndexBufferInterface(this); +- if (!mTriangleFanIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT)) ++ if (!mTriangleFanIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, indexType)) + { + delete mTriangleFanIB; + mTriangleFanIB = NULL; +@@ -1248,14 +1307,15 @@ void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indic + + const unsigned int numTris = count - 2; + +- if (numTris > (std::numeric_limits<unsigned int>::max() / (sizeof(unsigned int) * 3))) ++ int indexTypeSize = indexType == GL_UNSIGNED_SHORT ? sizeof(unsigned short) : sizeof(unsigned int); ++ if (numTris > (std::numeric_limits<unsigned int>::max() / (indexTypeSize * 3))) + { + ERR("Could not create a scratch index buffer for GL_TRIANGLE_FAN, too many indices required."); + return gl::error(GL_OUT_OF_MEMORY); + } + +- const unsigned int spaceNeeded = (numTris * 3) * sizeof(unsigned int); +- if (!mTriangleFanIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT)) ++ const unsigned int spaceNeeded = (numTris * 3) * indexTypeSize; ++ if (!mTriangleFanIB->reserveBufferSpace(spaceNeeded, indexType)) + { + ERR("Could not reserve enough space in scratch index buffer for GL_TRIANGLE_FAN."); + return gl::error(GL_OUT_OF_MEMORY); +@@ -1269,46 +1329,12 @@ void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indic + return gl::error(GL_OUT_OF_MEMORY); + } + +- unsigned int *data = reinterpret_cast<unsigned int*>(mappedMemory); ++ if (indexType == GL_UNSIGNED_SHORT) ++ fillTriangleFanIndices(type, numTris, indices, reinterpret_cast<unsigned short*>(mappedMemory)); ++ else ++ fillTriangleFanIndices(type, numTris, indices, reinterpret_cast<unsigned int*>(mappedMemory)); + unsigned int indexBufferOffset = offset; + +- switch (type) +- { +- case GL_NONE: // Non-indexed draw +- for (unsigned int i = 0; i < numTris; i++) +- { +- data[i*3 + 0] = 0; +- data[i*3 + 1] = i + 1; +- data[i*3 + 2] = i + 2; +- } +- break; +- case GL_UNSIGNED_BYTE: +- for (unsigned int i = 0; i < numTris; i++) +- { +- data[i*3 + 0] = static_cast<const GLubyte*>(indices)[0]; +- data[i*3 + 1] = static_cast<const GLubyte*>(indices)[i + 1]; +- data[i*3 + 2] = static_cast<const GLubyte*>(indices)[i + 2]; +- } +- break; +- case GL_UNSIGNED_SHORT: +- for (unsigned int i = 0; i < numTris; i++) +- { +- data[i*3 + 0] = static_cast<const GLushort*>(indices)[0]; +- data[i*3 + 1] = static_cast<const GLushort*>(indices)[i + 1]; +- data[i*3 + 2] = static_cast<const GLushort*>(indices)[i + 2]; +- } +- break; +- case GL_UNSIGNED_INT: +- for (unsigned int i = 0; i < numTris; i++) +- { +- data[i*3 + 0] = static_cast<const GLuint*>(indices)[0]; +- data[i*3 + 1] = static_cast<const GLuint*>(indices)[i + 1]; +- data[i*3 + 2] = static_cast<const GLuint*>(indices)[i + 2]; +- } +- break; +- default: UNREACHABLE(); +- } +- + if (!mTriangleFanIB->unmapBuffer()) + { + ERR("Could not unmap scratch index buffer for GL_TRIANGLE_FAN."); +@@ -1550,7 +1576,7 @@ void Renderer11::applyUniforms(const gl::ProgramBinary &programBinary) } // needed for the point sprite geometry shader @@ -90,7 +489,7 @@ index 7f166fd..31d976d 100644 { mDeviceContext->GSSetConstantBuffers(0, 1, &mDriverConstantBufferPS); mCurrentGeometryConstantBuffer = mDriverConstantBufferPS; -@@ -1956,6 +1961,11 @@ bool Renderer11::testDeviceResettable() +@@ -1700,6 +1726,11 @@ bool Renderer11::testDeviceResettable() D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0, @@ -102,31 +501,7 @@ index 7f166fd..31d976d 100644 }; ID3D11Device* dummyDevice; -@@ -2139,6 +2149,11 @@ float Renderer11::getTextureMaxAnisotropy() const - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_MAX_MAXANISOTROPY; -+ case D3D_FEATURE_LEVEL_9_3: -+ case D3D_FEATURE_LEVEL_9_2: -+ return 16; -+ case D3D_FEATURE_LEVEL_9_1: -+ return D3D_FL9_1_DEFAULT_MAX_ANISOTROPY; - default: UNREACHABLE(); - return 0; - } -@@ -2158,6 +2173,11 @@ Range Renderer11::getViewportBounds() const - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return Range(D3D10_VIEWPORT_BOUNDS_MIN, D3D10_VIEWPORT_BOUNDS_MAX); -+ case D3D_FEATURE_LEVEL_9_3: -+ return Range(D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION * -2, D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION * 2); -+ case D3D_FEATURE_LEVEL_9_2: -+ case D3D_FEATURE_LEVEL_9_1: -+ return Range(D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION * -2, D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION * 2); - default: UNREACHABLE(); - return Range(0, 0); - } -@@ -2172,6 +2192,10 @@ unsigned int Renderer11::getMaxVertexTextureImageUnits() const +@@ -1817,6 +1848,10 @@ unsigned int Renderer11::getMaxVertexTextureImageUnits() const case D3D_FEATURE_LEVEL_10_1: case D3D_FEATURE_LEVEL_10_0: return MAX_TEXTURE_IMAGE_UNITS_VTF_SM4; @@ -137,7 +512,7 @@ index 7f166fd..31d976d 100644 default: UNREACHABLE(); return 0; } -@@ -2195,14 +2219,14 @@ unsigned int Renderer11::getReservedFragmentUniformVectors() const +@@ -1840,14 +1875,14 @@ unsigned int Renderer11::getReservedFragmentUniformVectors() const unsigned int Renderer11::getMaxVertexUniformVectors() const { META_ASSERT(MAX_VERTEX_UNIFORM_VECTORS_D3D11 <= D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT); @@ -154,273 +529,161 @@ index 7f166fd..31d976d 100644 return MAX_FRAGMENT_UNIFORM_VECTORS_D3D11; } -@@ -2216,6 +2240,10 @@ unsigned int Renderer11::getMaxVaryingVectors() const - case D3D_FEATURE_LEVEL_10_1: +@@ -1864,6 +1899,11 @@ unsigned int Renderer11::getMaxVaryingVectors() const + return D3D10_1_VS_OUTPUT_REGISTER_COUNT - getReservedVaryings(); case D3D_FEATURE_LEVEL_10_0: - return D3D10_VS_OUTPUT_REGISTER_COUNT; + return D3D10_VS_OUTPUT_REGISTER_COUNT - getReservedVaryings(); + case D3D_FEATURE_LEVEL_9_3: ++ return 10 - getReservedVaryings(); + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: -+ return 8; ++ return 8 - getReservedVaryings(); default: UNREACHABLE(); return 0; } -@@ -2229,6 +2257,10 @@ bool Renderer11::getNonPower2TextureSupport() const +@@ -1881,6 +1921,10 @@ unsigned int Renderer11::getMaxVertexShaderUniformBuffers() const case D3D_FEATURE_LEVEL_10_1: case D3D_FEATURE_LEVEL_10_0: - return true; + return D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - getReservedVertexUniformBuffers(); + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: -+ return false; ++ return 0; default: UNREACHABLE(); - return false; + return 0; } -@@ -2242,6 +2274,11 @@ bool Renderer11::getOcclusionQuerySupport() const +@@ -1898,6 +1942,10 @@ unsigned int Renderer11::getMaxFragmentShaderUniformBuffers() const case D3D_FEATURE_LEVEL_10_1: case D3D_FEATURE_LEVEL_10_0: - return true; + return D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - getReservedFragmentUniformBuffers(); + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: -+ return true; + case D3D_FEATURE_LEVEL_9_1: -+ return false; ++ return 0; default: UNREACHABLE(); - return false; + return 0; } -@@ -2254,7 +2291,11 @@ bool Renderer11::getInstancingSupport() const - case D3D_FEATURE_LEVEL_11_0: - case D3D_FEATURE_LEVEL_10_1: +@@ -1935,6 +1983,10 @@ unsigned int Renderer11::getMaxTransformFeedbackBuffers() const + return D3D10_1_SO_BUFFER_SLOT_COUNT; case D3D_FEATURE_LEVEL_10_0: -- return true; + return D3D10_SO_BUFFER_SLOT_COUNT; + case D3D_FEATURE_LEVEL_9_3: -+ return true; + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: -+ return false; ++ return 0; default: UNREACHABLE(); - return false; + return 0; + } +@@ -1951,6 +2003,10 @@ unsigned int Renderer11::getMaxTransformFeedbackSeparateComponents() const + // D3D 10 and 10.1 only allow one output per output slot if an output slot other than zero + // is used. + return 4; ++ case D3D_FEATURE_LEVEL_9_3: ++ case D3D_FEATURE_LEVEL_9_2: ++ case D3D_FEATURE_LEVEL_9_1: ++ return 0; + default: UNREACHABLE(); + return 0; } -@@ -2276,6 +2317,11 @@ bool Renderer11::getDerivativeInstructionSupport() const +@@ -1973,6 +2029,10 @@ unsigned int Renderer11::getMaxUniformBufferSize() const case D3D_FEATURE_LEVEL_10_1: case D3D_FEATURE_LEVEL_10_0: - return true; + return D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * bytesPerComponent; + case D3D_FEATURE_LEVEL_9_3: -+ return true; + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: -+ return false; ++ return 0; default: UNREACHABLE(); - return false; + return 0; } -@@ -2294,6 +2340,9 @@ int Renderer11::getMajorShaderModel() const +@@ -2021,7 +2081,11 @@ int Renderer11::getMajorShaderModel() const + { case D3D_FEATURE_LEVEL_11_0: return D3D11_SHADER_MAJOR_VERSION; // 5 case D3D_FEATURE_LEVEL_10_1: return D3D10_1_SHADER_MAJOR_VERSION; // 4 - case D3D_FEATURE_LEVEL_10_0: return D3D10_SHADER_MAJOR_VERSION; // 4 +- case D3D_FEATURE_LEVEL_10_0: return D3D10_SHADER_MAJOR_VERSION; // 4 ++ case D3D_FEATURE_LEVEL_10_0: + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: -+ case D3D_FEATURE_LEVEL_9_1: return D3D10_SHADER_MAJOR_VERSION; // 4 (level 9) ++ case D3D_FEATURE_LEVEL_9_1: ++ return D3D10_SHADER_MAJOR_VERSION; // 4 default: UNREACHABLE(); return 0; } } -@@ -2305,6 +2354,9 @@ int Renderer11::getMinorShaderModel() const +@@ -2032,7 +2096,10 @@ int Renderer11::getMinorShaderModel() const + { case D3D_FEATURE_LEVEL_11_0: return D3D11_SHADER_MINOR_VERSION; // 0 case D3D_FEATURE_LEVEL_10_1: return D3D10_1_SHADER_MINOR_VERSION; // 1 - case D3D_FEATURE_LEVEL_10_0: return D3D10_SHADER_MINOR_VERSION; // 0 +- case D3D_FEATURE_LEVEL_10_0: return D3D10_SHADER_MINOR_VERSION; // 0 ++ case D3D_FEATURE_LEVEL_10_0: + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: -+ case D3D_FEATURE_LEVEL_9_1: return D3D10_SHADER_MINOR_VERSION; // 0 (level 9) ++ case D3D_FEATURE_LEVEL_9_1: return D3D10_SHADER_MINOR_VERSION; // 0 default: UNREACHABLE(); return 0; } } -@@ -2330,6 +2382,11 @@ int Renderer11::getMaxViewportDimension() const - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 8192 +@@ -2615,6 +2682,15 @@ ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &infoLog, const ch + case D3D_FEATURE_LEVEL_10_0: + profileVersion = "4_0"; + break; + case D3D_FEATURE_LEVEL_9_3: -+ return D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 4096 ++ profileVersion = "4_0_level_9_3"; ++ break; + case D3D_FEATURE_LEVEL_9_2: ++ profileVersion = "4_0_level_9_2"; ++ break; + case D3D_FEATURE_LEVEL_9_1: -+ return D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 2048 - default: UNREACHABLE(); - return 0; - } -@@ -2342,6 +2399,9 @@ int Renderer11::getMaxTextureWidth() const - case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 16384 - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 8192 -+ case D3D_FEATURE_LEVEL_9_3: return D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 4096 -+ case D3D_FEATURE_LEVEL_9_2: -+ case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 2048 - default: UNREACHABLE(); return 0; - } - } -@@ -2353,6 +2413,9 @@ int Renderer11::getMaxTextureHeight() const - case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 16384 - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 8192 -+ case D3D_FEATURE_LEVEL_9_3: return D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 4096 -+ case D3D_FEATURE_LEVEL_9_2: -+ case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 2048 - default: UNREACHABLE(); return 0; - } - } -@@ -2364,6 +2427,9 @@ bool Renderer11::get32BitIndexSupport() const - case D3D_FEATURE_LEVEL_11_0: - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP >= 32; // true -+ case D3D_FEATURE_LEVEL_9_3: -+ case D3D_FEATURE_LEVEL_9_2: -+ case D3D_FEATURE_LEVEL_9_1: return false; - default: UNREACHABLE(); return false; - } - } -@@ -2410,6 +2476,8 @@ unsigned int Renderer11::getMaxRenderTargets() const - { - META_ASSERT(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT <= gl::IMPLEMENTATION_MAX_DRAW_BUFFERS); - META_ASSERT(D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT <= gl::IMPLEMENTATION_MAX_DRAW_BUFFERS); -+ META_ASSERT(D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT <= gl::IMPLEMENTATION_MAX_DRAW_BUFFERS); -+ META_ASSERT(D3D_FL9_1_SIMULTANEOUS_RENDER_TARGET_COUNT <= gl::IMPLEMENTATION_MAX_DRAW_BUFFERS); - - switch (mFeatureLevel) - { -@@ -2417,6 +2485,9 @@ unsigned int Renderer11::getMaxRenderTargets() const - return D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; // 8 - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: -+ case D3D_FEATURE_LEVEL_9_3: // return D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT; // 4 -+ case D3D_FEATURE_LEVEL_9_2: -+ case D3D_FEATURE_LEVEL_9_1: // return D3D_FL9_1_SIMULTANEOUS_RENDER_TARGET_COUNT; // 1 - // Feature level 10.0 and 10.1 cards perform very poorly when the pixel shader - // outputs to multiple RTs that are not bound. - // TODO: Remove pixel shader outputs for render targets that are not bound. -@@ -2603,7 +2674,7 @@ bool Renderer11::copyTexture(ID3D11ShaderResourceView *source, const gl::Rectang - samplerDesc.BorderColor[2] = 0.0f; - samplerDesc.BorderColor[3] = 0.0f; - samplerDesc.MinLOD = 0.0f; -- samplerDesc.MaxLOD = 0.0f; -+ samplerDesc.MaxLOD = mDevice->GetFeatureLevel() >= D3D_FEATURE_LEVEL_10_0 ? 0.0f : FLT_MAX; - - result = mDevice->CreateSamplerState(&samplerDesc, &mCopySampler); - ASSERT(SUCCEEDED(result)); -@@ -2848,7 +2919,7 @@ ShaderExecutable *Renderer11::loadExecutable(const void *function, size_t length - - ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround) - { -- const char *profile = NULL; -+ std::string profile; - - switch (type) - { -@@ -2866,7 +2937,12 @@ ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &infoLog, const ch ++ profileVersion = "4_0_level_9_1"; ++ break; + default: + UNREACHABLE(); return NULL; - } - -- ID3DBlob *binary = (ID3DBlob*)compileToBinary(infoLog, shaderHLSL, profile, D3DCOMPILE_OPTIMIZATION_LEVEL0, false); -+ if (mFeatureLevel == D3D_FEATURE_LEVEL_9_3) -+ profile += "_level_9_3"; -+ else if (mFeatureLevel == D3D_FEATURE_LEVEL_9_2 || mFeatureLevel == D3D_FEATURE_LEVEL_9_1) -+ profile += "_level_9_1"; -+ -+ ID3DBlob *binary = (ID3DBlob*)compileToBinary(infoLog, shaderHLSL, profile.c_str(), D3DCOMPILE_OPTIMIZATION_LEVEL0, false); - if (!binary) - return NULL; - -diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.h -index ba3f0c6..a8a722c 100644 ---- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.h -+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.h -@@ -177,6 +177,7 @@ class Renderer11 : public Renderer +diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h +index 618972d..a31f15e 100644 +--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h ++++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h +@@ -199,6 +199,7 @@ class Renderer11 : public Renderer ID3D11Device *getDevice() { return mDevice; } ID3D11DeviceContext *getDeviceContext() { return mDeviceContext; }; IDXGIFactory *getDxgiFactory() { return mDxgiFactory; }; -+ D3D_FEATURE_LEVEL getFeatureLevel() { return mFeatureLevel; } - - bool getRenderTargetResource(gl::Renderbuffer *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource); - void unapplyRenderTargets(); -diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp -index 5f6ea21..fdfbe52 100644 ---- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp -+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp -@@ -222,14 +222,14 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, SwapChain11 *swapch - } - - TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height) -- : TextureStorage11(renderer, GetTextureBindFlags(gl_d3d11::ConvertTextureFormat(internalformat), usage, forceRenderable)) -+ : TextureStorage11(renderer, GetTextureBindFlags(gl_d3d11::ConvertTextureFormat(internalformat, Renderer11::makeRenderer11(renderer)->getFeatureLevel()), usage, forceRenderable)) - { - for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++) - { - mRenderTarget[i] = NULL; - } - -- DXGI_FORMAT convertedFormat = gl_d3d11::ConvertTextureFormat(internalformat); -+ DXGI_FORMAT convertedFormat = gl_d3d11::ConvertTextureFormat(internalformat, mRenderer->getFeatureLevel()); - if (d3d11::IsDepthStencilFormat(convertedFormat)) - { - mTextureFormat = d3d11::GetDepthTextureFormat(convertedFormat); -@@ -331,7 +331,7 @@ RenderTarget *TextureStorage11_2D::getRenderTarget(int level) - srvDesc.Format = mShaderResourceFormat; - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MostDetailedMip = level; -- srvDesc.Texture2D.MipLevels = 1; -+ srvDesc.Texture2D.MipLevels = level ? 1 : -1; - - ID3D11ShaderResourceView *srv; - result = device->CreateShaderResourceView(mTexture, &srvDesc, &srv); -@@ -440,7 +440,7 @@ void TextureStorage11_2D::generateMipmap(int level) - } ++ bool isLevel9() { return mFeatureLevel <= D3D_FEATURE_LEVEL_9_3; } - TextureStorage11_Cube::TextureStorage11_Cube(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size) -- : TextureStorage11(renderer, GetTextureBindFlags(gl_d3d11::ConvertTextureFormat(internalformat), usage, forceRenderable)) -+ : TextureStorage11(renderer, GetTextureBindFlags(gl_d3d11::ConvertTextureFormat(internalformat, Renderer11::makeRenderer11(renderer)->getFeatureLevel()), usage, forceRenderable)) - { - for (unsigned int i = 0; i < 6; i++) - { -@@ -450,7 +450,7 @@ TextureStorage11_Cube::TextureStorage11_Cube(Renderer *renderer, int levels, GLe - } - } + Blit11 *getBlitter() { return mBlit; } -- DXGI_FORMAT convertedFormat = gl_d3d11::ConvertTextureFormat(internalformat); -+ DXGI_FORMAT convertedFormat = gl_d3d11::ConvertTextureFormat(internalformat, mRenderer->getFeatureLevel()); - if (d3d11::IsDepthStencilFormat(convertedFormat)) - { - mTextureFormat = d3d11::GetDepthTextureFormat(convertedFormat); -diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp -index 6f06024..34b8259 100644 ---- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp -+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp -@@ -329,7 +329,7 @@ DXGI_FORMAT ConvertRenderbufferFormat(GLenum format) - return DXGI_FORMAT_R8G8B8A8_UNORM; - } +diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp +index 65e0e63..00b81b7 100644 +--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp ++++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp +@@ -441,7 +441,7 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, GLenum internalform + D3D11_TEXTURE2D_DESC desc; + desc.Width = width; // Compressed texture size constraints? + desc.Height = height; +- desc.MipLevels = ((levels > 0) ? (mTopLevel + levels) : 0); ++ desc.MipLevels = mRenderer->isLevel9() ? 1 : ((levels > 0) ? (mTopLevel + levels) : 0); + desc.ArraySize = 1; + desc.Format = mTextureFormat; + desc.SampleDesc.Count = 1; +diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.cpp +index a300c2e..c991fd4 100644 +--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.cpp ++++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.cpp +@@ -106,7 +106,7 @@ static D3D11ES3FormatMap BuildD3D11FormatMap() --DXGI_FORMAT ConvertTextureFormat(GLenum internalformat) -+DXGI_FORMAT ConvertTextureFormat(GLenum internalformat, D3D_FEATURE_LEVEL featureLevel) - { - switch (internalformat) - { -@@ -342,7 +342,7 @@ DXGI_FORMAT ConvertTextureFormat(GLenum internalformat) - case GL_LUMINANCE8_ALPHA8_EXT: - return DXGI_FORMAT_R8G8B8A8_UNORM; - case GL_ALPHA8_EXT: -- return DXGI_FORMAT_A8_UNORM; -+ return featureLevel >= D3D_FEATURE_LEVEL_10_0 ? DXGI_FORMAT_A8_UNORM : DXGI_FORMAT_B8G8R8A8_UNORM; - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - return DXGI_FORMAT_BC1_UNORM; -diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.h -index 1bc48c1..70ad4fe 100644 ---- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.h -+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.h -@@ -32,7 +32,7 @@ FLOAT ConvertMinLOD(GLenum minFilter, unsigned int lodOffset); - FLOAT ConvertMaxLOD(GLenum minFilter, unsigned int lodOffset); - - DXGI_FORMAT ConvertRenderbufferFormat(GLenum format); --DXGI_FORMAT ConvertTextureFormat(GLenum format); -+DXGI_FORMAT ConvertTextureFormat(GLenum format, D3D_FEATURE_LEVEL featureLevel); - } + // From GL_EXT_texture_storage + // | GL internal format | | D3D11 texture format | D3D11 SRV format | D3D11 RTV format | D3D11 DSV format | +- map.insert(D3D11ES3FormatPair(GL_ALPHA8_EXT, D3D11FormatInfo(DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_UNKNOWN ))); ++ map.insert(D3D11ES3FormatPair(GL_ALPHA8_EXT, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_LUMINANCE8_EXT, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_ALPHA32F_EXT, D3D11FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_LUMINANCE32F_EXT, D3D11FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN ))); +@@ -309,7 +309,7 @@ D3D11LoadFunctionMap buildD3D11LoadFunctionMap() + insertLoadFunction(&map, GL_ALPHA, GL_HALF_FLOAT_OES, LoadA16FToRGBA16F ); - namespace d3d11_gl + // From GL_EXT_texture_storage +- insertLoadFunction(&map, GL_ALPHA8_EXT, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 1> ); ++ insertLoadFunction(&map, GL_ALPHA8_EXT, GL_UNSIGNED_BYTE, LoadA8ToBGRA8 ); + insertLoadFunction(&map, GL_LUMINANCE8_EXT, GL_UNSIGNED_BYTE, LoadL8ToRGBA8 ); + insertLoadFunction(&map, GL_LUMINANCE8_ALPHA8_EXT, GL_UNSIGNED_BYTE, LoadLA8ToRGBA8 ); + insertLoadFunction(&map, GL_ALPHA32F_EXT, GL_FLOAT, LoadA32FToRGBA32F ); -- -1.8.4.msysgit.0 +1.9.0.msysgit.0 |