diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-05-18 15:16:30 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-05-26 15:11:40 +0200 |
commit | 752497910b67b2a1a80560840ca44548d8893434 (patch) | |
tree | 541501c9abfd97c3d2fa450d2e6abb60582c4420 /src/3rdparty/angle/src/libANGLE/renderer/d3d/IndexDataManager.cpp | |
parent | 7db527dbdd911c79f31425d099d1fc9c63e42453 (diff) |
Remove ANGLE
This marks the end of EGL and OpenGL ES support on Windows.
The concepts of -opengl dynamic, -opengl desktop, QT_OPENGL=software,
etc. remain unchanged, with the exception of the disapperance of
everything ANGLE related.
CMake builds now work identically to qmake on Windows: they default to
'dynamic' OpenGL on Windows, unless -DINPUT_opengl=desktop is specified.
On Windows, Qt 6 is expected to default to the "dynamic" OpenGL model by
default, just like Qt 5.15. This can be changed by switching to "desktop"
OpenGL, which will link to opengl32 (publicly, so other libs and applications
will do so as well) and disallows using another OpenGL DLL.
The "dynamic" mode is essential still because the fallback to a software
rasterizer, such as the opengl32sw.dll we ship with the Qt packages,
has to to work exactly like in Qt 5, the removal of ANGLE does not
change this concept in any way (except of course that the middle option
of using ANGLE is now gone)
When it comes to the windows plugin's OpenGL blacklist feature, it works
like before and accepts the ANGLE/D3D related keywords. They will
then be ignored. Similarly, requesting QT_OPENGL=angle is ignored (but
will show a warning).
The D3D11 and DXGI configure time tests are removed: Qt 5.14 already
depends on D3D 11.1 and DXGI 1.3 headers being available unconditionally
on Win32 (in QRhi's D3D11 backend). No need to test for these.
[ChangeLog][Windows] ANGLE is no longer included with Qt. Dynamic OpenGL
builds work like before but ANGLE is no longer an option. OpenGL proper
or an alternative opengl32 implementation are the two remaining options
now. Attempting to set QT_OPENGL=angle or Qt::AA_UseOpenGLES will have
no effect on Windows.
Fixes: QTBUG-79103
Change-Id: Ia404e0d07f3fe191b27434d863c81180112ecb3b
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/renderer/d3d/IndexDataManager.cpp')
-rw-r--r-- | src/3rdparty/angle/src/libANGLE/renderer/d3d/IndexDataManager.cpp | 320 |
1 files changed, 0 insertions, 320 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/IndexDataManager.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/IndexDataManager.cpp deleted file mode 100644 index e974097b45..0000000000 --- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/IndexDataManager.cpp +++ /dev/null @@ -1,320 +0,0 @@ -// -// Copyright (c) 2002-2014 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. -// - -// IndexDataManager.cpp: Defines the IndexDataManager, a class that -// runs the Buffer translation process for index buffers. - -#include "libANGLE/renderer/d3d/IndexDataManager.h" - -#include "common/utilities.h" -#include "libANGLE/Buffer.h" -#include "libANGLE/Context.h" -#include "libANGLE/VertexArray.h" -#include "libANGLE/formatutils.h" -#include "libANGLE/renderer/d3d/BufferD3D.h" -#include "libANGLE/renderer/d3d/IndexBuffer.h" - -namespace rx -{ - -namespace -{ - -template <typename InputT, typename DestT> -void ConvertIndexArray(const void *input, - GLenum sourceType, - void *output, - GLenum destinationType, - GLsizei count, - bool usePrimitiveRestartFixedIndex) -{ - const InputT *in = static_cast<const InputT *>(input); - DestT *out = static_cast<DestT *>(output); - - if (usePrimitiveRestartFixedIndex) - { - InputT srcRestartIndex = static_cast<InputT>(gl::GetPrimitiveRestartIndex(sourceType)); - DestT destRestartIndex = static_cast<DestT>(gl::GetPrimitiveRestartIndex(destinationType)); - for (GLsizei i = 0; i < count; i++) - { - out[i] = (in[i] == srcRestartIndex ? destRestartIndex : static_cast<DestT>(in[i])); - } - } - else - { - for (GLsizei i = 0; i < count; i++) - { - out[i] = static_cast<DestT>(in[i]); - } - } -} - -void ConvertIndices(GLenum sourceType, - GLenum destinationType, - const void *input, - GLsizei count, - void *output, - bool usePrimitiveRestartFixedIndex) -{ - if (sourceType == destinationType) - { - const gl::Type &typeInfo = gl::GetTypeInfo(destinationType); - memcpy(output, input, count * typeInfo.bytes); - return; - } - - if (sourceType == GL_UNSIGNED_BYTE) - { - ASSERT(destinationType == GL_UNSIGNED_SHORT); - ConvertIndexArray<GLubyte, GLushort>(input, sourceType, output, destinationType, count, - usePrimitiveRestartFixedIndex); - } - else if (sourceType == GL_UNSIGNED_SHORT) - { - ASSERT(destinationType == GL_UNSIGNED_INT); - ConvertIndexArray<GLushort, GLuint>(input, sourceType, output, destinationType, count, - usePrimitiveRestartFixedIndex); - } - else - UNREACHABLE(); -} - -gl::Error StreamInIndexBuffer(IndexBufferInterface *buffer, - const void *data, - unsigned int count, - GLenum srcType, - GLenum dstType, - bool usePrimitiveRestartFixedIndex, - unsigned int *offset) -{ - const gl::Type &dstTypeInfo = gl::GetTypeInfo(dstType); - - if (count > (std::numeric_limits<unsigned int>::max() >> dstTypeInfo.bytesShift)) - { - return gl::OutOfMemory() << "Reserving " << count << " indices of " << dstTypeInfo.bytes - << " bytes each exceeds the maximum buffer size."; - } - - unsigned int bufferSizeRequired = count << dstTypeInfo.bytesShift; - ANGLE_TRY(buffer->reserveBufferSpace(bufferSizeRequired, dstType)); - - void *output = nullptr; - ANGLE_TRY(buffer->mapBuffer(bufferSizeRequired, &output, offset)); - - ConvertIndices(srcType, dstType, data, count, output, usePrimitiveRestartFixedIndex); - - ANGLE_TRY(buffer->unmapBuffer()); - return gl::NoError(); -} - -unsigned int ElementTypeSize(GLenum elementType) -{ - switch (elementType) - { - case GL_UNSIGNED_BYTE: - return sizeof(GLubyte); - case GL_UNSIGNED_SHORT: - return sizeof(GLushort); - case GL_UNSIGNED_INT: - return sizeof(GLuint); - default: - UNREACHABLE(); - return 0; - } -} - -} // anonymous namespace - -bool IsOffsetAligned(GLenum elementType, unsigned int offset) -{ - return (offset % ElementTypeSize(elementType) == 0); -} - -// IndexDataManager implementation. -IndexDataManager::IndexDataManager(BufferFactoryD3D *factory) - : mFactory(factory), mStreamingBufferShort(), mStreamingBufferInt() -{ -} - -IndexDataManager::~IndexDataManager() -{ -} - -void IndexDataManager::deinitialize() -{ - mStreamingBufferShort.reset(); - mStreamingBufferInt.reset(); -} - -// This function translates a GL-style indices into DX-style indices, with their description -// returned in translated. -// GL can specify vertex data in immediate mode (pointer to CPU array of indices), which is not -// possible in DX and requires streaming (Case 1). If the GL indices are specified with a buffer -// (Case 2), in a format supported by DX (subcase a) then all is good. -// When we have a buffer with an unsupported format (subcase b) then we need to do some translation: -// we will start by falling back to streaming, and after a while will start using a static -// translated copy of the index buffer. -gl::Error IndexDataManager::prepareIndexData(const gl::Context *context, - GLenum srcType, - GLenum dstType, - GLsizei count, - gl::Buffer *glBuffer, - const void *indices, - TranslatedIndexData *translated) -{ - const gl::Type &srcTypeInfo = gl::GetTypeInfo(srcType); - const gl::Type &dstTypeInfo = gl::GetTypeInfo(dstType); - - BufferD3D *buffer = glBuffer ? GetImplAs<BufferD3D>(glBuffer) : nullptr; - - translated->indexType = dstType; - translated->srcIndexData.srcBuffer = buffer; - translated->srcIndexData.srcIndices = indices; - translated->srcIndexData.srcIndexType = srcType; - translated->srcIndexData.srcCount = count; - - // Context can be nullptr in perf tests. - bool primitiveRestartFixedIndexEnabled = - context ? context->getGLState().isPrimitiveRestartEnabled() : false; - - // Case 1: the indices are passed by pointer, which forces the streaming of index data - if (glBuffer == nullptr) - { - translated->storage = nullptr; - return streamIndexData(indices, count, srcType, dstType, primitiveRestartFixedIndexEnabled, - translated); - } - - // Case 2: the indices are already in a buffer - unsigned int offset = static_cast<unsigned int>(reinterpret_cast<uintptr_t>(indices)); - ASSERT(srcTypeInfo.bytes * static_cast<unsigned int>(count) + offset <= buffer->getSize()); - - bool offsetAligned = IsOffsetAligned(srcType, offset); - - // Case 2a: the buffer can be used directly - if (offsetAligned && buffer->supportsDirectBinding() && dstType == srcType) - { - translated->storage = buffer; - translated->indexBuffer = nullptr; - translated->serial = buffer->getSerial(); - translated->startIndex = (offset >> srcTypeInfo.bytesShift); - translated->startOffset = offset; - return gl::NoError(); - } - - translated->storage = nullptr; - - // Case 2b: use a static translated copy or fall back to streaming - StaticIndexBufferInterface *staticBuffer = buffer->getStaticIndexBuffer(); - - bool staticBufferInitialized = staticBuffer && staticBuffer->getBufferSize() != 0; - bool staticBufferUsable = - staticBuffer && offsetAligned && staticBuffer->getIndexType() == dstType; - - if (staticBufferInitialized && !staticBufferUsable) - { - buffer->invalidateStaticData(context); - staticBuffer = nullptr; - } - - if (staticBuffer == nullptr || !offsetAligned) - { - const uint8_t *bufferData = nullptr; - ANGLE_TRY(buffer->getData(context, &bufferData)); - ASSERT(bufferData != nullptr); - - ANGLE_TRY(streamIndexData(bufferData + offset, count, srcType, dstType, - primitiveRestartFixedIndexEnabled, translated)); - buffer->promoteStaticUsage(context, count << srcTypeInfo.bytesShift); - } - else - { - if (!staticBufferInitialized) - { - const uint8_t *bufferData = nullptr; - ANGLE_TRY(buffer->getData(context, &bufferData)); - ASSERT(bufferData != nullptr); - - unsigned int convertCount = - static_cast<unsigned int>(buffer->getSize()) >> srcTypeInfo.bytesShift; - ANGLE_TRY(StreamInIndexBuffer(staticBuffer, bufferData, convertCount, srcType, dstType, - primitiveRestartFixedIndexEnabled, nullptr)); - } - ASSERT(offsetAligned && staticBuffer->getIndexType() == dstType); - - translated->indexBuffer = staticBuffer->getIndexBuffer(); - translated->serial = staticBuffer->getSerial(); - translated->startIndex = (offset >> srcTypeInfo.bytesShift); - translated->startOffset = (offset >> srcTypeInfo.bytesShift) << dstTypeInfo.bytesShift; - } - - return gl::NoError(); -} - -gl::Error IndexDataManager::streamIndexData(const void *data, - unsigned int count, - GLenum srcType, - GLenum dstType, - bool usePrimitiveRestartFixedIndex, - TranslatedIndexData *translated) -{ - const gl::Type &dstTypeInfo = gl::GetTypeInfo(dstType); - - IndexBufferInterface *indexBuffer = nullptr; - ANGLE_TRY(getStreamingIndexBuffer(dstType, &indexBuffer)); - ASSERT(indexBuffer != nullptr); - - unsigned int offset; - ANGLE_TRY(StreamInIndexBuffer(indexBuffer, data, count, srcType, dstType, - usePrimitiveRestartFixedIndex, &offset)); - - translated->indexBuffer = indexBuffer->getIndexBuffer(); - translated->serial = indexBuffer->getSerial(); - translated->startIndex = (offset >> dstTypeInfo.bytesShift); - translated->startOffset = offset; - - return gl::NoError(); -} - -gl::Error IndexDataManager::getStreamingIndexBuffer(GLenum destinationIndexType, - IndexBufferInterface **outBuffer) -{ - ASSERT(outBuffer); - ASSERT(destinationIndexType == GL_UNSIGNED_SHORT || destinationIndexType == GL_UNSIGNED_INT); - - auto &streamingBuffer = - (destinationIndexType == GL_UNSIGNED_INT) ? mStreamingBufferInt : mStreamingBufferShort; - - if (!streamingBuffer) - { - StreamingBuffer newBuffer(new StreamingIndexBufferInterface(mFactory)); - ANGLE_TRY(newBuffer->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, destinationIndexType)); - streamingBuffer = std::move(newBuffer); - } - - *outBuffer = streamingBuffer.get(); - return gl::NoError(); -} - -GLenum GetIndexTranslationDestType(GLenum srcType, - const gl::HasIndexRange &lazyIndexRange, - bool usePrimitiveRestartWorkaround) -{ - // Avoid D3D11's primitive restart index value - // see http://msdn.microsoft.com/en-us/library/windows/desktop/bb205124(v=vs.85).aspx - if (usePrimitiveRestartWorkaround) - { - const gl::IndexRange &indexRange = lazyIndexRange.getIndexRange().value(); - if (indexRange.end == gl::GetPrimitiveRestartIndex(srcType)) - { - return GL_UNSIGNED_INT; - } - } - - return (srcType == GL_UNSIGNED_INT) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT; -} - -} // namespace rx |