summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libGLESv2/renderer
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-02-24 11:18:33 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-26 07:56:50 +0100
commita7d093e740b1e20874b5ebeb37b5c5d76ae19e42 (patch)
tree573b63025dbaa090392e468e1a90de8104054578 /src/3rdparty/angle/src/libGLESv2/renderer
parent45e17d0cc74d3444e23c18f73d6ac155659cec55 (diff)
Upgrade ANGLE to 1.3.5bb7ec572d0a
This brings Qt's copy of ANGLE up to ANGLE master, which contains a number of bugfixes as well as restructuring for the upcoming ES 3.0 support. This version brings considerable stability improvements to the D3D11 renderer. The static translator project files have been merged to align with the ANGLE source tree. Two new patches have been applied to fix errors in upstream ANGLE: - 0011-ANGLE-Fix-compilation-error-on-MinGW-caused-by-trace.patch The event trace header in ANGLE's third_party directory has an unused template which causes a compilation error on MinGW. Disable this part of the code. - 0012-ANGLE-fix-semantic-index-lookup.patch The sorted semantic index table was returning a direct mapping to the new indices, instead of the old indices. This caused a mismatch in the GL type lookup for the translated attribute. All other patches have been rebased, removed if no longer needed, and renamed to clear up the application order: - 0001-Fix-compilation-for-MSVC-2008-and-std-tuple.patch No changes. - 0001-Fix-compilation-with-MinGW-mingw-tdm64-gcc-4.8.1.patch No changes. Renamed to 0002. - 0001-Fix-compilation-with-MinGW-gcc-64-bit.patch No changes. Renamed to 0003. - 0001-Make-it-possible-to-link-ANGLE-statically-for-single.patch Modified patch to adapt to new DLL loading structure. Renamed to 0004. - 0005-Fix-build-when-SSE2-is-not-available.patch No changes. - 0011-Fix-compilation-of-libGLESv2-with-older-MinGW-w64-he.patch No changes. Renamed to 0006. - 0006-Make-DX9-DX11-mutually-exclusive.patch Made the patch less invasive by allowing D3D9 code to run unless explicitly disabled (e.g. on WinRT, where it doesn't compile). This makes the patch smaller and allows Desktop Windows to compile both D3D9 and D3D11 codepaths. Renamed to 0007. - 0015-ANGLE-Dynamically-load-D3D-compiler-from-a-list-of-k.patch No changes. Renamed to 0008. - 0012-ANGLE-Support-WinRT.patch Made D3D11_level9 initialization only possible if D3D9 is disabled. This makes sure Desktop PCs use the old D3D9 codepath instead of the less-tested D3D11_level9 codepath. Renamed to 0009. - 0013-Enable-D3D11-for-feature-level-9-cards.patch Conveniently smaller patch due to buffer implementation improvements upstream. Renamed to 0010. - 0014-ANGLE-D3D11-Alwayls-execute-QueryInterface.patch This was a fix for patch 0009, so was integrated there. Removed. - 0016-ANGLE-D3D11-Fix-build-on-desktop-Windows.patch This was a fix for patch 0009, so it was integrated there. Removed. - 0001-ANGLE-Fix-compilation-with-MSVC2013.patch Fixed upstream. Removed. - 0007-ANGLE-Fix-typedefs-for-Win64.patch Fixed upstream. Removed. - 0004-Fix-black-screen-after-minimizing-OpenGL-window-with.patch The issue has been fixed in Qt itself. Removed. - 0008-DX11-Prevent-assert-when-view-is-minimized-or-.patch The cause of the problem was the same as patch 0004, but for the D3D11 codepath. Removed. Change-Id: Id69484ab3a3e013050741c462fb1b06dfb0fd112 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Diffstat (limited to 'src/3rdparty/angle/src/libGLESv2/renderer')
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage.h2
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.cpp361
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.h56
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp83
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/Renderer.h34
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/SwapChain.h7
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/VertexDataManager.cpp4
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.cpp366
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.h92
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Fence11.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Fence11.cpp)4
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Fence11.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Fence11.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Image11.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Image11.cpp)48
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Image11.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Image11.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/IndexBuffer11.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/IndexBuffer11.cpp)8
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/IndexBuffer11.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/IndexBuffer11.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/InputLayoutCache.cpp)14
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/InputLayoutCache.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/InputLayoutCache.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Query11.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Query11.cpp)4
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Query11.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Query11.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/RenderStateCache.cpp)60
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/RenderStateCache.h)22
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderTarget11.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget11.cpp)6
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderTarget11.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget11.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Renderer11.cpp)400
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Renderer11.h)20
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/ShaderExecutable11.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable11.cpp)2
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/ShaderExecutable11.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable11.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/SwapChain11.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/SwapChain11.cpp)215
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/SwapChain11.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/SwapChain11.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/TextureStorage11.cpp)18
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/TextureStorage11.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/VertexBuffer11.cpp)4
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/VertexBuffer11.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/VertexBuffer11.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/renderer11_utils.cpp)2
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/renderer11_utils.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/shaders/Clear11.hlsl (renamed from src/3rdparty/angle/src/libGLESv2/renderer/shaders/Clear11.hlsl)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d11/shaders/Passthrough11.hlsl (renamed from src/3rdparty/angle/src/libGLESv2/renderer/shaders/Passthrough11.hlsl)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Blit.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Blit.cpp)20
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Blit.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Blit.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/BufferStorage9.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage9.cpp)4
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/BufferStorage9.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage9.h)2
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Fence9.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Fence9.cpp)6
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Fence9.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Fence9.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Image9.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Image9.cpp)12
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Image9.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Image9.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/IndexBuffer9.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/IndexBuffer9.cpp)4
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/IndexBuffer9.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/IndexBuffer9.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Query9.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Query9.cpp)6
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Query9.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Query9.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/RenderTarget9.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget9.cpp)6
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/RenderTarget9.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget9.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Renderer9.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Renderer9.cpp)207
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Renderer9.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/Renderer9.h)14
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/ShaderExecutable9.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable9.cpp)2
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/ShaderExecutable9.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable9.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/SwapChain9.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/SwapChain9.cpp)44
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/SwapChain9.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/SwapChain9.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/TextureStorage9.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/TextureStorage9.cpp)10
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/TextureStorage9.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/TextureStorage9.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/VertexBuffer9.cpp)8
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/VertexBuffer9.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/VertexBuffer9.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/VertexDeclarationCache.cpp)4
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/VertexDeclarationCache.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/renderer9_utils.cpp (renamed from src/3rdparty/angle/src/libGLESv2/renderer/renderer9_utils.cpp)2
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/renderer9_utils.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/renderer9_utils.h)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/shaders/Blit.ps (renamed from src/3rdparty/angle/src/libGLESv2/renderer/shaders/Blit.ps)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/shaders/Blit.vs (renamed from src/3rdparty/angle/src/libGLESv2/renderer/shaders/Blit.vs)0
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d9/vertexconversion.h (renamed from src/3rdparty/angle/src/libGLESv2/renderer/vertexconversion.h)0
68 files changed, 1123 insertions, 1060 deletions
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage.h b/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage.h
index 14a8c2765b..ace1a11bae 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage.h
@@ -22,7 +22,7 @@ class BufferStorage
// The data returned is only guaranteed valid until next non-const method.
virtual void *getData() = 0;
- virtual void setData(const void* data, unsigned int size, unsigned int offset, unsigned int target) = 0;
+ virtual void setData(const void* data, unsigned int size, unsigned int offset) = 0;
virtual void clear() = 0;
virtual unsigned int getSize() const = 0;
virtual bool supportsDirectBinding() const = 0;
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.cpp
deleted file mode 100644
index 2f694db061..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.cpp
+++ /dev/null
@@ -1,361 +0,0 @@
-#include "precompiled.h"
-//
-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// BufferStorage11.cpp Defines the BufferStorage11 class.
-
-#include "libGLESv2/renderer/BufferStorage11.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/renderer/Renderer11.h"
-
-namespace rx
-{
-
-BufferStorage11::BufferStorage11(Renderer11 *renderer)
-{
- mRenderer = renderer;
-
- mStagingBuffer = NULL;
- mStagingBufferSize = 0;
-
- mBuffer = NULL;
- mBufferSize = 0;
-
- mSize = 0;
-
- mResolvedData = NULL;
- mResolvedDataSize = 0;
- mResolvedDataValid = false;
-
- mReadUsageCount = 0;
- mWriteUsageCount = 0;
-}
-
-BufferStorage11::~BufferStorage11()
-{
- if (mStagingBuffer)
- {
- mStagingBuffer->Release();
- mStagingBuffer = NULL;
- }
-
- if (mBuffer)
- {
- mBuffer->Release();
- mBuffer = NULL;
- }
-
- if (mResolvedData)
- {
- free(mResolvedData);
- mResolvedData = NULL;
- }
-}
-
-BufferStorage11 *BufferStorage11::makeBufferStorage11(BufferStorage *bufferStorage)
-{
- ASSERT(HAS_DYNAMIC_TYPE(BufferStorage11*, bufferStorage));
- return static_cast<BufferStorage11*>(bufferStorage);
-}
-
-void *BufferStorage11::getData()
-{
- if (!mResolvedDataValid)
- {
- ID3D11Device *device = mRenderer->getDevice();
- ID3D11DeviceContext *context = mRenderer->getDeviceContext();
- HRESULT result;
-
- if (!mStagingBuffer || mStagingBufferSize < mBufferSize)
- {
- if (mStagingBuffer)
- {
- mStagingBuffer->Release();
- mStagingBuffer = NULL;
- mStagingBufferSize = 0;
- }
-
- D3D11_BUFFER_DESC bufferDesc;
- bufferDesc.ByteWidth = mSize;
- bufferDesc.Usage = D3D11_USAGE_STAGING;
- bufferDesc.BindFlags = 0;
- bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
- bufferDesc.MiscFlags = 0;
- bufferDesc.StructureByteStride = 0;
-
- result = device->CreateBuffer(&bufferDesc, NULL, &mStagingBuffer);
- if (FAILED(result))
- {
- return gl::error(GL_OUT_OF_MEMORY, (void*)NULL);
- }
-
- mStagingBufferSize = bufferDesc.ByteWidth;
- }
-
- if (!mResolvedData || mResolvedDataSize < mBufferSize)
- {
- free(mResolvedData);
- mResolvedData = malloc(mSize);
- mResolvedDataSize = mSize;
- }
-
- D3D11_BOX srcBox;
- srcBox.left = 0;
- srcBox.right = mSize;
- srcBox.top = 0;
- srcBox.bottom = 1;
- srcBox.front = 0;
- srcBox.back = 1;
-
- context->CopySubresourceRegion(mStagingBuffer, 0, 0, 0, 0, mBuffer, 0, &srcBox);
-
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- result = context->Map(mStagingBuffer, 0, D3D11_MAP_READ, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::error(GL_OUT_OF_MEMORY, (void*)NULL);
- }
-
- memcpy(mResolvedData, mappedResource.pData, mSize);
-
- context->Unmap(mStagingBuffer, 0);
-
- mResolvedDataValid = true;
- }
-
- mReadUsageCount = 0;
-
- return mResolvedData;
-}
-
-void BufferStorage11::setData(const void* data, unsigned int size, unsigned int offset, unsigned int target)
-{
- ID3D11Device *device = mRenderer->getDevice();
- ID3D11DeviceContext *context = mRenderer->getDeviceContext();
- HRESULT result;
-
- unsigned int requiredBufferSize = size + offset;
- unsigned int requiredStagingSize = size;
- bool directInitialization = offset == 0 && (!mBuffer || mBufferSize < size + offset);
-
- if (!directInitialization)
- {
- if (!mStagingBuffer || mStagingBufferSize < requiredStagingSize)
- {
- if (mStagingBuffer)
- {
- mStagingBuffer->Release();
- mStagingBuffer = NULL;
- mStagingBufferSize = 0;
- }
-
- D3D11_BUFFER_DESC bufferDesc;
- bufferDesc.ByteWidth = size;
- bufferDesc.Usage = D3D11_USAGE_STAGING;
- bufferDesc.BindFlags = 0;
- bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
- bufferDesc.MiscFlags = 0;
- bufferDesc.StructureByteStride = 0;
-
- if (data)
- {
- D3D11_SUBRESOURCE_DATA initialData;
- initialData.pSysMem = data;
- initialData.SysMemPitch = size;
- initialData.SysMemSlicePitch = 0;
-
- result = device->CreateBuffer(&bufferDesc, &initialData, &mStagingBuffer);
- }
- else
- {
- result = device->CreateBuffer(&bufferDesc, NULL, &mStagingBuffer);
- }
-
- if (FAILED(result))
- {
- return gl::error(GL_OUT_OF_MEMORY);
- }
-
- mStagingBufferSize = size;
- }
- else if (data)
- {
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- result = context->Map(mStagingBuffer, 0, D3D11_MAP_WRITE, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::error(GL_OUT_OF_MEMORY);
- }
-
- memcpy(mappedResource.pData, data, size);
-
- context->Unmap(mStagingBuffer, 0);
- }
- }
-
- if (!mBuffer || mBufferSize < size + offset)
- {
- D3D11_BUFFER_DESC bufferDesc;
- bufferDesc.ByteWidth = requiredBufferSize;
- bufferDesc.Usage = D3D11_USAGE_DEFAULT;
- if (mRenderer->getFeatureLevel() > D3D_FEATURE_LEVEL_9_3)
- bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER | D3D11_BIND_INDEX_BUFFER;
- else
- bufferDesc.BindFlags = target == GL_ARRAY_BUFFER ? D3D11_BIND_VERTEX_BUFFER : D3D11_BIND_INDEX_BUFFER;
- bufferDesc.CPUAccessFlags = 0;
- bufferDesc.MiscFlags = 0;
- bufferDesc.StructureByteStride = 0;
-
- if (directInitialization)
- {
- // Since the data will fill the entire buffer (being larger than the initial size and having
- // no offset), the buffer can be initialized with the data so no staging buffer is required
-
- // No longer need the old buffer
- if (mBuffer)
- {
- mBuffer->Release();
- mBuffer = NULL;
- mBufferSize = 0;
- }
-
- if (data)
- {
- D3D11_SUBRESOURCE_DATA initialData;
- initialData.pSysMem = data;
- initialData.SysMemPitch = size;
- initialData.SysMemSlicePitch = 0;
-
- result = device->CreateBuffer(&bufferDesc, &initialData, &mBuffer);
- }
- else
- {
- result = device->CreateBuffer(&bufferDesc, NULL, &mBuffer);
- }
-
- if (FAILED(result))
- {
- return gl::error(GL_OUT_OF_MEMORY);
- }
- }
- else if (mBuffer && offset > 0)
- {
- // If offset is greater than zero and the buffer is non-null, need to preserve the data from
- // the old buffer up to offset
- ID3D11Buffer *newBuffer = NULL;
-
- result = device->CreateBuffer(&bufferDesc, NULL, &newBuffer);
- if (FAILED(result))
- {
- return gl::error(GL_OUT_OF_MEMORY);
- }
-
- D3D11_BOX srcBox;
- srcBox.left = 0;
- srcBox.right = std::min(offset, mBufferSize);
- srcBox.top = 0;
- srcBox.bottom = 1;
- srcBox.front = 0;
- srcBox.back = 1;
-
- context->CopySubresourceRegion(newBuffer, 0, 0, 0, 0, mBuffer, 0, &srcBox);
-
- mBuffer->Release();
- mBuffer = newBuffer;
- }
- else
- {
- // Simple case, nothing needs to be copied from the old buffer to the new one, just create
- // a new buffer
-
- // No longer need the old buffer
- if (mBuffer)
- {
- mBuffer->Release();
- mBuffer = NULL;
- mBufferSize = 0;
- }
-
- // Create a new buffer for data storage
- result = device->CreateBuffer(&bufferDesc, NULL, &mBuffer);
- if (FAILED(result))
- {
- return gl::error(GL_OUT_OF_MEMORY);
- }
- }
-
- updateSerial();
- mBufferSize = bufferDesc.ByteWidth;
- }
-
- if (!directInitialization)
- {
- ASSERT(mStagingBuffer && mStagingBufferSize >= requiredStagingSize);
-
- // Data is already put into the staging buffer, copy it over to the data buffer
- D3D11_BOX srcBox;
- srcBox.left = 0;
- srcBox.right = size;
- srcBox.top = 0;
- srcBox.bottom = 1;
- srcBox.front = 0;
- srcBox.back = 1;
-
- context->CopySubresourceRegion(mBuffer, 0, offset, 0, 0, mStagingBuffer, 0, &srcBox);
- }
-
- mSize = std::max(mSize, offset + size);
-
- mWriteUsageCount = 0;
-
- mResolvedDataValid = false;
-}
-
-void BufferStorage11::clear()
-{
- mResolvedDataValid = false;
- mSize = 0;
-}
-
-unsigned int BufferStorage11::getSize() const
-{
- return mSize;
-}
-
-bool BufferStorage11::supportsDirectBinding() const
-{
- return mRenderer->getFeatureLevel() >= D3D_FEATURE_LEVEL_10_0;
-}
-
-void BufferStorage11::markBufferUsage()
-{
- mReadUsageCount++;
- mWriteUsageCount++;
-
- static const unsigned int usageLimit = 5;
-
- if (mReadUsageCount > usageLimit && mResolvedData)
- {
- free(mResolvedData);
- mResolvedData = NULL;
- mResolvedDataSize = 0;
- mResolvedDataValid = false;
- }
-
- if (mReadUsageCount > usageLimit && mWriteUsageCount > usageLimit && mStagingBuffer)
- {
- mStagingBuffer->Release();
- mStagingBuffer = NULL;
- mStagingBufferSize = 0;
- }
-}
-
-ID3D11Buffer *BufferStorage11::getBuffer() const
-{
- return mBuffer;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.h b/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.h
deleted file mode 100644
index c9489627c3..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.h
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// BufferStorage11.h Defines the BufferStorage11 class.
-
-#ifndef LIBGLESV2_RENDERER_BUFFERSTORAGE11_H_
-#define LIBGLESV2_RENDERER_BUFFERSTORAGE11_H_
-
-#include "libGLESv2/renderer/BufferStorage.h"
-
-namespace rx
-{
-class Renderer11;
-
-class BufferStorage11 : public BufferStorage
-{
- public:
- explicit BufferStorage11(Renderer11 *renderer);
- virtual ~BufferStorage11();
-
- static BufferStorage11 *makeBufferStorage11(BufferStorage *bufferStorage);
-
- virtual void *getData();
- virtual void setData(const void* data, unsigned int size, unsigned int offset, unsigned int target);
- virtual void clear();
- virtual unsigned int getSize() const;
- virtual bool supportsDirectBinding() const;
- virtual void markBufferUsage();
-
- ID3D11Buffer *getBuffer() const;
-
- private:
- Renderer11 *mRenderer;
-
- ID3D11Buffer *mStagingBuffer;
- unsigned int mStagingBufferSize;
-
- ID3D11Buffer *mBuffer;
- unsigned int mBufferSize;
-
- unsigned int mSize;
-
- void *mResolvedData;
- unsigned int mResolvedDataSize;
- bool mResolvedDataValid;
-
- unsigned int mReadUsageCount;
- unsigned int mWriteUsageCount;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_BUFFERSTORAGE11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp
index 39fd0f41f0..5278113811 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp
@@ -11,35 +11,26 @@
#include "libGLESv2/main.h"
#include "libGLESv2/Program.h"
#include "libGLESv2/renderer/Renderer.h"
-#ifndef ANGLE_ENABLE_D3D11
-#include "libGLESv2/renderer/Renderer9.h"
-#else
-#include "libGLESv2/renderer/Renderer11.h"
+#if defined(ANGLE_ENABLE_D3D9)
+# include "libGLESv2/renderer/d3d9/Renderer9.h"
+#endif
+#if defined(ANGLE_ENABLE_D3D11)
+# include "libGLESv2/renderer/d3d11/Renderer11.h"
#endif
#include "libGLESv2/utilities.h"
#include "third_party/trace_event/trace_event.h"
-#if !defined(ANGLE_ENABLE_D3D11)
-// Enables use of the Direct3D 11 API for a default display, when available
-#define ANGLE_ENABLE_D3D11 0
-#endif
-
#ifndef D3DERR_OUTOFVIDEOMEMORY
#define D3DERR_OUTOFVIDEOMEMORY MAKE_HRESULT(1, 0x876, 380)
#endif
-#ifndef D3DCOMPILER_DLL
-#define D3DCOMPILER_DLL L"d3dcompiler_43.dll" // Lowest common denominator
-#endif
+#if defined(__MINGW32__) || defined(ANGLE_OS_WINPHONE)
-#ifndef QT_D3DCOMPILER_DLL
-#define QT_D3DCOMPILER_DLL D3DCOMPILER_DLL
-#endif
+#ifndef D3DCOMPILER_DLL
-#if defined(__MINGW32__) || defined(ANGLE_OS_WINPHONE)
+// Add define + typedefs for older MinGW-w64 headers (pre 5783)
-//Add define + typedefs for older MinGW-w64 headers (pre 5783)
-//Also define these on Windows Phone, which doesn't have a shader compiler
+#define D3DCOMPILER_DLL L"d3dcompiler_43.dll"
HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename,
const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint,
@@ -48,8 +39,14 @@ typedef HRESULT (WINAPI *pD3DCompile)(const void *data, SIZE_T data_size, const
const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint,
const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages);
+#endif // D3DCOMPILER_DLL
+
#endif // __MINGW32__ || ANGLE_OS_WINPHONE
+#ifndef QT_D3DCOMPILER_DLL
+#define QT_D3DCOMPILER_DLL D3DCOMPILER_DLL
+#endif
+
namespace rx
{
@@ -82,7 +79,8 @@ bool Renderer::initializeCompiler()
break;
}
}
-#else
+#endif // ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES
+
// Load the compiler DLL specified by the environment, or default to QT_D3DCOMPILER_DLL
#if !defined(ANGLE_OS_WINRT)
const wchar_t *defaultCompiler = _wgetenv(L"QT_D3DCOMPILER_DLL");
@@ -109,15 +107,11 @@ bool Renderer::initializeCompiler()
// Load the first available known compiler DLL
for (int i = 0; compilerDlls[i]; ++i)
{
-#if !defined(ANGLE_OS_WINRT)
+ // Load the version of the D3DCompiler DLL associated with the Direct3D version ANGLE was built with.
mD3dCompilerModule = LoadLibrary(compilerDlls[i]);
-#else
- mD3dCompilerModule = LoadPackagedLibrary(compilerDlls[i], NULL);
-#endif
if (mD3dCompilerModule)
break;
}
-#endif // ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES
if (!mD3dCompilerModule)
{
@@ -230,18 +224,46 @@ ShaderBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, co
extern "C"
{
-rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, EGLNativeDisplayType displayId)
+rx::Renderer *glCreateRenderer(egl::Display *display, EGLNativeDisplayType displayId)
{
rx::Renderer *renderer = NULL;
EGLint status = EGL_BAD_ALLOC;
-#if ANGLE_ENABLE_D3D11
- renderer = new rx::Renderer11(display, hDc);
-#else
- bool softwareDevice = (displayId == EGL_SOFTWARE_DISPLAY_ANGLE);
- renderer = new rx::Renderer9(display, hDc, softwareDevice);
+#if defined(ANGLE_OS_WINRT)
+ if (displayId == EGL_DEFAULT_DISPLAY)
+ displayId = EGL_D3D11_ONLY_DISPLAY_ANGLE;
#endif
+#if defined(ANGLE_ENABLE_D3D11)
+ if (displayId == EGL_DEFAULT_DISPLAY ||
+ displayId == EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ||
+ displayId == EGL_D3D11_ONLY_DISPLAY_ANGLE)
+ {
+ renderer = new rx::Renderer11(display);
+
+ if (renderer)
+ {
+ status = renderer->initialize();
+ }
+
+ if (status == EGL_SUCCESS)
+ {
+ return renderer;
+ }
+ else if (displayId == EGL_D3D11_ONLY_DISPLAY_ANGLE)
+ {
+ return NULL;
+ }
+
+ // Failed to create a D3D11 renderer, try creating a D3D9 renderer
+ delete renderer;
+ }
+#endif // ANGLE_ENABLE_D3D11
+
+#if defined(ANGLE_ENABLE_D3D9)
+ bool softwareDevice = (displayId == EGL_SOFTWARE_DISPLAY_ANGLE);
+ renderer = new rx::Renderer9(display, displayId, softwareDevice);
+
if (renderer)
{
status = renderer->initialize();
@@ -251,6 +273,7 @@ rx::Renderer *glCreateRenderer(egl::Display *display, HDC hDc, EGLNativeDisplayT
{
return renderer;
}
+#endif // ANGLE_ENABLE_D3D9
return NULL;
}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.h b/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.h
index ac67c27e71..79578b2458 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.h
@@ -14,30 +14,6 @@
#include "libGLESv2/Uniform.h"
#include "libGLESv2/angletypes.h"
-#ifndef D3DCOMPILE_OPTIMIZATION_LEVEL0
-#define D3DCOMPILE_OPTIMIZATION_LEVEL0 (1 << 14)
-#endif
-#ifndef D3DCOMPILE_OPTIMIZATION_LEVEL1
-#define D3DCOMPILE_OPTIMIZATION_LEVEL1 0
-#endif
-#ifndef D3DCOMPILE_OPTIMIZATION_LEVEL2
-#define D3DCOMPILE_OPTIMIZATION_LEVEL2 ((1 << 14) | (1 << 15))
-#endif
-#ifndef D3DCOMPILE_OPTIMIZATION_LEVEL3
-#define D3DCOMPILE_OPTIMIZATION_LEVEL3 (1 << 15)
-#endif
-#ifndef D3DCOMPILE_DEBUG
-#define D3DCOMPILE_DEBUG (1 << 0)
-#endif
-#ifndef D3DCOMPILE_SKIP_OPTIMIZATION
-#define D3DCOMPILE_SKIP_OPTIMIZATION (1 << 2)
-#endif
-#ifndef D3DCOMPILE_AVOID_FLOW_CONTROL
-#define D3DCOMPILE_AVOID_FLOW_CONTROL (1 << 9)
-#endif
-#ifndef D3DCOMPILE_PREFER_FLOW_CONTROL
-#define D3DCOMPILE_PREFER_FLOW_CONTROL (1 << 10)
-#endif
#if !defined(ANGLE_COMPILE_OPTIMIZATION_LEVEL)
#define ANGLE_COMPILE_OPTIMIZATION_LEVEL D3DCOMPILE_OPTIMIZATION_LEVEL3
#endif
@@ -118,6 +94,12 @@ enum ShaderType
SHADER_GEOMETRY
};
+enum D3DWorkaroundType
+{
+ ANGLE_D3D_WORKAROUND_NONE,
+ ANGLE_D3D_WORKAROUND_SM3_OPTIMIZER
+};
+
class Renderer
{
public:
@@ -138,7 +120,7 @@ class Renderer
virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0;
virtual void setRasterizerState(const gl::RasterizerState &rasterState) = 0;
- virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
+ virtual void setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::Color &blendColor,
unsigned int sampleMask) = 0;
virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW) = 0;
@@ -232,7 +214,7 @@ class Renderer
// Shader operations
virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type) = 0;
- virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type) = 0;
+ virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround) = 0;
// Image operations
virtual Image *createImage() = 0;
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain.h b/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain.h
index a6870ebedc..8231fbcb25 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain.h
@@ -1,3 +1,4 @@
+#include "../precompiled.h"
//
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
@@ -12,6 +13,10 @@
#include "common/angleutils.h"
+#if !defined(ANGLE_FORCE_VSYNC_OFF)
+#define ANGLE_FORCE_VSYNC_OFF 0
+#endif
+
namespace rx
{
@@ -33,7 +38,7 @@ class SwapChain
virtual HANDLE getShareHandle() {return mShareHandle;};
protected:
- const EGLNativeWindowType mWindow; // Window that the surface is created for.
+ const EGLNativeWindowType mWindow; // Window that the surface is created for.
const GLenum mBackBufferFormat;
const GLenum mDepthBufferFormat;
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/VertexDataManager.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/VertexDataManager.cpp
index 7ff5171fca..8034aed8c9 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/VertexDataManager.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/VertexDataManager.cpp
@@ -266,6 +266,10 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[],
return GL_OUT_OF_MEMORY;
}
+ mCurrentValue[i][0] = attribs[i].mCurrentValue[0];
+ mCurrentValue[i][1] = attribs[i].mCurrentValue[1];
+ mCurrentValue[i][2] = attribs[i].mCurrentValue[2];
+ mCurrentValue[i][3] = attribs[i].mCurrentValue[3];
mCurrentValueOffsets[i] = streamOffset;
}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.cpp
new file mode 100644
index 0000000000..31d5b8b886
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.cpp
@@ -0,0 +1,366 @@
+#include "precompiled.h"
+//
+// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// BufferStorage11.cpp Defines the BufferStorage11 class.
+
+#include "libGLESv2/renderer/d3d11/BufferStorage11.h"
+#include "libGLESv2/main.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
+
+namespace rx
+{
+
+BufferStorage11::BufferStorage11(Renderer11 *renderer)
+{
+ mRenderer = renderer;
+
+ mStagingBuffer = NULL;
+ mStagingBufferSize = 0;
+
+ mSize = 0;
+
+ mResolvedData = NULL;
+ mResolvedDataSize = 0;
+ mResolvedDataValid = false;
+
+ mReadUsageCount = 0;
+ mWriteUsageCount = 0;
+}
+
+BufferStorage11::~BufferStorage11()
+{
+ SafeRelease(mStagingBuffer);
+
+ if (mResolvedData)
+ {
+ free(mResolvedData);
+ mResolvedData = NULL;
+ }
+
+ for (auto it = mDirectBuffers.begin(); it != mDirectBuffers.end(); it++)
+ {
+ SafeDelete(it->second);
+ }
+}
+
+BufferStorage11 *BufferStorage11::makeBufferStorage11(BufferStorage *bufferStorage)
+{
+ ASSERT(HAS_DYNAMIC_TYPE(BufferStorage11*, bufferStorage));
+ return static_cast<BufferStorage11*>(bufferStorage);
+}
+
+void *BufferStorage11::getData()
+{
+ ASSERT(mStagingBuffer);
+
+ if (!mResolvedDataValid)
+ {
+ ID3D11Device *device = mRenderer->getDevice();
+ ID3D11DeviceContext *context = mRenderer->getDeviceContext();
+ HRESULT result;
+
+ if (!mResolvedData || mResolvedDataSize < mStagingBufferSize)
+ {
+ free(mResolvedData);
+ mResolvedData = malloc(mSize);
+ mResolvedDataSize = mSize;
+ }
+
+ D3D11_MAPPED_SUBRESOURCE mappedResource;
+ result = context->Map(mStagingBuffer, 0, D3D11_MAP_READ, 0, &mappedResource);
+ if (FAILED(result))
+ {
+ return gl::error(GL_OUT_OF_MEMORY, (void*)NULL);
+ }
+
+ memcpy(mResolvedData, mappedResource.pData, mSize);
+
+ context->Unmap(mStagingBuffer, 0);
+
+ mResolvedDataValid = true;
+ }
+
+ mReadUsageCount = 0;
+
+ return mResolvedData;
+}
+
+void BufferStorage11::setData(const void* data, unsigned int size, unsigned int offset)
+{
+ ID3D11Device *device = mRenderer->getDevice();
+ ID3D11DeviceContext *context = mRenderer->getDeviceContext();
+ HRESULT result;
+
+ const unsigned int requiredStagingBufferSize = size + offset;
+ const bool createStagingBuffer = !mStagingBuffer || mStagingBufferSize < requiredStagingBufferSize;
+
+ if (createStagingBuffer)
+ {
+ D3D11_BUFFER_DESC bufferDesc;
+ bufferDesc.ByteWidth = requiredStagingBufferSize;
+ bufferDesc.Usage = D3D11_USAGE_STAGING;
+ bufferDesc.BindFlags = 0;
+ bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
+ bufferDesc.MiscFlags = 0;
+ bufferDesc.StructureByteStride = 0;
+
+ HRESULT result;
+ ID3D11Device *device = mRenderer->getDevice();
+ ID3D11DeviceContext *context = mRenderer->getDeviceContext();
+ ID3D11Buffer *newStagingBuffer;
+
+ if (data && offset == 0)
+ {
+ D3D11_SUBRESOURCE_DATA initialData;
+ initialData.pSysMem = data;
+ initialData.SysMemPitch = requiredStagingBufferSize;
+ initialData.SysMemSlicePitch = 0;
+
+ result = device->CreateBuffer(&bufferDesc, &initialData, &newStagingBuffer);
+ }
+ else
+ {
+ result = device->CreateBuffer(&bufferDesc, NULL, &newStagingBuffer);
+ }
+
+ if (FAILED(result))
+ {
+ mStagingBufferSize = 0;
+ return gl::error(GL_OUT_OF_MEMORY);
+ }
+
+ mStagingBufferSize = requiredStagingBufferSize;
+
+ if (mStagingBuffer && offset > 0)
+ {
+ // If offset is greater than zero and the buffer is non-null, need to preserve the data from
+ // the old buffer up to offset
+ D3D11_BOX srcBox;
+ srcBox.left = 0;
+ srcBox.right = std::min(offset, requiredStagingBufferSize);
+ srcBox.top = 0;
+ srcBox.bottom = 1;
+ srcBox.front = 0;
+ srcBox.back = 1;
+
+ context->CopySubresourceRegion(newStagingBuffer, 0, 0, 0, 0, mStagingBuffer, 0, &srcBox);
+ }
+
+ SafeRelease(mStagingBuffer);
+ mStagingBuffer = newStagingBuffer;
+ }
+
+ if (data && (offset != 0 || !createStagingBuffer))
+ {
+ D3D11_MAPPED_SUBRESOURCE mappedResource;
+ result = context->Map(mStagingBuffer, 0, D3D11_MAP_WRITE, 0, &mappedResource);
+ if (FAILED(result))
+ {
+ return gl::error(GL_OUT_OF_MEMORY);
+ }
+
+ unsigned char *offsetBufferPointer = reinterpret_cast<unsigned char *>(mappedResource.pData) + offset;
+ memcpy(offsetBufferPointer, data, size);
+
+ context->Unmap(mStagingBuffer, 0);
+ }
+
+ for (auto it = mDirectBuffers.begin(); it != mDirectBuffers.end(); it++)
+ {
+ it->second->markDirty();
+ }
+
+ mSize = std::max(mSize, requiredStagingBufferSize);
+ mWriteUsageCount = 0;
+
+ mResolvedDataValid = false;
+}
+
+void BufferStorage11::copyData(BufferStorage* sourceStorage, unsigned int size,
+ unsigned int sourceOffset, unsigned int destOffset)
+{
+ BufferStorage11* source = makeBufferStorage11(sourceStorage);
+ if (source)
+ {
+ ID3D11DeviceContext *context = mRenderer->getDeviceContext();
+
+ D3D11_BOX srcBox;
+ srcBox.left = sourceOffset;
+ srcBox.right = sourceOffset + size;
+ srcBox.top = 0;
+ srcBox.bottom = 1;
+ srcBox.front = 0;
+ srcBox.back = 1;
+
+ ASSERT(mStagingBuffer && source->mStagingBuffer);
+ context->CopySubresourceRegion(mStagingBuffer, 0, destOffset, 0, 0, source->mStagingBuffer, 0, &srcBox);
+ }
+}
+
+void BufferStorage11::clear()
+{
+ mResolvedDataValid = false;
+ mSize = 0;
+}
+
+unsigned int BufferStorage11::getSize() const
+{
+ return mSize;
+}
+
+bool BufferStorage11::supportsDirectBinding() const
+{
+ return true;
+}
+
+void BufferStorage11::markBufferUsage()
+{
+ mReadUsageCount++;
+ mWriteUsageCount++;
+
+ const unsigned int usageLimit = 5;
+
+ if (mReadUsageCount > usageLimit && mResolvedData)
+ {
+ free(mResolvedData);
+ mResolvedData = NULL;
+ mResolvedDataSize = 0;
+ mResolvedDataValid = false;
+ }
+}
+
+ID3D11Buffer *BufferStorage11::getBuffer(BufferUsage usage)
+{
+ markBufferUsage();
+
+ DirectBufferStorage11 *directBuffer = NULL;
+
+ auto directBufferIt = mDirectBuffers.find(usage);
+ if (directBufferIt != mDirectBuffers.end())
+ {
+ directBuffer = directBufferIt->second;
+ }
+
+ if (directBuffer)
+ {
+ if (directBuffer->isDirty())
+ {
+ // if updateFromStagingBuffer returns true, the D3D buffer has been recreated
+ // and we should update our serial
+ if (directBuffer->updateFromStagingBuffer(mStagingBuffer, mSize, 0))
+ {
+ updateSerial();
+ }
+ }
+ }
+ else
+ {
+ // buffer is not allocated, create it
+ directBuffer = new DirectBufferStorage11(mRenderer, usage);
+ directBuffer->updateFromStagingBuffer(mStagingBuffer, mSize, 0);
+
+ mDirectBuffers.insert(std::make_pair(usage, directBuffer));
+ updateSerial();
+ }
+
+ return directBuffer->getD3DBuffer();
+}
+
+DirectBufferStorage11::DirectBufferStorage11(Renderer11 *renderer, BufferUsage usage)
+ : mRenderer(renderer),
+ mUsage(usage),
+ mDirectBuffer(NULL),
+ mBufferSize(0),
+ mDirty(false)
+{
+}
+
+DirectBufferStorage11::~DirectBufferStorage11()
+{
+ SafeRelease(mDirectBuffer);
+}
+
+BufferUsage DirectBufferStorage11::getUsage() const
+{
+ return mUsage;
+}
+
+// Returns true if it recreates the direct buffer
+bool DirectBufferStorage11::updateFromStagingBuffer(ID3D11Buffer *stagingBuffer, size_t size, size_t offset)
+{
+ ID3D11Device *device = mRenderer->getDevice();
+ ID3D11DeviceContext *context = mRenderer->getDeviceContext();
+
+ // unused for now
+ ASSERT(offset == 0);
+
+ unsigned int requiredBufferSize = size + offset;
+ bool createBuffer = !mDirectBuffer || mBufferSize < requiredBufferSize;
+
+ // (Re)initialize D3D buffer if needed
+ if (createBuffer)
+ {
+ D3D11_BUFFER_DESC bufferDesc;
+ fillBufferDesc(&bufferDesc, mRenderer, mUsage, requiredBufferSize);
+
+ ID3D11Buffer *newBuffer;
+ HRESULT result = device->CreateBuffer(&bufferDesc, NULL, &newBuffer);
+
+ if (FAILED(result))
+ {
+ return gl::error(GL_OUT_OF_MEMORY, false);
+ }
+
+ // No longer need the old buffer
+ SafeRelease(mDirectBuffer);
+ mDirectBuffer = newBuffer;
+
+ mBufferSize = bufferDesc.ByteWidth;
+ }
+
+ // Copy data via staging buffer
+ D3D11_BOX srcBox;
+ srcBox.left = 0;
+ srcBox.right = size;
+ srcBox.top = 0;
+ srcBox.bottom = 1;
+ srcBox.front = 0;
+ srcBox.back = 1;
+
+ context->CopySubresourceRegion(mDirectBuffer, 0, offset, 0, 0, stagingBuffer, 0, &srcBox);
+
+ mDirty = false;
+
+ return createBuffer;
+}
+
+void DirectBufferStorage11::fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Renderer *renderer, BufferUsage usage, unsigned int bufferSize)
+{
+ bufferDesc->ByteWidth = bufferSize;
+ bufferDesc->MiscFlags = 0;
+ bufferDesc->StructureByteStride = 0;
+
+ switch (usage)
+ {
+ case BUFFER_USAGE_VERTEX:
+ bufferDesc->Usage = D3D11_USAGE_DEFAULT;
+ bufferDesc->BindFlags = D3D11_BIND_VERTEX_BUFFER;
+ bufferDesc->CPUAccessFlags = 0;
+ break;
+
+ case BUFFER_USAGE_INDEX:
+ bufferDesc->Usage = D3D11_USAGE_DEFAULT;
+ bufferDesc->BindFlags = D3D11_BIND_INDEX_BUFFER;
+ bufferDesc->CPUAccessFlags = 0;
+ break;
+
+ default:
+ UNREACHABLE();
+ }
+}
+
+}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.h
new file mode 100644
index 0000000000..a6afafe1b4
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.h
@@ -0,0 +1,92 @@
+//
+// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// BufferStorage11.h Defines the BufferStorage11 class.
+
+#ifndef LIBGLESV2_RENDERER_BUFFERSTORAGE11_H_
+#define LIBGLESV2_RENDERER_BUFFERSTORAGE11_H_
+
+#include "libGLESv2/renderer/BufferStorage.h"
+
+namespace rx
+{
+class Renderer;
+class Renderer11;
+class DirectBufferStorage11;
+
+enum BufferUsage
+{
+ BUFFER_USAGE_VERTEX,
+ BUFFER_USAGE_INDEX,
+};
+
+class BufferStorage11 : public BufferStorage
+{
+ public:
+ explicit BufferStorage11(Renderer11 *renderer);
+ virtual ~BufferStorage11();
+
+ static BufferStorage11 *makeBufferStorage11(BufferStorage *bufferStorage);
+
+ virtual void *getData();
+ virtual void setData(const void* data, unsigned int size, unsigned int offset);
+ virtual void copyData(BufferStorage* sourceStorage, unsigned int size,
+ unsigned int sourceOffset, unsigned int destOffset);
+ virtual void clear();
+ virtual unsigned int getSize() const;
+ virtual bool supportsDirectBinding() const;
+
+ ID3D11Buffer *getBuffer(BufferUsage usage);
+
+ private:
+ Renderer11 *mRenderer;
+
+ ID3D11Buffer *mStagingBuffer;
+ unsigned int mStagingBufferSize;
+
+ std::map<BufferUsage, DirectBufferStorage11*> mDirectBuffers;
+
+ unsigned int mSize;
+
+ void *mResolvedData;
+ unsigned int mResolvedDataSize;
+ bool mResolvedDataValid;
+
+ unsigned int mReadUsageCount;
+ unsigned int mWriteUsageCount;
+
+ void markBufferUsage();
+};
+
+// Each instance of BufferStorageD3DBuffer11 is specialized for a class of D3D binding points
+// - vertex buffers
+// - index buffers
+class DirectBufferStorage11
+{
+ public:
+ DirectBufferStorage11(Renderer11 *renderer, BufferUsage usage);
+ ~DirectBufferStorage11();
+
+ BufferUsage getUsage() const;
+ bool updateFromStagingBuffer(ID3D11Buffer *stagingBuffer, size_t size, size_t offset);
+
+ ID3D11Buffer *getD3DBuffer() { return mDirectBuffer; }
+ bool isDirty() const { return mDirty; }
+ void markDirty() { mDirty = true; }
+
+ private:
+ Renderer11 *mRenderer;
+ const BufferUsage mUsage;
+ ID3D11Buffer *mDirectBuffer;
+ size_t mBufferSize;
+ bool mDirty;
+
+ static void fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Renderer *renderer, BufferUsage usage, unsigned int bufferSize);
+};
+
+}
+
+#endif // LIBGLESV2_RENDERER_BUFFERSTORAGE11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Fence11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Fence11.cpp
index 9d11c9a0fc..2a7d4d43ef 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Fence11.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Fence11.cpp
@@ -7,9 +7,9 @@
// Fence11.cpp: Defines the rx::Fence11 class which implements rx::FenceImpl.
-#include "libGLESv2/renderer/Fence11.h"
+#include "libGLESv2/renderer/d3d11/Fence11.h"
#include "libGLESv2/main.h"
-#include "libGLESv2/renderer/Renderer11.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
namespace rx
{
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Fence11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Fence11.h
index a5398bca14..a5398bca14 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Fence11.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Fence11.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Image11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Image11.cpp
index 81e9e9ecb2..5d039a35e8 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Image11.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Image11.cpp
@@ -8,15 +8,15 @@
// Image11.h: Implements the rx::Image11 class, which acts as the interface to
// the actual underlying resources of a Texture
-#include "libGLESv2/renderer/Renderer11.h"
-#include "libGLESv2/renderer/Image11.h"
-#include "libGLESv2/renderer/TextureStorage11.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
+#include "libGLESv2/renderer/d3d11/Image11.h"
+#include "libGLESv2/renderer/d3d11/TextureStorage11.h"
#include "libGLESv2/Framebuffer.h"
#include "libGLESv2/Renderbuffer.h"
#include "libGLESv2/main.h"
#include "libGLESv2/utilities.h"
-#include "libGLESv2/renderer/renderer11_utils.h"
+#include "libGLESv2/renderer/d3d11/renderer11_utils.h"
#include "libGLESv2/renderer/generatemip.h"
namespace rx
@@ -106,9 +106,15 @@ void Image11::generateMipmap(Image11 *dest, Image11 *src)
dest->markDirty();
}
+static bool FormatRequiresInitialization(DXGI_FORMAT dxgiFormat, GLenum internalFormat)
+{
+ return (dxgiFormat == DXGI_FORMAT_R8G8B8A8_UNORM && gl::GetAlphaSize(internalFormat) == 0) ||
+ (dxgiFormat == DXGI_FORMAT_R32G32B32A32_FLOAT && gl::GetAlphaSize(internalFormat) == 0);
+}
+
bool Image11::isDirty() const
{
- return (mStagingTexture && mDirty);
+ return ((mStagingTexture || FormatRequiresInitialization(mDXGIFormat, mInternalFormat)) && mDirty);
}
bool Image11::updateSurface(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
@@ -374,6 +380,27 @@ unsigned int Image11::getStagingSubresource()
return mStagingSubresource;
}
+template <typename T, size_t N>
+static void setDefaultData(ID3D11DeviceContext *deviceContext, ID3D11Texture2D *texture, UINT subresource,
+ GLsizei width, GLsizei height, const T (&defaultData)[N])
+{
+ D3D11_MAPPED_SUBRESOURCE map;
+ deviceContext->Map(texture, subresource, D3D11_MAP_WRITE, 0, &map);
+
+ unsigned char* ptr = reinterpret_cast<unsigned char*>(map.pData);
+ size_t pixelSize = sizeof(T) * N;
+
+ for (GLsizei y = 0; y < height; y++)
+ {
+ for (GLsizei x = 0; x < width; x++)
+ {
+ memcpy(ptr + (y * map.RowPitch) + (x * pixelSize), defaultData, pixelSize);
+ }
+ }
+
+ deviceContext->Unmap(texture, subresource);
+}
+
void Image11::createStagingTexture()
{
if (mStagingTexture)
@@ -421,6 +448,17 @@ void Image11::createStagingTexture()
mStagingTexture = newTexture;
mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1);
mDirty = false;
+
+ if (mDXGIFormat == DXGI_FORMAT_R8G8B8A8_UNORM && gl::GetAlphaSize(mInternalFormat) == 0)
+ {
+ unsigned char defaultPixel[4] = { 0, 0, 0, 255 };
+ setDefaultData(mRenderer->getDeviceContext(), mStagingTexture, mStagingSubresource, mWidth, mHeight, defaultPixel);
+ }
+ else if (mDXGIFormat == DXGI_FORMAT_R32G32B32A32_FLOAT && gl::GetAlphaSize(mInternalFormat) == 0)
+ {
+ float defaultPixel[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
+ setDefaultData(mRenderer->getDeviceContext(), mStagingTexture, mStagingSubresource, mWidth, mHeight, defaultPixel);
+ }
}
HRESULT Image11::map(D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map)
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Image11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Image11.h
index 11a6492dc8..11a6492dc8 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Image11.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Image11.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/IndexBuffer11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/IndexBuffer11.cpp
index 36a62adc1c..44f9976d43 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/IndexBuffer11.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/IndexBuffer11.cpp
@@ -7,8 +7,8 @@
// IndexBuffer11.cpp: Defines the D3D11 IndexBuffer implementation.
-#include "libGLESv2/renderer/IndexBuffer11.h"
-#include "libGLESv2/renderer/Renderer11.h"
+#include "libGLESv2/renderer/d3d11/IndexBuffer11.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
namespace rx
{
@@ -170,7 +170,7 @@ DXGI_FORMAT IndexBuffer11::getIndexFormat() const
{
case GL_UNSIGNED_BYTE: return DXGI_FORMAT_R16_UINT;
case GL_UNSIGNED_SHORT: return DXGI_FORMAT_R16_UINT;
- case GL_UNSIGNED_INT: return mRenderer->get32BitIndexSupport() ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT;
+ case GL_UNSIGNED_INT: return DXGI_FORMAT_R32_UINT;
default: UNREACHABLE(); return DXGI_FORMAT_UNKNOWN;
}
}
@@ -180,4 +180,4 @@ ID3D11Buffer *IndexBuffer11::getBuffer() const
return mBuffer;
}
-}
+} \ No newline at end of file
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/IndexBuffer11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/IndexBuffer11.h
index 39a61946ad..39a61946ad 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/IndexBuffer11.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/IndexBuffer11.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/InputLayoutCache.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp
index 1552f3a326..4940b8c638 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/InputLayoutCache.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp
@@ -8,10 +8,10 @@
// InputLayoutCache.cpp: Defines InputLayoutCache, a class that builds and caches
// D3D11 input layouts.
-#include "libGLESv2/renderer/InputLayoutCache.h"
-#include "libGLESv2/renderer/VertexBuffer11.h"
-#include "libGLESv2/renderer/BufferStorage11.h"
-#include "libGLESv2/renderer/ShaderExecutable11.h"
+#include "libGLESv2/renderer/d3d11/InputLayoutCache.h"
+#include "libGLESv2/renderer/d3d11/VertexBuffer11.h"
+#include "libGLESv2/renderer/d3d11/BufferStorage11.h"
+#include "libGLESv2/renderer/d3d11/ShaderExecutable11.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/Context.h"
#include "libGLESv2/renderer/VertexDataManager.h"
@@ -103,10 +103,10 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
// Record the type of the associated vertex shader vector in our key
// This will prevent mismatched vertex shaders from using the same input layout
GLint attributeSize;
- programBinary->getActiveAttribute(ilKey.elementCount, 0, NULL, &attributeSize, &ilKey.elements[ilKey.elementCount].glslElementType, NULL);
+ programBinary->getActiveAttribute(sortedSemanticIndices[i], 0, NULL, &attributeSize, &ilKey.elements[ilKey.elementCount].glslElementType, NULL);
ilKey.elements[ilKey.elementCount].desc.SemanticName = semanticName;
- ilKey.elements[ilKey.elementCount].desc.SemanticIndex = sortedSemanticIndices[i];
+ ilKey.elements[ilKey.elementCount].desc.SemanticIndex = i;
ilKey.elements[ilKey.elementCount].desc.Format = attributes[i].attribute->mArrayEnabled ? vertexBuffer->getDXGIFormat(*attributes[i].attribute) : DXGI_FORMAT_R32G32B32A32_FLOAT;
ilKey.elements[ilKey.elementCount].desc.InputSlot = i;
ilKey.elements[ilKey.elementCount].desc.AlignedByteOffset = 0;
@@ -114,7 +114,7 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
ilKey.elements[ilKey.elementCount].desc.InstanceDataStepRate = attributes[i].divisor;
ilKey.elementCount++;
- vertexBuffers[i] = bufferStorage ? bufferStorage->getBuffer() : vertexBuffer->getBuffer();
+ vertexBuffers[i] = bufferStorage ? bufferStorage->getBuffer(BUFFER_USAGE_VERTEX) : vertexBuffer->getBuffer();
vertexBufferSerials[i] = bufferStorage ? bufferStorage->getSerial() : vertexBuffer->getSerial();
vertexStrides[i] = attributes[i].stride;
vertexOffsets[i] = attributes[i].offset;
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/InputLayoutCache.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/InputLayoutCache.h
index bb1a8eebcf..bb1a8eebcf 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/InputLayoutCache.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/InputLayoutCache.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Query11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Query11.cpp
index 13210fc929..24c0330a1e 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Query11.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Query11.cpp
@@ -7,8 +7,8 @@
// Query11.cpp: Defines the rx::Query11 class which implements rx::QueryImpl.
-#include "libGLESv2/renderer/Query11.h"
-#include "libGLESv2/renderer/Renderer11.h"
+#include "libGLESv2/renderer/d3d11/Query11.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
#include "libGLESv2/main.h"
namespace rx
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Query11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Query11.h
index 0a03de77ca..0a03de77ca 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Query11.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Query11.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/RenderStateCache.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp
index fd388dfe08..a1c324cd80 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/RenderStateCache.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp
@@ -8,9 +8,12 @@
// RenderStateCache.cpp: Defines rx::RenderStateCache, a cache of Direct3D render
// state objects.
-#include "libGLESv2/renderer/RenderStateCache.h"
-#include "libGLESv2/renderer/renderer11_utils.h"
+#include "libGLESv2/renderer/d3d11/RenderStateCache.h"
+#include "libGLESv2/renderer/d3d11/renderer11_utils.h"
+#include "libGLESv2/Framebuffer.h"
+#include "libGLESv2/Renderbuffer.h"
+#include "libGLESv2/utilities.h"
#include "common/debug.h"
#include "third_party/murmurhash/MurmurHash3.h"
@@ -71,21 +74,21 @@ void RenderStateCache::clear()
mSamplerStateCache.clear();
}
-std::size_t RenderStateCache::hashBlendState(const gl::BlendState &blendState)
+std::size_t RenderStateCache::hashBlendState(const BlendStateKey &blendState)
{
static const unsigned int seed = 0xABCDEF98;
std::size_t hash = 0;
- MurmurHash3_x86_32(&blendState, sizeof(gl::BlendState), seed, &hash);
+ MurmurHash3_x86_32(&blendState, sizeof(BlendStateKey), seed, &hash);
return hash;
}
-bool RenderStateCache::compareBlendStates(const gl::BlendState &a, const gl::BlendState &b)
+bool RenderStateCache::compareBlendStates(const BlendStateKey &a, const BlendStateKey &b)
{
return memcmp(&a, &b, sizeof(gl::BlendState)) == 0;
}
-ID3D11BlendState *RenderStateCache::getBlendState(const gl::BlendState &blendState)
+ID3D11BlendState *RenderStateCache::getBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState)
{
if (!mDevice)
{
@@ -93,7 +96,36 @@ ID3D11BlendState *RenderStateCache::getBlendState(const gl::BlendState &blendSta
return NULL;
}
- BlendStateMap::iterator i = mBlendStateCache.find(blendState);
+ bool mrt = false;
+
+ BlendStateKey key = { 0 };
+ key.blendState = blendState;
+ for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
+ {
+ gl::Renderbuffer *renderBuffer = framebuffer->getColorbuffer(i);
+ if (renderBuffer)
+ {
+ if (i > 0)
+ {
+ mrt = true;
+ }
+
+ GLenum internalFormat = renderBuffer->getInternalFormat();
+ key.rtChannels[i][0] = gl::GetRedSize(internalFormat) > 0;
+ key.rtChannels[i][1] = gl::GetGreenSize(internalFormat) > 0;
+ key.rtChannels[i][2] = gl::GetBlueSize(internalFormat) > 0;;
+ key.rtChannels[i][3] = gl::GetAlphaSize(internalFormat) > 0;
+ }
+ else
+ {
+ key.rtChannels[i][0] = false;
+ key.rtChannels[i][1] = false;
+ key.rtChannels[i][2] = false;
+ key.rtChannels[i][3] = false;
+ }
+ }
+
+ BlendStateMap::iterator i = mBlendStateCache.find(key);
if (i != mBlendStateCache.end())
{
BlendStateCounterPair &state = i->second;
@@ -122,7 +154,7 @@ ID3D11BlendState *RenderStateCache::getBlendState(const gl::BlendState &blendSta
// Create a new blend state and insert it into the cache
D3D11_BLEND_DESC blendDesc = { 0 };
blendDesc.AlphaToCoverageEnable = blendState.sampleAlphaToCoverage;
- blendDesc.IndependentBlendEnable = FALSE;
+ blendDesc.IndependentBlendEnable = mrt ? TRUE : FALSE;
for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
{
@@ -140,10 +172,10 @@ ID3D11BlendState *RenderStateCache::getBlendState(const gl::BlendState &blendSta
rtBlend.BlendOpAlpha = gl_d3d11::ConvertBlendOp(blendState.blendEquationAlpha);
}
- rtBlend.RenderTargetWriteMask = gl_d3d11::ConvertColorMask(blendState.colorMaskRed,
- blendState.colorMaskGreen,
- blendState.colorMaskBlue,
- blendState.colorMaskAlpha);
+ rtBlend.RenderTargetWriteMask = gl_d3d11::ConvertColorMask(key.rtChannels[i][0] && blendState.colorMaskRed,
+ key.rtChannels[i][1] && blendState.colorMaskGreen,
+ key.rtChannels[i][2] && blendState.colorMaskBlue,
+ key.rtChannels[i][3] && blendState.colorMaskAlpha);
}
ID3D11BlendState *dx11BlendState = NULL;
@@ -154,7 +186,7 @@ ID3D11BlendState *RenderStateCache::getBlendState(const gl::BlendState &blendSta
return NULL;
}
- mBlendStateCache.insert(std::make_pair(blendState, std::make_pair(dx11BlendState, mCounter++)));
+ mBlendStateCache.insert(std::make_pair(key, std::make_pair(dx11BlendState, mCounter++)));
return dx11BlendState;
}
@@ -404,4 +436,4 @@ ID3D11SamplerState *RenderStateCache::getSamplerState(const gl::SamplerState &sa
}
}
-} \ No newline at end of file
+}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/RenderStateCache.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.h
index f8b5111de4..b4b871a4bd 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/RenderStateCache.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.h
@@ -13,6 +13,11 @@
#include "libGLESv2/angletypes.h"
#include "common/angleutils.h"
+namespace gl
+{
+class Framebuffer;
+}
+
namespace rx
{
@@ -26,7 +31,7 @@ class RenderStateCache
void clear();
// Increments refcount on the returned blend state, Release() must be called.
- ID3D11BlendState *getBlendState(const gl::BlendState &blendState);
+ ID3D11BlendState *getBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState);
ID3D11RasterizerState *getRasterizerState(const gl::RasterizerState &rasterState,
bool scissorEnabled, unsigned int depthSize);
ID3D11DepthStencilState *getDepthStencilState(const gl::DepthStencilState &dsState);
@@ -38,14 +43,19 @@ class RenderStateCache
unsigned long long mCounter;
// Blend state cache
- static std::size_t hashBlendState(const gl::BlendState &blendState);
- static bool compareBlendStates(const gl::BlendState &a, const gl::BlendState &b);
+ struct BlendStateKey
+ {
+ gl::BlendState blendState;
+ bool rtChannels[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT][4];
+ };
+ static std::size_t hashBlendState(const BlendStateKey &blendState);
+ static bool compareBlendStates(const BlendStateKey &a, const BlendStateKey &b);
static const unsigned int kMaxBlendStates;
- typedef std::size_t (*BlendStateHashFunction)(const gl::BlendState &);
- typedef bool (*BlendStateEqualityFunction)(const gl::BlendState &, const gl::BlendState &);
+ typedef std::size_t (*BlendStateHashFunction)(const BlendStateKey &);
+ typedef bool (*BlendStateEqualityFunction)(const BlendStateKey &, const BlendStateKey &);
typedef std::pair<ID3D11BlendState*, unsigned long long> BlendStateCounterPair;
- typedef std::unordered_map<gl::BlendState, BlendStateCounterPair, BlendStateHashFunction, BlendStateEqualityFunction> BlendStateMap;
+ typedef std::unordered_map<BlendStateKey, BlendStateCounterPair, BlendStateHashFunction, BlendStateEqualityFunction> BlendStateMap;
BlendStateMap mBlendStateCache;
// Rasterizer state cache
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderTarget11.cpp
index 2667cc6fa7..3707097aa4 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget11.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderTarget11.cpp
@@ -8,10 +8,10 @@
// RenderTarget11.cpp: Implements a DX11-specific wrapper for ID3D11View pointers
// retained by Renderbuffers.
-#include "libGLESv2/renderer/RenderTarget11.h"
-#include "libGLESv2/renderer/Renderer11.h"
+#include "libGLESv2/renderer/d3d11/RenderTarget11.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
-#include "libGLESv2/renderer/renderer11_utils.h"
+#include "libGLESv2/renderer/d3d11/renderer11_utils.h"
#include "libGLESv2/main.h"
namespace rx
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderTarget11.h
index 97827f2639..97827f2639 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget11.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/RenderTarget11.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.cpp
index f83e9e91ce..31d976dec4 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer11.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.cpp
@@ -12,31 +12,31 @@
#include "libGLESv2/Buffer.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/RenderBuffer.h"
-#include "libGLESv2/renderer/Renderer11.h"
-#include "libGLESv2/renderer/RenderTarget11.h"
-#include "libGLESv2/renderer/renderer11_utils.h"
-#include "libGLESv2/renderer/ShaderExecutable11.h"
-#include "libGLESv2/renderer/SwapChain11.h"
-#include "libGLESv2/renderer/Image11.h"
-#include "libGLESv2/renderer/VertexBuffer11.h"
-#include "libGLESv2/renderer/IndexBuffer11.h"
-#include "libGLESv2/renderer/BufferStorage11.h"
+#include "libGLESv2/Renderbuffer.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
+#include "libGLESv2/renderer/d3d11/RenderTarget11.h"
+#include "libGLESv2/renderer/d3d11/renderer11_utils.h"
+#include "libGLESv2/renderer/d3d11/ShaderExecutable11.h"
+#include "libGLESv2/renderer/d3d11/SwapChain11.h"
+#include "libGLESv2/renderer/d3d11/Image11.h"
+#include "libGLESv2/renderer/d3d11/VertexBuffer11.h"
+#include "libGLESv2/renderer/d3d11/IndexBuffer11.h"
+#include "libGLESv2/renderer/d3d11/BufferStorage11.h"
#include "libGLESv2/renderer/VertexDataManager.h"
#include "libGLESv2/renderer/IndexDataManager.h"
-#include "libGLESv2/renderer/TextureStorage11.h"
-#include "libGLESv2/renderer/Query11.h"
-#include "libGLESv2/renderer/Fence11.h"
+#include "libGLESv2/renderer/d3d11/TextureStorage11.h"
+#include "libGLESv2/renderer/d3d11/Query11.h"
+#include "libGLESv2/renderer/d3d11/Fence11.h"
-#include "libGLESv2/renderer/shaders/compiled/passthrough11vs.h"
-#include "libGLESv2/renderer/shaders/compiled/passthroughrgba11ps.h"
-#include "libGLESv2/renderer/shaders/compiled/passthroughrgb11ps.h"
-#include "libGLESv2/renderer/shaders/compiled/passthroughlum11ps.h"
-#include "libGLESv2/renderer/shaders/compiled/passthroughlumalpha11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthrough11vs.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha11ps.h"
-#include "libGLESv2/renderer/shaders/compiled/clear11vs.h"
-#include "libGLESv2/renderer/shaders/compiled/clearsingle11ps.h"
-#include "libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/clear11vs.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/clearsingle11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/clearmultiple11ps.h"
#include "libEGL/Display.h"
@@ -66,7 +66,7 @@ enum
MAX_TEXTURE_IMAGE_UNITS_VTF_SM4 = 16
};
-Renderer11::Renderer11(egl::Display *display, HDC hDc) : Renderer(display), mDc(hDc)
+Renderer11::Renderer11(egl::Display *display) : Renderer(display)
{
mVertexDataManager = NULL;
mIndexDataManager = NULL;
@@ -147,6 +147,7 @@ EGLint Renderer11::initialize()
return EGL_NOT_INITIALIZED;
}
+
// create the D3D11 device
ASSERT(mDevice == NULL);
PFN_D3D11_CREATE_DEVICE D3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(mD3d11Module, "D3D11CreateDevice");
@@ -160,13 +161,14 @@ EGLint Renderer11::initialize()
D3D_FEATURE_LEVEL featureLevels[] =
{
- D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
+#if !defined(ANGLE_ENABLE_D3D9)
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_1,
+#endif
};
HRESULT result = S_OK;
@@ -253,8 +255,6 @@ EGLint Renderer11::initialize()
{
D3D11_MESSAGE_ID hideMessages[] =
{
- D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETS_HAZARD,
- D3D11_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_HAZARD,
D3D11_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET
};
@@ -670,7 +670,7 @@ void Renderer11::setRasterizerState(const gl::RasterizerState &rasterState)
mForceSetRasterState = false;
}
-void Renderer11::setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
+void Renderer11::setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::Color &blendColor,
unsigned int sampleMask)
{
if (mForceSetBlendState ||
@@ -678,7 +678,7 @@ void Renderer11::setBlendState(const gl::BlendState &blendState, const gl::Color
memcmp(&blendColor, &mCurBlendColor, sizeof(gl::Color)) != 0 ||
sampleMask != mCurSampleMask)
{
- ID3D11BlendState *dxBlendState = mStateCache.getBlendState(blendState);
+ ID3D11BlendState *dxBlendState = mStateCache.getBlendState(framebuffer, blendState);
if (!dxBlendState)
{
ERR("NULL blend state returned by RenderStateCache::getBlendState, setting the default "
@@ -929,6 +929,25 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
renderTargetFormat = colorbuffer->getActualFormat();
missingColorRenderTarget = false;
}
+
+#ifdef _DEBUG
+ // Workaround for Debug SETSHADERRESOURCES_HAZARD D3D11 warnings
+ for (unsigned int vertexSerialIndex = 0; vertexSerialIndex < gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; vertexSerialIndex++)
+ {
+ if (colorbuffer->getTextureSerial() != 0 && mCurVertexTextureSerials[vertexSerialIndex] == colorbuffer->getTextureSerial())
+ {
+ setTexture(gl::SAMPLER_VERTEX, vertexSerialIndex, NULL);
+ }
+ }
+
+ for (unsigned int pixelSerialIndex = 0; pixelSerialIndex < gl::MAX_TEXTURE_IMAGE_UNITS; pixelSerialIndex++)
+ {
+ if (colorbuffer->getTextureSerial() != 0 && mCurPixelTextureSerials[pixelSerialIndex] == colorbuffer->getTextureSerial())
+ {
+ setTexture(gl::SAMPLER_PIXEL, pixelSerialIndex, NULL);
+ }
+ }
+#endif
}
}
@@ -1056,7 +1075,7 @@ GLenum Renderer11::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementAr
BufferStorage11 *storage = BufferStorage11::makeBufferStorage11(indexInfo->storage);
IndexBuffer11* indexBuffer = IndexBuffer11::makeIndexBuffer11(indexInfo->indexBuffer);
- mDeviceContext->IASetIndexBuffer(storage->getBuffer(), indexBuffer->getIndexFormat(), indexInfo->startOffset);
+ mDeviceContext->IASetIndexBuffer(storage->getBuffer(BUFFER_USAGE_INDEX), indexBuffer->getIndexFormat(), indexInfo->startOffset);
mAppliedIBSerial = 0;
mAppliedStorageIBSerial = storage->getSerial();
@@ -1118,43 +1137,6 @@ void Renderer11::drawElements(GLenum mode, GLsizei count, GLenum type, const GLv
}
}
-template <typename T>
-static void drawLineLoopIndexed(T *data, GLenum type, const GLvoid *indices, GLsizei count)
-{
- 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();
- }
-}
-
void Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer)
{
// Get the raw indices for an indexed draw
@@ -1203,71 +1185,59 @@ void Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices,
return gl::error(GL_OUT_OF_MEMORY);
}
- if (get32BitIndexSupport())
- drawLineLoopIndexed(reinterpret_cast<unsigned int*>(mappedMemory), type, indices, count);
- else
- drawLineLoopIndexed(reinterpret_cast<unsigned short*>(mappedMemory), type, indices, count);
-
+ unsigned int *data = reinterpret_cast<unsigned int*>(mappedMemory);
unsigned int indexBufferOffset = offset;
- if (!mLineLoopIB->unmapBuffer())
- {
- ERR("Could not unmap index buffer for GL_LINE_LOOP.");
- return gl::error(GL_OUT_OF_MEMORY);
- }
-
- if (mAppliedIBSerial != mLineLoopIB->getSerial() || mAppliedIBOffset != indexBufferOffset)
- {
- IndexBuffer11 *indexBuffer = IndexBuffer11::makeIndexBuffer11(mLineLoopIB->getIndexBuffer());
-
- mDeviceContext->IASetIndexBuffer(indexBuffer->getBuffer(), indexBuffer->getIndexFormat(), indexBufferOffset);
- mAppliedIBSerial = mLineLoopIB->getSerial();
- mAppliedStorageIBSerial = 0;
- mAppliedIBOffset = indexBufferOffset;
- }
-
- mDeviceContext->DrawIndexed(count + 1, 0, -minIndex);
-}
-
-template <typename T>
-static void drawTriangleFanIndexed(T *data, GLenum type, const GLvoid *indices, unsigned int numTris)
-{
switch (type)
{
case GL_NONE: // Non-indexed draw
- for (unsigned int i = 0; i < numTris; i++)
+ for (int i = 0; i < count; i++)
{
- data[i*3 + 0] = 0;
- data[i*3 + 1] = i + 1;
- data[i*3 + 2] = i + 2;
+ data[i] = i;
}
+ data[count] = 0;
break;
case GL_UNSIGNED_BYTE:
- for (unsigned int i = 0; i < numTris; i++)
+ for (int i = 0; i < count; 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];
+ data[i] = static_cast<const GLubyte*>(indices)[i];
}
+ data[count] = static_cast<const GLubyte*>(indices)[0];
break;
case GL_UNSIGNED_SHORT:
- for (unsigned int i = 0; i < numTris; i++)
+ for (int i = 0; i < count; 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];
+ data[i] = static_cast<const GLushort*>(indices)[i];
}
+ data[count] = static_cast<const GLushort*>(indices)[0];
break;
case GL_UNSIGNED_INT:
- for (unsigned int i = 0; i < numTris; i++)
+ for (int i = 0; i < count; 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];
+ 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.");
+ return gl::error(GL_OUT_OF_MEMORY);
+ }
+
+ if (mAppliedIBSerial != mLineLoopIB->getSerial() || mAppliedIBOffset != indexBufferOffset)
+ {
+ IndexBuffer11 *indexBuffer = IndexBuffer11::makeIndexBuffer11(mLineLoopIB->getIndexBuffer());
+
+ mDeviceContext->IASetIndexBuffer(indexBuffer->getBuffer(), indexBuffer->getIndexFormat(), indexBufferOffset);
+ mAppliedIBSerial = mLineLoopIB->getSerial();
+ mAppliedStorageIBSerial = 0;
+ mAppliedIBOffset = indexBufferOffset;
+ }
+
+ mDeviceContext->DrawIndexed(count + 1, 0, -minIndex);
}
void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances)
@@ -1320,13 +1290,46 @@ void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indic
return gl::error(GL_OUT_OF_MEMORY);
}
- if (get32BitIndexSupport())
- drawTriangleFanIndexed(reinterpret_cast<unsigned int*>(mappedMemory), type, indices, numTris);
- else
- drawTriangleFanIndexed(reinterpret_cast<unsigned short*>(mappedMemory), type, indices, numTris);
-
+ unsigned int *data = 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.");
@@ -1544,10 +1547,14 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra
void Renderer11::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer)
{
- bool alphaUnmasked = (gl::GetAlphaSize(mRenderTargetDesc.format) == 0) || clearParams.colorMaskAlpha;
+ gl::Renderbuffer *firstRenderbuffer = frameBuffer->getFirstColorbuffer();
+ GLenum internalFormat = firstRenderbuffer ? firstRenderbuffer->getInternalFormat() : GL_NONE;
+
bool needMaskedColorClear = (clearParams.mask & GL_COLOR_BUFFER_BIT) &&
- !(clearParams.colorMaskRed && clearParams.colorMaskGreen &&
- clearParams.colorMaskBlue && alphaUnmasked);
+ ((!clearParams.colorMaskRed && gl::GetRedSize(internalFormat) > 0) ||
+ (!clearParams.colorMaskGreen && gl::GetGreenSize(internalFormat) > 0) ||
+ (!clearParams.colorMaskBlue && gl::GetBlueSize(internalFormat) > 0) ||
+ (!clearParams.colorMaskAlpha && gl::GetAlphaSize(internalFormat) > 0));
unsigned int stencilUnmasked = 0x0;
if (frameBuffer->hasStencil())
@@ -1564,7 +1571,7 @@ void Renderer11::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *
if (needMaskedColorClear || needMaskedStencilClear || needScissoredClear)
{
- maskedClear(clearParams, frameBuffer->usingExtendedDrawBuffers());
+ maskedClear(clearParams, frameBuffer);
}
else
{
@@ -1591,10 +1598,12 @@ void Renderer11::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *
return;
}
- const float clearValues[4] = { clearParams.colorClearValue.red,
- clearParams.colorClearValue.green,
- clearParams.colorClearValue.blue,
- clearParams.colorClearValue.alpha };
+ GLenum format = renderbufferObject->getInternalFormat();
+
+ const float clearValues[4] = { (gl::GetRedSize(format) > 0) ? clearParams.colorClearValue.red : 0.0f,
+ (gl::GetGreenSize(format) > 0) ? clearParams.colorClearValue.green : 0.0f,
+ (gl::GetBlueSize(format) > 0) ? clearParams.colorClearValue.blue : 0.0f,
+ (gl::GetAlphaSize(format) > 0) ? clearParams.colorClearValue.alpha : 1.0f };
mDeviceContext->ClearRenderTargetView(framebufferRTV, clearValues);
}
}
@@ -1638,7 +1647,7 @@ void Renderer11::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *
}
}
-void Renderer11::maskedClear(const gl::ClearParameters &clearParams, bool usingExtendedDrawBuffers)
+void Renderer11::maskedClear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer)
{
HRESULT result;
@@ -1758,7 +1767,7 @@ void Renderer11::maskedClear(const gl::ClearParameters &clearParams, bool usingE
static const float blendFactors[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
static const UINT sampleMask = 0xFFFFFFFF;
- ID3D11BlendState *blendState = mStateCache.getBlendState(glBlendState);
+ ID3D11BlendState *blendState = mStateCache.getBlendState(frameBuffer, glBlendState);
// Set the vertices
D3D11_MAPPED_SUBRESOURCE mappedResource;
@@ -1785,7 +1794,7 @@ void Renderer11::maskedClear(const gl::ClearParameters &clearParams, bool usingE
mDeviceContext->RSSetState(mScissorEnabled ? mClearScissorRS : mClearNoScissorRS);
// Apply shaders
- ID3D11PixelShader *pixelShader = usingExtendedDrawBuffers ? mClearMultiplePS : mClearSinglePS;
+ ID3D11PixelShader *pixelShader = frameBuffer->usingExtendedDrawBuffers() ? mClearMultiplePS : mClearSinglePS;
mDeviceContext->IASetInputLayout(mClearIL);
mDeviceContext->VSSetShader(mClearVS, NULL, 0);
@@ -1949,13 +1958,14 @@ bool Renderer11::testDeviceResettable()
D3D_FEATURE_LEVEL featureLevels[] =
{
- D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
+#if !defined(ANGLE_ENABLE_D3D9)
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_1,
+#endif
};
ID3D11Device* dummyDevice;
@@ -2134,7 +2144,6 @@ float Renderer11::getTextureMaxAnisotropy() const
{
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
return D3D11_MAX_MAXANISOTROPY;
case D3D_FEATURE_LEVEL_10_1:
@@ -2159,7 +2168,6 @@ Range Renderer11::getViewportBounds() const
{
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
return Range(D3D11_VIEWPORT_BOUNDS_MIN, D3D11_VIEWPORT_BOUNDS_MAX);
case D3D_FEATURE_LEVEL_10_1:
@@ -2180,7 +2188,6 @@ unsigned int Renderer11::getMaxVertexTextureImageUnits() const
META_ASSERT(MAX_TEXTURE_IMAGE_UNITS_VTF_SM4 <= gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS);
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
case D3D_FEATURE_LEVEL_10_1:
case D3D_FEATURE_LEVEL_10_0:
@@ -2212,41 +2219,15 @@ unsigned int Renderer11::getReservedFragmentUniformVectors() const
unsigned int Renderer11::getMaxVertexUniformVectors() const
{
META_ASSERT(MAX_VERTEX_UNIFORM_VECTORS_D3D11 <= D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT);
- switch (mFeatureLevel)
- {
- case D3D_FEATURE_LEVEL_11_1:
- case D3D_FEATURE_LEVEL_11_0:
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0:
- return MAX_VERTEX_UNIFORM_VECTORS_D3D11;
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1:
- return MAX_VERTEX_UNIFORM_VECTORS_D3D9;
- default:
- UNIMPLEMENTED();
- return 0;
- }
+ ASSERT(mFeatureLevel >= D3D_FEATURE_LEVEL_9_1);
+ return MAX_VERTEX_UNIFORM_VECTORS_D3D11;
}
unsigned int Renderer11::getMaxFragmentUniformVectors() const
{
META_ASSERT(MAX_FRAGMENT_UNIFORM_VECTORS_D3D11 <= D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT);
- switch (mFeatureLevel)
- {
- case D3D_FEATURE_LEVEL_11_1:
- case D3D_FEATURE_LEVEL_11_0:
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0:
- return MAX_FRAGMENT_UNIFORM_VECTORS_D3D11;
- case D3D_FEATURE_LEVEL_9_3:
- return 221;
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1:
- return 29;
- default: UNREACHABLE();
- return 0;
- }
+ ASSERT(mFeatureLevel >= D3D_FEATURE_LEVEL_9_1);
+ return MAX_FRAGMENT_UNIFORM_VECTORS_D3D11;
}
unsigned int Renderer11::getMaxVaryingVectors() const
@@ -2254,11 +2235,9 @@ unsigned int Renderer11::getMaxVaryingVectors() const
META_ASSERT(gl::IMPLEMENTATION_MAX_VARYING_VECTORS == D3D11_VS_OUTPUT_REGISTER_COUNT);
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
return D3D11_VS_OUTPUT_REGISTER_COUNT;
case D3D_FEATURE_LEVEL_10_1:
- return D3D10_1_VS_OUTPUT_REGISTER_COUNT;
case D3D_FEATURE_LEVEL_10_0:
return D3D10_VS_OUTPUT_REGISTER_COUNT;
case D3D_FEATURE_LEVEL_9_3:
@@ -2274,7 +2253,6 @@ bool Renderer11::getNonPower2TextureSupport() const
{
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
case D3D_FEATURE_LEVEL_10_1:
case D3D_FEATURE_LEVEL_10_0:
@@ -2292,10 +2270,10 @@ bool Renderer11::getOcclusionQuerySupport() const
{
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
case D3D_FEATURE_LEVEL_10_1:
case D3D_FEATURE_LEVEL_10_0:
+ return true;
case D3D_FEATURE_LEVEL_9_3:
case D3D_FEATURE_LEVEL_9_2:
return true;
@@ -2310,12 +2288,11 @@ bool Renderer11::getInstancingSupport() const
{
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
case D3D_FEATURE_LEVEL_10_1:
case D3D_FEATURE_LEVEL_10_0:
case D3D_FEATURE_LEVEL_9_3:
- return true;
+ return true;
case D3D_FEATURE_LEVEL_9_2:
case D3D_FEATURE_LEVEL_9_1:
return false;
@@ -2336,10 +2313,10 @@ bool Renderer11::getDerivativeInstructionSupport() const
{
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
case D3D_FEATURE_LEVEL_10_1:
case D3D_FEATURE_LEVEL_10_0:
+ return true;
case D3D_FEATURE_LEVEL_9_3:
return true;
case D3D_FEATURE_LEVEL_9_2:
@@ -2360,13 +2337,12 @@ int Renderer11::getMajorShaderModel() const
{
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
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_9_3:
case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 4; // SM4 level 9, but treat as 4
+ case D3D_FEATURE_LEVEL_9_1: return D3D10_SHADER_MAJOR_VERSION; // 4 (level 9)
default: UNREACHABLE(); return 0;
}
}
@@ -2375,13 +2351,12 @@ int Renderer11::getMinorShaderModel() const
{
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
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_9_3:
case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 0;
+ case D3D_FEATURE_LEVEL_9_1: return D3D10_SHADER_MINOR_VERSION; // 0 (level 9)
default: UNREACHABLE(); return 0;
}
}
@@ -2402,8 +2377,7 @@ int Renderer11::getMaxViewportDimension() const
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
- case D3D_FEATURE_LEVEL_11_0:
+ 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:
@@ -2422,7 +2396,6 @@ int Renderer11::getMaxTextureWidth() const
{
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
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
@@ -2437,7 +2410,6 @@ int Renderer11::getMaxTextureHeight() const
{
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
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
@@ -2452,8 +2424,7 @@ bool Renderer11::get32BitIndexSupport() const
{
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
- case D3D_FEATURE_LEVEL_11_0:
+ 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:
@@ -2510,17 +2481,17 @@ unsigned int Renderer11::getMaxRenderTargets() const
switch (mFeatureLevel)
{
- case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
return D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; // 8
case D3D_FEATURE_LEVEL_10_1:
case D3D_FEATURE_LEVEL_10_0:
- return D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; // 8
- case D3D_FEATURE_LEVEL_9_3:
- return D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT; // 4
+ 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
+ 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.
+ return 1;
default:
UNREACHABLE();
return 1;
@@ -2703,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));
@@ -2946,7 +2917,7 @@ ShaderExecutable *Renderer11::loadExecutable(const void *function, size_t length
return executable;
}
-ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type)
+ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround)
{
std::string profile;
@@ -3124,7 +3095,7 @@ void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsi
area.width = width;
area.height = height;
- readTextureData(colorBufferTexture, subresourceIndex, area, format, type, outputPitch,
+ readTextureData(colorBufferTexture, subresourceIndex, area, colorbuffer->getActualFormat(), format, type, outputPitch,
packReverseRowOrder, packAlignment, pixels);
colorBufferTexture->Release();
@@ -3160,7 +3131,7 @@ TextureStorage *Renderer11::createTextureStorageCube(int levels, GLenum internal
return new TextureStorage11_Cube(this, levels, internalformat, usage, forceRenderable, size);
}
-static inline unsigned int getFastPixelCopySize(DXGI_FORMAT sourceFormat, GLenum destFormat, GLenum destType)
+static inline unsigned int getFastPixelCopySize(DXGI_FORMAT sourceFormat, GLenum sourceGLFormat, GLenum destFormat, GLenum destType)
{
if (sourceFormat == DXGI_FORMAT_A8_UNORM &&
destFormat == GL_ALPHA &&
@@ -3168,9 +3139,10 @@ static inline unsigned int getFastPixelCopySize(DXGI_FORMAT sourceFormat, GLenum
{
return 1;
}
- else if (sourceFormat == DXGI_FORMAT_R8G8B8A8_UNORM &&
- destFormat == GL_RGBA &&
- destType == GL_UNSIGNED_BYTE)
+ else if (sourceFormat == DXGI_FORMAT_R8G8B8A8_UNORM &&
+ sourceGLFormat == GL_RGBA8_OES &&
+ destFormat == GL_RGBA &&
+ destType == GL_UNSIGNED_BYTE)
{
return 4;
}
@@ -3180,9 +3152,10 @@ static inline unsigned int getFastPixelCopySize(DXGI_FORMAT sourceFormat, GLenum
{
return 4;
}
- else if (sourceFormat == DXGI_FORMAT_R16G16B16A16_FLOAT &&
- destFormat == GL_RGBA &&
- destType == GL_HALF_FLOAT_OES)
+ else if (sourceFormat == DXGI_FORMAT_R16G16B16A16_FLOAT &&
+ sourceGLFormat == GL_RGBA16F_EXT &&
+ destFormat == GL_RGBA &&
+ destType == GL_HALF_FLOAT_OES)
{
return 8;
}
@@ -3192,9 +3165,10 @@ static inline unsigned int getFastPixelCopySize(DXGI_FORMAT sourceFormat, GLenum
{
return 12;
}
- else if (sourceFormat == DXGI_FORMAT_R32G32B32A32_FLOAT &&
- destFormat == GL_RGBA &&
- destType == GL_FLOAT)
+ else if (sourceFormat == DXGI_FORMAT_R32G32B32A32_FLOAT &&
+ sourceGLFormat == GL_RGBA32F_EXT &&
+ destFormat == GL_RGBA &&
+ destType == GL_FLOAT)
{
return 16;
}
@@ -3204,7 +3178,7 @@ static inline unsigned int getFastPixelCopySize(DXGI_FORMAT sourceFormat, GLenum
}
}
-static inline void readPixelColor(const unsigned char *data, DXGI_FORMAT format, unsigned int x,
+static inline void readPixelColor(const unsigned char *data, DXGI_FORMAT format, GLenum glFormat, unsigned int x,
unsigned int y, int inputPitch, gl::Color *outColor)
{
switch (format)
@@ -3215,7 +3189,15 @@ static inline void readPixelColor(const unsigned char *data, DXGI_FORMAT format,
outColor->red = (rgba & 0x000000FF) * (1.0f / 0x000000FF);
outColor->green = (rgba & 0x0000FF00) * (1.0f / 0x0000FF00);
outColor->blue = (rgba & 0x00FF0000) * (1.0f / 0x00FF0000);
- outColor->alpha = (rgba & 0xFF000000) * (1.0f / 0xFF000000);
+
+ if (gl::GetAlphaSize(glFormat) > 0)
+ {
+ outColor->alpha = (rgba & 0xFF000000) * (1.0f / 0xFF000000);
+ }
+ else
+ {
+ outColor->alpha = 1.0f;
+ }
}
break;
@@ -3233,7 +3215,15 @@ static inline void readPixelColor(const unsigned char *data, DXGI_FORMAT format,
outColor->red = *(reinterpret_cast<const float*>(data + 16 * x + y * inputPitch) + 0);
outColor->green = *(reinterpret_cast<const float*>(data + 16 * x + y * inputPitch) + 1);
outColor->blue = *(reinterpret_cast<const float*>(data + 16 * x + y * inputPitch) + 2);
- outColor->alpha = *(reinterpret_cast<const float*>(data + 16 * x + y * inputPitch) + 3);
+
+ if (gl::GetAlphaSize(glFormat) > 0)
+ {
+ outColor->alpha = *(reinterpret_cast<const float*>(data + 16 * x + y * inputPitch) + 3);
+ }
+ else
+ {
+ outColor->alpha = 1.0f;
+ }
}
break;
@@ -3251,7 +3241,15 @@ static inline void readPixelColor(const unsigned char *data, DXGI_FORMAT format,
outColor->red = gl::float16ToFloat32(*(reinterpret_cast<const unsigned short*>(data + 8 * x + y * inputPitch) + 0));
outColor->green = gl::float16ToFloat32(*(reinterpret_cast<const unsigned short*>(data + 8 * x + y * inputPitch) + 1));
outColor->blue = gl::float16ToFloat32(*(reinterpret_cast<const unsigned short*>(data + 8 * x + y * inputPitch) + 2));
- outColor->alpha = gl::float16ToFloat32(*(reinterpret_cast<const unsigned short*>(data + 8 * x + y * inputPitch) + 3));
+
+ if (gl::GetAlphaSize(glFormat) > 0)
+ {
+ outColor->alpha = gl::float16ToFloat32(*(reinterpret_cast<const unsigned short*>(data + 8 * x + y * inputPitch) + 3));
+ }
+ else
+ {
+ outColor->alpha = 1.0f;
+ }
}
break;
@@ -3413,7 +3411,7 @@ static inline void writePixelColor(const gl::Color &color, GLenum format, GLenum
}
void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area,
- GLenum format, GLenum type, GLsizei outputPitch, bool packReverseRowOrder,
+ GLenum sourceFormat, GLenum format, GLenum type, GLsizei outputPitch, bool packReverseRowOrder,
GLint packAlignment, void *pixels)
{
D3D11_TEXTURE2D_DESC textureDesc;
@@ -3502,7 +3500,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
inputPitch = static_cast<int>(mapping.RowPitch);
}
- unsigned int fastPixelSize = getFastPixelCopySize(textureDesc.Format, format, type);
+ unsigned int fastPixelSize = getFastPixelCopySize(textureDesc.Format, sourceFormat, format, type);
if (fastPixelSize != 0)
{
unsigned char *dest = static_cast<unsigned char*>(pixels);
@@ -3537,7 +3535,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
{
for (int i = 0; i < area.width; i++)
{
- readPixelColor(source, textureDesc.Format, i, j, inputPitch, &pixelColor);
+ readPixelColor(source, textureDesc.Format, sourceFormat, i, j, inputPitch, &pixelColor);
writePixelColor(pixelColor, format, type, i, j, outputPitch, pixels);
}
}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.h
index 433945da7a..a8a722c56c 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer11.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/Renderer11.h
@@ -14,8 +14,8 @@
#include "libGLESv2/mathutil.h"
#include "libGLESv2/renderer/Renderer.h"
-#include "libGLESv2/renderer/RenderStateCache.h"
-#include "libGLESv2/renderer/InputLayoutCache.h"
+#include "libGLESv2/renderer/d3d11/RenderStateCache.h"
+#include "libGLESv2/renderer/d3d11/InputLayoutCache.h"
#include "libGLESv2/renderer/RenderTarget.h"
namespace gl
@@ -32,7 +32,6 @@ class StreamingIndexBufferInterface;
enum
{
- MAX_VERTEX_UNIFORM_VECTORS_D3D9 = 254,
MAX_VERTEX_UNIFORM_VECTORS_D3D11 = 1024,
MAX_FRAGMENT_UNIFORM_VECTORS_D3D11 = 1024
};
@@ -40,7 +39,7 @@ enum
class Renderer11 : public Renderer
{
public:
- Renderer11(egl::Display *display, HDC hDc);
+ Renderer11(egl::Display *display);
virtual ~Renderer11();
static Renderer11 *makeRenderer11(Renderer *renderer);
@@ -59,7 +58,7 @@ class Renderer11 : public Renderer
virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture);
virtual void setRasterizerState(const gl::RasterizerState &rasterState);
- virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
+ virtual void setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::Color &blendColor,
unsigned int sampleMask);
virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW);
@@ -156,7 +155,7 @@ class Renderer11 : public Renderer
// Shader operations
virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type);
- virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type);
+ virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround);
// Image operations
virtual Image *createImage();
@@ -178,7 +177,7 @@ class Renderer11 : public Renderer
ID3D11Device *getDevice() { return mDevice; }
ID3D11DeviceContext *getDeviceContext() { return mDeviceContext; };
IDXGIFactory *getDxgiFactory() { return mDxgiFactory; };
- D3D_FEATURE_LEVEL getFeatureLevel() const { return mFeatureLevel; }
+ D3D_FEATURE_LEVEL getFeatureLevel() { return mFeatureLevel; }
bool getRenderTargetResource(gl::Renderbuffer *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource);
void unapplyRenderTargets();
@@ -193,10 +192,10 @@ class Renderer11 : public Renderer
void drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances);
void readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area,
- GLenum format, GLenum type, GLsizei outputPitch, bool packReverseRowOrder,
+ GLenum sourceFormat, GLenum format, GLenum type, GLsizei outputPitch, bool packReverseRowOrder,
GLint packAlignment, void *pixels);
- void maskedClear(const gl::ClearParameters &clearParams, bool usingExtendedDrawBuffers);
+ void maskedClear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer);
rx::Range getViewportBounds() const;
bool blitRenderbufferRect(const gl::Rectangle &readRect, const gl::Rectangle &drawRect, RenderTarget *readRenderTarget,
@@ -205,7 +204,6 @@ class Renderer11 : public Renderer
HMODULE mD3d11Module;
HMODULE mDxgiModule;
- HDC mDc;
bool mDeviceLost;
@@ -237,7 +235,7 @@ class Renderer11 : public Renderer
unsigned int qualityLevels[D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT];
};
- typedef std::unordered_map<DXGI_FORMAT, MultisampleSupportInfo> MultisampleSupportMap;
+ typedef std::unordered_map<DXGI_FORMAT, MultisampleSupportInfo, std::hash<int> > MultisampleSupportMap;
MultisampleSupportMap mMultisampleSupportMap;
unsigned int mMaxSupportedSamples;
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/ShaderExecutable11.cpp
index e1eb560334..2e455e3af5 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable11.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/ShaderExecutable11.cpp
@@ -8,7 +8,7 @@
// ShaderExecutable11.cpp: Implements a D3D11-specific class to contain shader
// executable implementation details.
-#include "libGLESv2/renderer/ShaderExecutable11.h"
+#include "libGLESv2/renderer/d3d11/ShaderExecutable11.h"
#include "common/debug.h"
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/ShaderExecutable11.h
index c6ec1cf7d2..c6ec1cf7d2 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable11.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/ShaderExecutable11.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/SwapChain11.cpp
index 2fe15ff5b8..bd97d5cff5 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain11.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/SwapChain11.cpp
@@ -7,12 +7,13 @@
// SwapChain11.cpp: Implements a back-end specific class for the D3D11 swap chain.
-#include "libGLESv2/renderer/SwapChain11.h"
+#include "libGLESv2/renderer/d3d11/SwapChain11.h"
-#include "libGLESv2/renderer/renderer11_utils.h"
-#include "libGLESv2/renderer/Renderer11.h"
-#include "libGLESv2/renderer/shaders/compiled/passthrough11vs.h"
-#include "libGLESv2/renderer/shaders/compiled/passthroughrgba11ps.h"
+#include "libGLESv2/renderer/d3d11/renderer11_utils.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
+
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthrough11vs.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba11ps.h"
namespace rx
{
@@ -48,83 +49,19 @@ SwapChain11::~SwapChain11()
void SwapChain11::release()
{
- if (mSwapChain)
- {
- mSwapChain->Release();
- mSwapChain = NULL;
- }
-
- if (mBackBufferTexture)
- {
- mBackBufferTexture->Release();
- mBackBufferTexture = NULL;
- }
-
- if (mBackBufferRTView)
- {
- mBackBufferRTView->Release();
- mBackBufferRTView = NULL;
- }
-
- if (mOffscreenTexture)
- {
- mOffscreenTexture->Release();
- mOffscreenTexture = NULL;
- }
-
- if (mOffscreenRTView)
- {
- mOffscreenRTView->Release();
- mOffscreenRTView = NULL;
- }
-
- if (mOffscreenSRView)
- {
- mOffscreenSRView->Release();
- mOffscreenSRView = NULL;
- }
-
- if (mDepthStencilTexture)
- {
- mDepthStencilTexture->Release();
- mDepthStencilTexture = NULL;
- }
-
- if (mDepthStencilDSView)
- {
- mDepthStencilDSView->Release();
- mDepthStencilDSView = NULL;
- }
-
- if (mQuadVB)
- {
- mQuadVB->Release();
- mQuadVB = NULL;
- }
-
- if (mPassThroughSampler)
- {
- mPassThroughSampler->Release();
- mPassThroughSampler = NULL;
- }
-
- if (mPassThroughIL)
- {
- mPassThroughIL->Release();
- mPassThroughIL = NULL;
- }
-
- if (mPassThroughVS)
- {
- mPassThroughVS->Release();
- mPassThroughVS = NULL;
- }
-
- if (mPassThroughPS)
- {
- mPassThroughPS->Release();
- mPassThroughPS = NULL;
- }
+ SafeRelease(mSwapChain);
+ SafeRelease(mBackBufferTexture);
+ SafeRelease(mBackBufferRTView);
+ SafeRelease(mOffscreenTexture);
+ SafeRelease(mOffscreenRTView);
+ SafeRelease(mOffscreenSRView);
+ SafeRelease(mDepthStencilTexture);
+ SafeRelease(mDepthStencilDSView);
+ SafeRelease(mQuadVB);
+ SafeRelease(mPassThroughSampler);
+ SafeRelease(mPassThroughIL);
+ SafeRelease(mPassThroughVS);
+ SafeRelease(mPassThroughPS);
if (!mAppCreatedShareHandle)
{
@@ -134,35 +71,11 @@ void SwapChain11::release()
void SwapChain11::releaseOffscreenTexture()
{
- if (mOffscreenTexture)
- {
- mOffscreenTexture->Release();
- mOffscreenTexture = NULL;
- }
-
- if (mOffscreenRTView)
- {
- mOffscreenRTView->Release();
- mOffscreenRTView = NULL;
- }
-
- if (mOffscreenSRView)
- {
- mOffscreenSRView->Release();
- mOffscreenSRView = NULL;
- }
-
- if (mDepthStencilTexture)
- {
- mDepthStencilTexture->Release();
- mDepthStencilTexture = NULL;
- }
-
- if (mDepthStencilDSView)
- {
- mDepthStencilDSView->Release();
- mDepthStencilDSView = NULL;
- }
+ SafeRelease(mOffscreenTexture);
+ SafeRelease(mOffscreenRTView);
+ SafeRelease(mOffscreenSRView);
+ SafeRelease(mDepthStencilTexture);
+ SafeRelease(mDepthStencilDSView);
}
EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHeight)
@@ -369,23 +282,17 @@ EGLint SwapChain11::resize(EGLint backbufferWidth, EGLint backbufferHeight)
return EGL_BAD_ACCESS;
}
- if (!mSwapChain)
- reset(backbufferWidth, backbufferHeight, mSwapInterval);
+ // EGL allows creating a surface with 0x0 dimension, however, DXGI does not like 0x0 swapchains
+ if (backbufferWidth < 1 || backbufferHeight < 1)
+ {
+ return EGL_SUCCESS;
+ }
// Can only call resize if we have already created our swap buffer and resources
ASSERT(mSwapChain && mBackBufferTexture && mBackBufferRTView);
- if (mBackBufferTexture)
- {
- mBackBufferTexture->Release();
- mBackBufferTexture = NULL;
- }
-
- if (mBackBufferRTView)
- {
- mBackBufferRTView->Release();
- mBackBufferRTView = NULL;
- }
+ SafeRelease(mBackBufferTexture);
+ SafeRelease(mBackBufferRTView);
// Resize swap chain
DXGI_FORMAT backbufferDXGIFormat = gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat);
@@ -434,23 +341,9 @@ EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swap
// Release specific resources to free up memory for the new render target, while the
// old render target still exists for the purpose of preserving its contents.
- if (mSwapChain)
- {
- mSwapChain->Release();
- mSwapChain = NULL;
- }
-
- if (mBackBufferTexture)
- {
- mBackBufferTexture->Release();
- mBackBufferTexture = NULL;
- }
-
- if (mBackBufferRTView)
- {
- mBackBufferRTView->Release();
- mBackBufferRTView = NULL;
- }
+ SafeRelease(mSwapChain);
+ SafeRelease(mBackBufferTexture);
+ SafeRelease(mBackBufferRTView);
mSwapInterval = static_cast<unsigned int>(swapInterval);
if (mSwapInterval > 4)
@@ -469,25 +362,13 @@ EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swap
if (mWindow)
{
#if !defined(ANGLE_OS_WINRT)
- // We cannot create a swap chain for an HWND that is owned by a different process
- DWORD currentProcessId = GetCurrentProcessId();
- DWORD wndProcessId;
- GetWindowThreadProcessId(mWindow, &wndProcessId);
-
- if (currentProcessId != wndProcessId)
- {
- ERR("Could not create swap chain, window owned by different process");
- release();
- return EGL_BAD_NATIVE_WINDOW;
- }
-
IDXGIFactory *factory = mRenderer->getDxgiFactory();
DXGI_SWAP_CHAIN_DESC swapChainDesc = {0};
- swapChainDesc.BufferCount = 2;
swapChainDesc.BufferDesc.Format = gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat);
swapChainDesc.BufferDesc.Width = backbufferWidth;
swapChainDesc.BufferDesc.Height = backbufferHeight;
+ swapChainDesc.BufferCount = 2;
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
@@ -512,7 +393,6 @@ EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swap
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
#endif
#endif
-
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.Flags = 0;
swapChainDesc.SampleDesc.Count = 1;
@@ -535,10 +415,28 @@ EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swap
{
return EGL_CONTEXT_LOST;
}
+#if !defined(ANGLE_OS_WINRT)
else
{
- return EGL_BAD_ALLOC;
+ // We cannot create a swap chain for an HWND that is owned by a different process on some versions of
+ // windows
+ DWORD currentProcessId = GetCurrentProcessId();
+ DWORD wndProcessId;
+ GetWindowThreadProcessId(mWindow, &wndProcessId);
+
+ if (currentProcessId != wndProcessId)
+ {
+ ERR("Could not create swap chain, window owned by different process");
+ return EGL_BAD_NATIVE_WINDOW;
+ }
+ else
+ {
+ return EGL_BAD_ALLOC;
+ }
}
+#else
+ return EGL_BAD_ALLOC;
+#endif
}
result = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mBackBufferTexture);
@@ -697,7 +595,12 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
// Draw
deviceContext->Draw(4, 0);
+
+#if ANGLE_FORCE_VSYNC_OFF
+ result = mSwapChain->Present(0, 0);
+#else
result = mSwapChain->Present(mSwapInterval, 0);
+#endif
if (result == DXGI_ERROR_DEVICE_REMOVED)
{
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/SwapChain11.h
index 2a030c839d..2a030c839d 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain11.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/SwapChain11.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/TextureStorage11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp
index 32a407a988..fdfbe526ec 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/TextureStorage11.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp
@@ -8,12 +8,12 @@
// TextureStorage11.cpp: Implements the abstract rx::TextureStorage11 class and its concrete derived
// classes TextureStorage11_2D and TextureStorage11_Cube, which act as the interface to the D3D11 texture.
-#include "libGLESv2/renderer/TextureStorage11.h"
+#include "libGLESv2/renderer/d3d11/TextureStorage11.h"
-#include "libGLESv2/renderer/Renderer11.h"
-#include "libGLESv2/renderer/RenderTarget11.h"
-#include "libGLESv2/renderer/SwapChain11.h"
-#include "libGLESv2/renderer/renderer11_utils.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
+#include "libGLESv2/renderer/d3d11/RenderTarget11.h"
+#include "libGLESv2/renderer/d3d11/SwapChain11.h"
+#include "libGLESv2/renderer/d3d11/renderer11_utils.h"
#include "libGLESv2/utilities.h"
#include "libGLESv2/main.h"
@@ -229,7 +229,7 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, int levels, GLenum
mRenderTarget[i] = NULL;
}
- DXGI_FORMAT convertedFormat = gl_d3d11::ConvertTextureFormat(internalformat, Renderer11::makeRenderer11(renderer)->getFeatureLevel());
+ 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);
@@ -450,7 +450,7 @@ TextureStorage11_Cube::TextureStorage11_Cube(Renderer *renderer, int levels, GLe
}
}
- DXGI_FORMAT convertedFormat = gl_d3d11::ConvertTextureFormat(internalformat, Renderer11::makeRenderer11(renderer)->getFeatureLevel());
+ DXGI_FORMAT convertedFormat = gl_d3d11::ConvertTextureFormat(internalformat, mRenderer->getFeatureLevel());
if (d3d11::IsDepthStencilFormat(convertedFormat))
{
mTextureFormat = d3d11::GetDepthTextureFormat(convertedFormat);
@@ -549,7 +549,7 @@ RenderTarget *TextureStorage11_Cube::getRenderTarget(GLenum faceTarget, int leve
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srvDesc.Format = mShaderResourceFormat;
- srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
+ srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY; // Will be used with Texture2D sampler, not TextureCube
srvDesc.Texture2DArray.MostDetailedMip = level;
srvDesc.Texture2DArray.MipLevels = 1;
srvDesc.Texture2DArray.FirstArraySlice = faceIdx;
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/TextureStorage11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.h
index 3c5ded05b8..3c5ded05b8 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/TextureStorage11.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/VertexBuffer11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp
index 521da80c3d..6f9b4181f1 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/VertexBuffer11.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp
@@ -7,11 +7,11 @@
// VertexBuffer11.cpp: Defines the D3D11 VertexBuffer implementation.
-#include "libGLESv2/renderer/VertexBuffer11.h"
+#include "libGLESv2/renderer/d3d11/VertexBuffer11.h"
#include "libGLESv2/renderer/BufferStorage.h"
#include "libGLESv2/Buffer.h"
-#include "libGLESv2/renderer/Renderer11.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
#include "libGLESv2/Context.h"
namespace rx
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/VertexBuffer11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/VertexBuffer11.h
index eceb426e82..eceb426e82 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/VertexBuffer11.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/VertexBuffer11.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/renderer11_utils.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp
index 0624a61160..34b8259a80 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/renderer11_utils.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp
@@ -8,7 +8,7 @@
// renderer11_utils.cpp: Conversion functions and other utility routines
// specific to the D3D11 renderer.
-#include "libGLESv2/renderer/renderer11_utils.h"
+#include "libGLESv2/renderer/d3d11/renderer11_utils.h"
#include "common/debug.h"
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/renderer11_utils.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.h
index 70ad4fea2b..70ad4fea2b 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/renderer11_utils.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/shaders/Clear11.hlsl b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/shaders/Clear11.hlsl
index cb132dc99c..cb132dc99c 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/shaders/Clear11.hlsl
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/shaders/Clear11.hlsl
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/shaders/Passthrough11.hlsl b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/shaders/Passthrough11.hlsl
index 43b7801efc..43b7801efc 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/shaders/Passthrough11.hlsl
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d11/shaders/Passthrough11.hlsl
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Blit.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Blit.cpp
index 2a3ce39c63..d73df6418d 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Blit.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Blit.cpp
@@ -7,23 +7,23 @@
// Blit.cpp: Surface copy utility class.
-#include "libGLESv2/renderer/Blit.h"
+#include "libGLESv2/renderer/d3d9/Blit.h"
#include "libGLESv2/main.h"
-#include "libGLESv2/renderer/renderer9_utils.h"
-#include "libGLESv2/renderer/TextureStorage9.h"
-#include "libGLESv2/renderer/RenderTarget9.h"
-#include "libGLESv2/renderer/Renderer9.h"
+#include "libGLESv2/renderer/d3d9/renderer9_utils.h"
+#include "libGLESv2/renderer/d3d9/TextureStorage9.h"
+#include "libGLESv2/renderer/d3d9/RenderTarget9.h"
+#include "libGLESv2/renderer/d3d9/Renderer9.h"
#include "libGLESv2/Framebuffer.h"
#include "libGLESv2/Renderbuffer.h"
namespace
{
-#include "libGLESv2/renderer/shaders/compiled/standardvs.h"
-#include "libGLESv2/renderer/shaders/compiled/flipyvs.h"
-#include "libGLESv2/renderer/shaders/compiled/passthroughps.h"
-#include "libGLESv2/renderer/shaders/compiled/luminanceps.h"
-#include "libGLESv2/renderer/shaders/compiled/componentmaskps.h"
+#include "libGLESv2/renderer/d3d9/shaders/compiled/standardvs.h"
+#include "libGLESv2/renderer/d3d9/shaders/compiled/flipyvs.h"
+#include "libGLESv2/renderer/d3d9/shaders/compiled/passthroughps.h"
+#include "libGLESv2/renderer/d3d9/shaders/compiled/luminanceps.h"
+#include "libGLESv2/renderer/d3d9/shaders/compiled/componentmaskps.h"
const BYTE* const g_shaderCode[] =
{
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Blit.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Blit.h
index 3718028e66..3718028e66 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Blit.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Blit.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/BufferStorage9.cpp
index 57fd29bf80..9fdc1246f1 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/BufferStorage9.cpp
@@ -7,7 +7,7 @@
// BufferStorage9.cpp Defines the BufferStorage9 class.
-#include "libGLESv2/renderer/BufferStorage9.h"
+#include "libGLESv2/renderer/d3d9/BufferStorage9.h"
#include "common/debug.h"
namespace rx
@@ -36,7 +36,7 @@ void *BufferStorage9::getData()
return mMemory;
}
-void BufferStorage9::setData(const void* data, unsigned int size, unsigned int offset, unsigned int)
+void BufferStorage9::setData(const void* data, unsigned int size, unsigned int offset)
{
if (!mMemory || offset + size > mAllocatedSize)
{
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/BufferStorage9.h
index 82ae577e23..3e803969bc 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage9.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/BufferStorage9.h
@@ -23,7 +23,7 @@ class BufferStorage9 : public BufferStorage
static BufferStorage9 *makeBufferStorage9(BufferStorage *bufferStorage);
virtual void *getData();
- virtual void setData(const void* data, unsigned int size, unsigned int offset, unsigned int target = 0);
+ virtual void setData(const void* data, unsigned int size, unsigned int offset);
virtual void clear();
virtual unsigned int getSize() const;
virtual bool supportsDirectBinding() const;
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Fence9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Fence9.cpp
index 86064d7e52..639c37b4e4 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Fence9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Fence9.cpp
@@ -7,10 +7,10 @@
// Fence9.cpp: Defines the rx::Fence9 class.
-#include "libGLESv2/renderer/Fence9.h"
+#include "libGLESv2/renderer/d3d9/Fence9.h"
#include "libGLESv2/main.h"
-#include "libGLESv2/renderer/renderer9_utils.h"
-#include "libGLESv2/renderer/Renderer9.h"
+#include "libGLESv2/renderer/d3d9/renderer9_utils.h"
+#include "libGLESv2/renderer/d3d9/Renderer9.h"
namespace rx
{
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Fence9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Fence9.h
index 9f17641e51..9f17641e51 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Fence9.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Fence9.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Image9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Image9.cpp
index 53030b7f1e..cd12d8cc9e 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Image9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Image9.cpp
@@ -8,16 +8,16 @@
// Image9.cpp: Implements the rx::Image9 class, which acts as the interface to
// the actual underlying surfaces of a Texture.
-#include "libGLESv2/renderer/Image9.h"
+#include "libGLESv2/renderer/d3d9/Image9.h"
#include "libGLESv2/main.h"
#include "libGLESv2/Framebuffer.h"
#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/renderer/Renderer9.h"
-#include "libGLESv2/renderer/RenderTarget9.h"
-#include "libGLESv2/renderer/TextureStorage9.h"
+#include "libGLESv2/renderer/d3d9/Renderer9.h"
+#include "libGLESv2/renderer/d3d9/RenderTarget9.h"
+#include "libGLESv2/renderer/d3d9/TextureStorage9.h"
-#include "libGLESv2/renderer/renderer9_utils.h"
+#include "libGLESv2/renderer/d3d9/renderer9_utils.h"
#include "libGLESv2/renderer/generatemip.h"
namespace rx
@@ -733,4 +733,4 @@ void Image9::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
mDirty = true;
}
-} \ No newline at end of file
+}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Image9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Image9.h
index 2fbbca3124..2fbbca3124 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Image9.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Image9.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/IndexBuffer9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/IndexBuffer9.cpp
index c6d83c5dca..7cb5d13a18 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/IndexBuffer9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/IndexBuffer9.cpp
@@ -7,8 +7,8 @@
// Indexffer9.cpp: Defines the D3D9 IndexBuffer implementation.
-#include "libGLESv2/renderer/IndexBuffer9.h"
-#include "libGLESv2/renderer/Renderer9.h"
+#include "libGLESv2/renderer/d3d9/IndexBuffer9.h"
+#include "libGLESv2/renderer/d3d9/Renderer9.h"
namespace rx
{
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/IndexBuffer9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/IndexBuffer9.h
index 6801867532..6801867532 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/IndexBuffer9.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/IndexBuffer9.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Query9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Query9.cpp
index ef694267dd..72781cbc39 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Query9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Query9.cpp
@@ -8,10 +8,10 @@
// Query9.cpp: Defines the rx::Query9 class which implements rx::QueryImpl.
-#include "libGLESv2/renderer/Query9.h"
+#include "libGLESv2/renderer/d3d9/Query9.h"
#include "libGLESv2/main.h"
-#include "libGLESv2/renderer/renderer9_utils.h"
-#include "libGLESv2/renderer/Renderer9.h"
+#include "libGLESv2/renderer/d3d9/renderer9_utils.h"
+#include "libGLESv2/renderer/d3d9/Renderer9.h"
namespace rx
{
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Query9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Query9.h
index 47eef89336..47eef89336 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Query9.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Query9.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/RenderTarget9.cpp
index a84c709059..090431db99 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/RenderTarget9.cpp
@@ -8,10 +8,10 @@
// RenderTarget9.cpp: Implements a D3D9-specific wrapper for IDirect3DSurface9
// pointers retained by renderbuffers.
-#include "libGLESv2/renderer/RenderTarget9.h"
-#include "libGLESv2/renderer/Renderer9.h"
+#include "libGLESv2/renderer/d3d9/RenderTarget9.h"
+#include "libGLESv2/renderer/d3d9/Renderer9.h"
-#include "libGLESv2/renderer/renderer9_utils.h"
+#include "libGLESv2/renderer/d3d9/renderer9_utils.h"
#include "libGLESv2/main.h"
namespace rx
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/RenderTarget9.h
index faf8ad1c6d..faf8ad1c6d 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget9.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/RenderTarget9.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Renderer9.cpp
index d3f3814ae5..97a10d64bf 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Renderer9.cpp
@@ -14,19 +14,19 @@
#include "libGLESv2/Renderbuffer.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/renderer/IndexDataManager.h"
-#include "libGLESv2/renderer/Renderer9.h"
-#include "libGLESv2/renderer/renderer9_utils.h"
-#include "libGLESv2/renderer/ShaderExecutable9.h"
-#include "libGLESv2/renderer/SwapChain9.h"
-#include "libGLESv2/renderer/TextureStorage9.h"
-#include "libGLESv2/renderer/Image9.h"
-#include "libGLESv2/renderer/Blit.h"
-#include "libGLESv2/renderer/RenderTarget9.h"
-#include "libGLESv2/renderer/VertexBuffer9.h"
-#include "libGLESv2/renderer/IndexBuffer9.h"
-#include "libGLESv2/renderer/BufferStorage9.h"
-#include "libGLESv2/renderer/Query9.h"
-#include "libGLESv2/renderer/Fence9.h"
+#include "libGLESv2/renderer/d3d9/Renderer9.h"
+#include "libGLESv2/renderer/d3d9/renderer9_utils.h"
+#include "libGLESv2/renderer/d3d9/ShaderExecutable9.h"
+#include "libGLESv2/renderer/d3d9/SwapChain9.h"
+#include "libGLESv2/renderer/d3d9/TextureStorage9.h"
+#include "libGLESv2/renderer/d3d9/Image9.h"
+#include "libGLESv2/renderer/d3d9/Blit.h"
+#include "libGLESv2/renderer/d3d9/RenderTarget9.h"
+#include "libGLESv2/renderer/d3d9/VertexBuffer9.h"
+#include "libGLESv2/renderer/d3d9/IndexBuffer9.h"
+#include "libGLESv2/renderer/d3d9/BufferStorage9.h"
+#include "libGLESv2/renderer/d3d9/Query9.h"
+#include "libGLESv2/renderer/d3d9/Fence9.h"
#include "libEGL/Display.h"
@@ -121,8 +121,6 @@ Renderer9::Renderer9(egl::Display *display, HDC hDc, bool softwareDevice) : Rend
Renderer9::~Renderer9()
{
- releaseDeviceResources();
-
if (mDevice)
{
// If the device is lost, reset it first to prevent leaving the driver in an unstable state
@@ -130,22 +128,19 @@ Renderer9::~Renderer9()
{
resetDevice();
}
-
- mDevice->Release();
- mDevice = NULL;
}
- if (mDeviceEx)
- {
- mDeviceEx->Release();
- mDeviceEx = NULL;
- }
+ deinitialize();
+}
- if (mD3d9)
- {
- mD3d9->Release();
- mD3d9 = NULL;
- }
+void Renderer9::deinitialize()
+{
+ releaseDeviceResources();
+
+ SafeRelease(mDevice);
+ SafeRelease(mDeviceEx);
+ SafeRelease(mD3d9);
+ SafeRelease(mD3d9Ex);
if (mDeviceWindow)
{
@@ -153,12 +148,6 @@ Renderer9::~Renderer9()
mDeviceWindow = NULL;
}
- if (mD3d9Ex)
- {
- mD3d9Ex->Release();
- mD3d9Ex = NULL;
- }
-
if (mD3d9Module)
{
mD3d9Module = NULL;
@@ -863,7 +852,7 @@ void Renderer9::setRasterizerState(const gl::RasterizerState &rasterState)
mForceSetRasterState = false;
}
-void Renderer9::setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor, unsigned int sampleMask)
+void Renderer9::setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::Color &blendColor, unsigned int sampleMask)
{
bool blendStateChanged = mForceSetBlendState || memcmp(&blendState, &mCurBlendState, sizeof(gl::BlendState)) != 0;
bool blendColorChanged = mForceSetBlendState || memcmp(&blendColor, &mCurBlendColor, sizeof(gl::Color)) != 0;
@@ -1465,7 +1454,7 @@ void Renderer9::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvo
if (mode == GL_POINTS)
{
- drawIndexedPoints(count, type, indices, elementArrayBuffer);
+ drawIndexedPoints(count, type, indices, indexInfo.minIndex, elementArrayBuffer);
}
else if (mode == GL_LINE_LOOP)
{
@@ -1669,16 +1658,16 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices,
}
template <typename T>
-static void drawPoints(IDirect3DDevice9* device, GLsizei count, const GLvoid *indices)
+static void drawPoints(IDirect3DDevice9* device, GLsizei count, const GLvoid *indices, int minIndex)
{
for (int i = 0; i < count; i++)
{
- unsigned int indexValue = static_cast<unsigned int>(static_cast<const T*>(indices)[i]);
+ unsigned int indexValue = static_cast<unsigned int>(static_cast<const T*>(indices)[i]) - minIndex;
device->DrawPrimitive(D3DPT_POINTLIST, indexValue, 1);
}
}
-void Renderer9::drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer)
+void Renderer9::drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer)
{
// Drawing index point lists is unsupported in d3d9, fall back to a regular DrawPrimitive call
// for each individual point. This call is not expected to happen often.
@@ -1692,9 +1681,9 @@ void Renderer9::drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indi
switch (type)
{
- case GL_UNSIGNED_BYTE: drawPoints<GLubyte>(mDevice, count, indices); break;
- case GL_UNSIGNED_SHORT: drawPoints<GLushort>(mDevice, count, indices); break;
- case GL_UNSIGNED_INT: drawPoints<GLuint>(mDevice, count, indices); break;
+ case GL_UNSIGNED_BYTE: drawPoints<GLubyte>(mDevice, count, indices, minIndex); break;
+ case GL_UNSIGNED_SHORT: drawPoints<GLushort>(mDevice, count, indices, minIndex); break;
+ case GL_UNSIGNED_INT: drawPoints<GLuint>(mDevice, count, indices, minIndex); break;
default: UNREACHABLE();
}
}
@@ -2045,31 +2034,19 @@ void Renderer9::releaseDeviceResources()
mEventQueryPool.pop_back();
}
- if (mMaskedClearSavedState)
- {
- mMaskedClearSavedState->Release();
- mMaskedClearSavedState = NULL;
- }
+ SafeRelease(mMaskedClearSavedState);
mVertexShaderCache.clear();
mPixelShaderCache.clear();
- delete mBlit;
- mBlit = NULL;
-
- delete mVertexDataManager;
- mVertexDataManager = NULL;
-
- delete mIndexDataManager;
- mIndexDataManager = NULL;
-
- delete mLineLoopIB;
- mLineLoopIB = NULL;
+ SafeDelete(mBlit);
+ SafeDelete(mVertexDataManager);
+ SafeDelete(mIndexDataManager);
+ SafeDelete(mLineLoopIB);
for (int i = 0; i < NUM_NULL_COLORBUFFER_CACHE_ENTRIES; i++)
{
- delete mNullColorbufferCache[i].buffer;
- mNullColorbufferCache[i].buffer = NULL;
+ SafeDelete(mNullColorbufferCache[i].buffer);
}
}
@@ -2089,22 +2066,8 @@ bool Renderer9::isDeviceLost()
// set notify to true to broadcast a message to all contexts of the device loss
bool Renderer9::testDeviceLost(bool notify)
{
- HRESULT status = S_OK;
-
- if (mDeviceEx)
- {
- status = mDeviceEx->CheckDeviceState(NULL);
- }
- else if (mDevice)
- {
- status = mDevice->TestCooperativeLevel();
- }
- else
- {
- // No device yet, so no reset required
- }
-
- bool isLost = FAILED(status) || d3d9::isDeviceLostError(status);
+ HRESULT status = getDeviceStatusCode();
+ bool isLost = FAILED(status);
if (isLost)
{
@@ -2123,7 +2086,7 @@ bool Renderer9::testDeviceLost(bool notify)
return isLost;
}
-bool Renderer9::testDeviceResettable()
+HRESULT Renderer9::getDeviceStatusCode()
{
HRESULT status = D3D_OK;
@@ -2136,9 +2099,14 @@ bool Renderer9::testDeviceResettable()
status = mDevice->TestCooperativeLevel();
}
+ return status;
+}
+
+bool Renderer9::testDeviceResettable()
+{
// On D3D9Ex, DEVICELOST represents a hung device that needs to be restarted
// DEVICEREMOVED indicates the device has been stopped and must be recreated
- switch (status)
+ switch (getDeviceStatusCode())
{
case D3DERR_DEVICENOTRESET:
case D3DERR_DEVICEHUNG:
@@ -2146,8 +2114,8 @@ bool Renderer9::testDeviceResettable()
case D3DERR_DEVICELOST:
return (mDeviceEx != NULL);
case D3DERR_DEVICEREMOVED:
- UNIMPLEMENTED();
- return false;
+ ASSERT(mDeviceEx != NULL);
+ return isRemovedDeviceResettable();
default:
return false;
}
@@ -2161,14 +2129,26 @@ bool Renderer9::resetDevice()
HRESULT result = D3D_OK;
bool lost = testDeviceLost(false);
- int attempts = 3;
+ bool removedDevice = (getDeviceStatusCode() == D3DERR_DEVICEREMOVED);
- while (lost && attempts > 0)
+ // Device Removed is a feature which is only present with D3D9Ex
+ ASSERT(mDeviceEx != NULL || !removedDevice);
+
+ for (int attempts = 3; lost && attempts > 0; attempts--)
{
- if (mDeviceEx)
+ if (removedDevice)
+ {
+ // Device removed, which may trigger on driver reinstallation,
+ // may cause a longer wait other reset attempts before the
+ // system is ready to handle creating a new device.
+ Sleep(800);
+ lost = !resetRemovedDevice();
+ }
+ else if (mDeviceEx)
{
Sleep(500); // Give the graphics driver some CPU time
result = mDeviceEx->ResetEx(&presentParameters, NULL);
+ lost = testDeviceLost(false);
}
else
{
@@ -2183,10 +2163,8 @@ bool Renderer9::resetDevice()
{
result = mDevice->Reset(&presentParameters);
}
+ lost = testDeviceLost(false);
}
-
- lost = testDeviceLost(false);
- attempts --;
}
if (FAILED(result))
@@ -2195,13 +2173,58 @@ bool Renderer9::resetDevice()
return false;
}
- // reset device defaults
- initializeDevice();
+ if (removedDevice && lost)
+ {
+ ERR("Device lost reset failed multiple times");
+ return false;
+ }
+
+ // If the device was removed, we already finished re-initialization in resetRemovedDevice
+ if (!removedDevice)
+ {
+ // reset device defaults
+ initializeDevice();
+ }
+
mDeviceLost = false;
return true;
}
+bool Renderer9::isRemovedDeviceResettable() const
+{
+ bool success = false;
+
+#ifdef ANGLE_ENABLE_D3D9EX
+ IDirect3D9Ex *d3d9Ex = NULL;
+ typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT, IDirect3D9Ex**);
+ Direct3DCreate9ExFunc Direct3DCreate9ExPtr = reinterpret_cast<Direct3DCreate9ExFunc>(GetProcAddress(mD3d9Module, "Direct3DCreate9Ex"));
+
+ if (Direct3DCreate9ExPtr && SUCCEEDED(Direct3DCreate9ExPtr(D3D_SDK_VERSION, &d3d9Ex)))
+ {
+ D3DCAPS9 deviceCaps;
+ HRESULT result = d3d9Ex->GetDeviceCaps(mAdapter, mDeviceType, &deviceCaps);
+ success = SUCCEEDED(result);
+ }
+
+ SafeRelease(d3d9Ex);
+#else
+ ASSERT(UNREACHABLE());
+#endif
+
+ return success;
+}
+
+bool Renderer9::resetRemovedDevice()
+{
+ // From http://msdn.microsoft.com/en-us/library/windows/desktop/bb172554(v=vs.85).aspx:
+ // The hardware adapter has been removed. Application must destroy the device, do enumeration of
+ // adapters and create another Direct3D device. If application continues rendering without
+ // calling Reset, the rendering calls will succeed. Applies to Direct3D 9Ex only.
+ deinitialize();
+ return (initialize() == EGL_SUCCESS);
+}
+
DWORD Renderer9::getAdapterVendor() const
{
return mAdapterIdentifier.VendorId;
@@ -3129,7 +3152,7 @@ ShaderExecutable *Renderer9::loadExecutable(const void *function, size_t length,
return executable;
}
-ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type)
+ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround)
{
const char *profile = NULL;
@@ -3146,7 +3169,11 @@ ShaderExecutable *Renderer9::compileToExecutable(gl::InfoLog &infoLog, const cha
return NULL;
}
- ID3DBlob *binary = (ID3DBlob*)compileToBinary(infoLog, shaderHLSL, profile, ANGLE_COMPILE_OPTIMIZATION_LEVEL, true);
+ // ANGLE issue 486:
+ // Work-around a D3D9 compiler bug that presents itself when using conditional discard, by disabling optimization
+ UINT optimizationFlags = (workaround == ANGLE_D3D_WORKAROUND_SM3_OPTIMIZER ? D3DCOMPILE_SKIP_OPTIMIZATION : ANGLE_COMPILE_OPTIMIZATION_LEVEL);
+
+ ID3DBlob *binary = (ID3DBlob*)compileToBinary(infoLog, shaderHLSL, profile, optimizationFlags, true);
if (!binary)
return NULL;
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Renderer9.h
index f8932c4fd4..24fd2bdd84 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer9.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/Renderer9.h
@@ -12,7 +12,7 @@
#include "common/angleutils.h"
#include "libGLESv2/mathutil.h"
#include "libGLESv2/renderer/ShaderCache.h"
-#include "libGLESv2/renderer/VertexDeclarationCache.h"
+#include "libGLESv2/renderer/d3d9/VertexDeclarationCache.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/RenderTarget.h"
@@ -72,7 +72,7 @@ class Renderer9 : public Renderer
virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture);
virtual void setRasterizerState(const gl::RasterizerState &rasterState);
- virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
+ virtual void setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::Color &blendColor,
unsigned int sampleMask);
virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW);
@@ -170,7 +170,7 @@ class Renderer9 : public Renderer
// Shader operations
virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type);
- virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type);
+ virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type, D3DWorkaroundType workaround);
// Image operations
virtual Image *createImage();
@@ -198,12 +198,14 @@ class Renderer9 : public Renderer
private:
DISALLOW_COPY_AND_ASSIGN(Renderer9);
+ void deinitialize();
+
void applyUniformnfv(gl::Uniform *targetUniform, const GLfloat *v);
void applyUniformniv(gl::Uniform *targetUniform, const GLint *v);
void applyUniformnbv(gl::Uniform *targetUniform, const GLint *v);
void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
- void drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer);
+ void drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray);
bool copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged);
@@ -218,6 +220,10 @@ class Renderer9 : public Renderer
D3DPRESENT_PARAMETERS getDefaultPresentParameters();
void releaseDeviceResources();
+ HRESULT getDeviceStatusCode();
+ bool isRemovedDeviceResettable() const;
+ bool resetRemovedDevice();
+
UINT mAdapter;
D3DDEVTYPE mDeviceType;
bool mSoftwareDevice; // FIXME: Deprecate
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/ShaderExecutable9.cpp
index 98868a3fbf..5decf9664d 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/ShaderExecutable9.cpp
@@ -8,7 +8,7 @@
// ShaderExecutable9.cpp: Implements a D3D9-specific class to contain shader
// executable implementation details.
-#include "libGLESv2/renderer/ShaderExecutable9.h"
+#include "libGLESv2/renderer/d3d9/ShaderExecutable9.h"
#include "common/debug.h"
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/ShaderExecutable9.h
index fa1e6c2844..fa1e6c2844 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable9.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/ShaderExecutable9.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/SwapChain9.cpp
index f57a874688..dd8895d18d 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/SwapChain9.cpp
@@ -7,9 +7,9 @@
// SwapChain9.cpp: Implements a back-end specific class for the D3D9 swap chain.
-#include "libGLESv2/renderer/SwapChain9.h"
-#include "libGLESv2/renderer/renderer9_utils.h"
-#include "libGLESv2/renderer/Renderer9.h"
+#include "libGLESv2/renderer/d3d9/SwapChain9.h"
+#include "libGLESv2/renderer/d3d9/renderer9_utils.h"
+#include "libGLESv2/renderer/d3d9/Renderer9.h"
namespace rx
{
@@ -71,6 +71,9 @@ void SwapChain9::release()
static DWORD convertInterval(EGLint interval)
{
+#if ANGLE_FORCE_VSYNC_OFF
+ return D3DPRESENT_INTERVAL_IMMEDIATE;
+#else
switch(interval)
{
case 0: return D3DPRESENT_INTERVAL_IMMEDIATE;
@@ -82,6 +85,7 @@ static DWORD convertInterval(EGLint interval)
}
return D3DPRESENT_INTERVAL_DEFAULT;
+#endif
}
EGLint SwapChain9::resize(int backbufferWidth, int backbufferHeight)
@@ -137,21 +141,6 @@ EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapI
pShareHandle = &mShareHandle;
}
- // CreateTexture will fail on zero dimensions, so just release old target
- if (!backbufferWidth || !backbufferHeight)
- {
- if (mRenderTarget)
- {
- mRenderTarget->Release();
- mRenderTarget = NULL;
- }
-
- mWidth = backbufferWidth;
- mHeight = backbufferHeight;
-
- return EGL_SUCCESS;
- }
-
result = device->CreateTexture(backbufferWidth, backbufferHeight, 1, D3DUSAGE_RENDERTARGET,
gl_d3d9::ConvertRenderbufferFormat(mBackBufferFormat), D3DPOOL_DEFAULT,
&mOffscreenTexture, pShareHandle);
@@ -323,6 +312,11 @@ EGLint SwapChain9::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
device->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
+ for (UINT streamIndex = 0; streamIndex < gl::MAX_VERTEX_ATTRIBS; streamIndex++)
+ {
+ device->SetStreamSourceFreq(streamIndex, 1);
+ }
+
D3DVIEWPORT9 viewport = {0, 0, mWidth, mHeight, 0.0f, 1.0f};
device->SetViewport(&viewport);
@@ -357,17 +351,19 @@ EGLint SwapChain9::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
mRenderer->markAllStateDirty();
- if (d3d9::isDeviceLostError(result))
- {
- return EGL_CONTEXT_LOST;
- }
-
if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DRIVERINTERNALERROR)
{
return EGL_BAD_ALLOC;
}
- ASSERT(SUCCEEDED(result));
+ // http://crbug.com/313210
+ // If our swap failed, trigger a device lost event. Resetting will work around an AMD-specific
+ // device removed bug with lost contexts when reinstalling drivers.
+ if (FAILED(result))
+ {
+ mRenderer->notifyDeviceLost();
+ return EGL_CONTEXT_LOST;
+ }
return EGL_SUCCESS;
}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/SwapChain9.h
index 16a62bd86f..16a62bd86f 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain9.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/SwapChain9.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/TextureStorage9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/TextureStorage9.cpp
index 8aa74a7cba..2486a9a5bf 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/TextureStorage9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/TextureStorage9.cpp
@@ -10,11 +10,11 @@
// D3D9 texture.
#include "libGLESv2/main.h"
-#include "libGLESv2/renderer/Renderer9.h"
-#include "libGLESv2/renderer/TextureStorage9.h"
-#include "libGLESv2/renderer/SwapChain9.h"
-#include "libGLESv2/renderer/RenderTarget9.h"
-#include "libGLESv2/renderer/renderer9_utils.h"
+#include "libGLESv2/renderer/d3d9/Renderer9.h"
+#include "libGLESv2/renderer/d3d9/TextureStorage9.h"
+#include "libGLESv2/renderer/d3d9/SwapChain9.h"
+#include "libGLESv2/renderer/d3d9/RenderTarget9.h"
+#include "libGLESv2/renderer/d3d9/renderer9_utils.h"
#include "libGLESv2/Texture.h"
namespace rx
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/TextureStorage9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/TextureStorage9.h
index 86f551a131..86f551a131 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/TextureStorage9.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/TextureStorage9.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/VertexBuffer9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp
index b017b3af33..57f5bcd256 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/VertexBuffer9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp
@@ -7,11 +7,11 @@
// VertexBuffer9.cpp: Defines the D3D9 VertexBuffer implementation.
-#include "libGLESv2/renderer/VertexBuffer9.h"
-#include "libGLESv2/renderer/vertexconversion.h"
+#include "libGLESv2/renderer/d3d9/VertexBuffer9.h"
+#include "libGLESv2/renderer/d3d9/vertexconversion.h"
#include "libGLESv2/renderer/BufferStorage.h"
#include "libGLESv2/Context.h"
-#include "libGLESv2/renderer/Renderer9.h"
+#include "libGLESv2/renderer/d3d9/Renderer9.h"
#include "libGLESv2/Buffer.h"
@@ -182,7 +182,7 @@ bool VertexBuffer9::getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei
bool VertexBuffer9::requiresConversion(const gl::VertexAttribute &attrib) const
{
- return formatConverter(attrib).identity;
+ return !formatConverter(attrib).identity;
}
unsigned int VertexBuffer9::getVertexSize(const gl::VertexAttribute &attrib) const
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/VertexBuffer9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/VertexBuffer9.h
index 2f88117bda..2f88117bda 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/VertexBuffer9.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/VertexBuffer9.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/VertexDeclarationCache.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.cpp
index 9b83a6476e..e5c8a14232 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/VertexDeclarationCache.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.cpp
@@ -9,8 +9,8 @@
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/Context.h"
-#include "libGLESv2/renderer/VertexBuffer9.h"
-#include "libGLESv2/renderer/VertexDeclarationCache.h"
+#include "libGLESv2/renderer/d3d9/VertexBuffer9.h"
+#include "libGLESv2/renderer/d3d9/VertexDeclarationCache.h"
namespace rx
{
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/VertexDeclarationCache.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.h
index 3fc024a9ba..3fc024a9ba 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/VertexDeclarationCache.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/renderer9_utils.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/renderer9_utils.cpp
index da75d465e3..b7f2ffb1d9 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/renderer9_utils.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/renderer9_utils.cpp
@@ -8,7 +8,7 @@
// renderer9_utils.cpp: Conversion functions and other utility routines
// specific to the D3D9 renderer.
-#include "libGLESv2/renderer/renderer9_utils.h"
+#include "libGLESv2/renderer/d3d9/renderer9_utils.h"
#include "libGLESv2/mathutil.h"
#include "libGLESv2/Context.h"
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/renderer9_utils.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/renderer9_utils.h
index bf6cdf1ea6..bf6cdf1ea6 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/renderer9_utils.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/renderer9_utils.h
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/shaders/Blit.ps b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/shaders/Blit.ps
index dcb3bd0e76..dcb3bd0e76 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/shaders/Blit.ps
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/shaders/Blit.ps
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/shaders/Blit.vs b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/shaders/Blit.vs
index 3a36980b93..3a36980b93 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/shaders/Blit.vs
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/shaders/Blit.vs
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/vertexconversion.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/vertexconversion.h
index 590b9d48a3..590b9d48a3 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/vertexconversion.h
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d9/vertexconversion.h