diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-07-11 23:29:50 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-07-11 23:31:02 +0200 |
commit | 70dd5e7c66b1fe3f82e5b4db2406050baba15f05 (patch) | |
tree | 3f012200ef3c934f33db1a4ef2b790fae3141860 /gfx/angle/src/libANGLE | |
parent | 3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff) | |
parent | 8481fa25d246f1968d0a254ee3c6cdd82c60781a (diff) | |
download | UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.gz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.lz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.xz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.zip |
Merge branch 'ANGLE-rollback'
This resolves #624
Note: Cherry-picked some fixes on top of the ANGLE version that we want to keep.
Diffstat (limited to 'gfx/angle/src/libANGLE')
271 files changed, 9598 insertions, 21563 deletions
diff --git a/gfx/angle/src/libANGLE/Buffer.cpp b/gfx/angle/src/libANGLE/Buffer.cpp index c69d1c671..3523b32ac 100755 --- a/gfx/angle/src/libANGLE/Buffer.cpp +++ b/gfx/angle/src/libANGLE/Buffer.cpp @@ -10,95 +10,99 @@ #include "libANGLE/Buffer.h" #include "libANGLE/renderer/BufferImpl.h" -#include "libANGLE/renderer/GLImplFactory.h" namespace gl { -BufferState::BufferState() - : mLabel(), +Buffer::Buffer(rx::BufferImpl *impl, GLuint id) + : RefCountObject(id), + mBuffer(impl), + mLabel(), mUsage(GL_STATIC_DRAW), mSize(0), mAccessFlags(0), mAccess(GL_WRITE_ONLY_OES), mMapped(GL_FALSE), - mMapPointer(nullptr), + mMapPointer(NULL), mMapOffset(0), mMapLength(0) { } -BufferState::~BufferState() -{ -} - -Buffer::Buffer(rx::GLImplFactory *factory, GLuint id) - : RefCountObject(id), mImpl(factory->createBuffer(mState)) -{ -} - Buffer::~Buffer() { - SafeDelete(mImpl); + SafeDelete(mBuffer); } void Buffer::setLabel(const std::string &label) { - mState.mLabel = label; + mLabel = label; } const std::string &Buffer::getLabel() const { - return mState.mLabel; + return mLabel; } -Error Buffer::bufferData(GLenum target, const void *data, GLsizeiptr size, GLenum usage) +Error Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage) { - ANGLE_TRY(mImpl->setData(target, data, size, usage)); + gl::Error error = mBuffer->setData(data, size, usage); + if (error.isError()) + { + return error; + } mIndexRangeCache.clear(); - mState.mUsage = usage; - mState.mSize = size; + mUsage = usage; + mSize = size; - return NoError(); + return error; } -Error Buffer::bufferSubData(GLenum target, const void *data, GLsizeiptr size, GLintptr offset) +Error Buffer::bufferSubData(const void *data, GLsizeiptr size, GLintptr offset) { - ANGLE_TRY(mImpl->setSubData(target, data, size, offset)); + gl::Error error = mBuffer->setSubData(data, size, offset); + if (error.isError()) + { + return error; + } mIndexRangeCache.invalidateRange(static_cast<unsigned int>(offset), static_cast<unsigned int>(size)); - return NoError(); + return error; } Error Buffer::copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) { - ANGLE_TRY(mImpl->copySubData(source->getImplementation(), sourceOffset, destOffset, size)); + gl::Error error = mBuffer->copySubData(source->getImplementation(), sourceOffset, destOffset, size); + if (error.isError()) + { + return error; + } mIndexRangeCache.invalidateRange(static_cast<unsigned int>(destOffset), static_cast<unsigned int>(size)); - return NoError(); + return error; } Error Buffer::map(GLenum access) { - ASSERT(!mState.mMapped); + ASSERT(!mMapped); - Error error = mImpl->map(access, &mState.mMapPointer); + Error error = mBuffer->map(access, &mMapPointer); if (error.isError()) { - mState.mMapPointer = nullptr; + mMapPointer = NULL; return error; } ASSERT(access == GL_WRITE_ONLY_OES); - mState.mMapped = GL_TRUE; - mState.mMapOffset = 0; - mState.mMapLength = mState.mSize; - mState.mAccess = access; - mState.mAccessFlags = GL_MAP_WRITE_BIT; + mMapped = GL_TRUE; + mMapOffset = 0; + mMapLength = mSize; + mAccess = access; + mAccessFlags = GL_MAP_WRITE_BIT; mIndexRangeCache.clear(); return error; @@ -106,21 +110,21 @@ Error Buffer::map(GLenum access) Error Buffer::mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access) { - ASSERT(!mState.mMapped); - ASSERT(offset + length <= mState.mSize); + ASSERT(!mMapped); + ASSERT(offset + length <= mSize); - Error error = mImpl->mapRange(offset, length, access, &mState.mMapPointer); + Error error = mBuffer->mapRange(offset, length, access, &mMapPointer); if (error.isError()) { - mState.mMapPointer = nullptr; + mMapPointer = NULL; return error; } - mState.mMapped = GL_TRUE; - mState.mMapOffset = static_cast<GLint64>(offset); - mState.mMapLength = static_cast<GLint64>(length); - mState.mAccess = GL_WRITE_ONLY_OES; - mState.mAccessFlags = access; + mMapped = GL_TRUE; + mMapOffset = static_cast<GLint64>(offset); + mMapLength = static_cast<GLint64>(length); + mAccess = GL_WRITE_ONLY_OES; + mAccessFlags = access; // The OES_mapbuffer extension states that GL_WRITE_ONLY_OES is the only valid // value for GL_BUFFER_ACCESS_OES because it was written against ES2. Since there is @@ -137,21 +141,21 @@ Error Buffer::mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access) Error Buffer::unmap(GLboolean *result) { - ASSERT(mState.mMapped); + ASSERT(mMapped); - Error error = mImpl->unmap(result); + Error error = mBuffer->unmap(result); if (error.isError()) { *result = GL_FALSE; return error; } - mState.mMapped = GL_FALSE; - mState.mMapPointer = nullptr; - mState.mMapOffset = 0; - mState.mMapLength = 0; - mState.mAccess = GL_WRITE_ONLY_OES; - mState.mAccessFlags = 0; + mMapped = GL_FALSE; + mMapPointer = NULL; + mMapOffset = 0; + mMapLength = 0; + mAccess = GL_WRITE_ONLY_OES; + mAccessFlags = 0; return error; } @@ -174,14 +178,18 @@ Error Buffer::getIndexRange(GLenum type, { if (mIndexRangeCache.findRange(type, offset, count, primitiveRestartEnabled, outRange)) { - return NoError(); + return gl::Error(GL_NO_ERROR); } - ANGLE_TRY(mImpl->getIndexRange(type, offset, count, primitiveRestartEnabled, outRange)); + Error error = mBuffer->getIndexRange(type, offset, count, primitiveRestartEnabled, outRange); + if (error.isError()) + { + return error; + } mIndexRangeCache.addRange(type, offset, count, primitiveRestartEnabled, *outRange); - return NoError(); + return Error(GL_NO_ERROR); } } // namespace gl diff --git a/gfx/angle/src/libANGLE/Buffer.h b/gfx/angle/src/libANGLE/Buffer.h index dba4d5adf..6c951ef58 100755 --- a/gfx/angle/src/libANGLE/Buffer.h +++ b/gfx/angle/src/libANGLE/Buffer.h @@ -20,20 +20,35 @@ namespace rx { class BufferImpl; -class GLImplFactory; }; namespace gl { -class Buffer; -class BufferState final : angle::NonCopyable +class Buffer final : public RefCountObject, public LabeledObject { public: - BufferState(); - ~BufferState(); + Buffer(rx::BufferImpl *impl, GLuint id); + virtual ~Buffer(); + + void setLabel(const std::string &label) override; + const std::string &getLabel() const override; + + Error bufferData(const void *data, GLsizeiptr size, GLenum usage); + Error bufferSubData(const void *data, GLsizeiptr size, GLintptr offset); + Error copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size); + Error map(GLenum access); + Error mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access); + Error unmap(GLboolean *result); + + void onTransformFeedback(); + void onPixelUnpack(); - const std::string &getLabel(); + Error getIndexRange(GLenum type, + size_t offset, + size_t count, + bool primitiveRestartEnabled, + IndexRange *outRange) const; GLenum getUsage() const { return mUsage; } GLbitfield getAccessFlags() const { return mAccessFlags; } @@ -44,8 +59,10 @@ class BufferState final : angle::NonCopyable GLint64 getMapLength() const { return mMapLength; } GLint64 getSize() const { return mSize; } + rx::BufferImpl *getImplementation() const { return mBuffer; } + private: - friend class Buffer; + rx::BufferImpl *mBuffer; std::string mLabel; @@ -57,47 +74,6 @@ class BufferState final : angle::NonCopyable GLvoid *mMapPointer; GLint64 mMapOffset; GLint64 mMapLength; -}; - -class Buffer final : public RefCountObject, public LabeledObject -{ - public: - Buffer(rx::GLImplFactory *factory, GLuint id); - ~Buffer() override; - - void setLabel(const std::string &label) override; - const std::string &getLabel() const override; - - Error bufferData(GLenum target, const void *data, GLsizeiptr size, GLenum usage); - Error bufferSubData(GLenum target, const void *data, GLsizeiptr size, GLintptr offset); - Error copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size); - Error map(GLenum access); - Error mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access); - Error unmap(GLboolean *result); - - void onTransformFeedback(); - void onPixelUnpack(); - - Error getIndexRange(GLenum type, - size_t offset, - size_t count, - bool primitiveRestartEnabled, - IndexRange *outRange) const; - - GLenum getUsage() const { return mState.mUsage; } - GLbitfield getAccessFlags() const { return mState.mAccessFlags; } - GLenum getAccess() const { return mState.mAccess; } - GLboolean isMapped() const { return mState.mMapped; } - GLvoid *getMapPointer() const { return mState.mMapPointer; } - GLint64 getMapOffset() const { return mState.mMapOffset; } - GLint64 getMapLength() const { return mState.mMapLength; } - GLint64 getSize() const { return mState.mSize; } - - rx::BufferImpl *getImplementation() const { return mImpl; } - - private: - BufferState mState; - rx::BufferImpl *mImpl; mutable IndexRangeCache mIndexRangeCache; }; diff --git a/gfx/angle/src/libANGLE/Caps.cpp b/gfx/angle/src/libANGLE/Caps.cpp index d8e486d3d..985d79867 100755 --- a/gfx/angle/src/libANGLE/Caps.cpp +++ b/gfx/angle/src/libANGLE/Caps.cpp @@ -70,11 +70,6 @@ void TextureCapsMap::remove(GLenum internalFormat) } } -void TextureCapsMap::clear() -{ - mCapsMap.clear(); -} - const TextureCaps &TextureCapsMap::get(GLenum internalFormat) const { static TextureCaps defaultUnsupportedTexture; @@ -166,12 +161,6 @@ Extensions::Extensions() bindUniformLocation(false), syncQuery(false), copyTexture(false), - copyCompressedTexture(false), - webglCompatibility(false), - bindGeneratesResource(false), - robustClientMemory(false), - textureSRGBDecode(false), - sRGBWriteControl(false), colorBufferFloat(false), multisampleCompatibility(false), framebufferMixedSamples(false), @@ -184,13 +173,78 @@ std::vector<std::string> Extensions::getStrings() const { std::vector<std::string> extensionStrings; - for (const auto &extensionInfo : GetExtensionInfoMap()) - { - if (this->*(extensionInfo.second.ExtensionsMember)) - { - extensionStrings.push_back(extensionInfo.first); - } - } + // clang-format off + // | Extension name | Supported flag | Output vector | + InsertExtensionString("GL_OES_element_index_uint", elementIndexUint, &extensionStrings); + InsertExtensionString("GL_OES_packed_depth_stencil", packedDepthStencil, &extensionStrings); + InsertExtensionString("GL_OES_get_program_binary", getProgramBinary, &extensionStrings); + InsertExtensionString("GL_OES_rgb8_rgba8", rgb8rgba8, &extensionStrings); + InsertExtensionString("GL_EXT_texture_format_BGRA8888", textureFormatBGRA8888, &extensionStrings); + InsertExtensionString("GL_EXT_read_format_bgra", readFormatBGRA, &extensionStrings); + InsertExtensionString("GL_NV_pixel_buffer_object", pixelBufferObject, &extensionStrings); + InsertExtensionString("GL_OES_mapbuffer", mapBuffer, &extensionStrings); + InsertExtensionString("GL_EXT_map_buffer_range", mapBufferRange, &extensionStrings); + InsertExtensionString("GL_EXT_color_buffer_half_float", colorBufferHalfFloat, &extensionStrings); + InsertExtensionString("GL_OES_texture_half_float", textureHalfFloat, &extensionStrings); + InsertExtensionString("GL_OES_texture_half_float_linear", textureHalfFloatLinear, &extensionStrings); + InsertExtensionString("GL_OES_texture_float", textureFloat, &extensionStrings); + InsertExtensionString("GL_OES_texture_float_linear", textureFloatLinear, &extensionStrings); + InsertExtensionString("GL_EXT_texture_rg", textureRG, &extensionStrings); + InsertExtensionString("GL_EXT_texture_compression_dxt1", textureCompressionDXT1, &extensionStrings); + InsertExtensionString("GL_ANGLE_texture_compression_dxt3", textureCompressionDXT3, &extensionStrings); + InsertExtensionString("GL_ANGLE_texture_compression_dxt5", textureCompressionDXT5, &extensionStrings); + InsertExtensionString("GL_KHR_texture_compression_astc_hdr", textureCompressionASTCHDR, &extensionStrings); + InsertExtensionString("GL_KHR_texture_compression_astc_ldr", textureCompressionASTCLDR, &extensionStrings); + InsertExtensionString("GL_OES_compressed_ETC1_RGB8_texture", compressedETC1RGB8Texture, &extensionStrings); + InsertExtensionString("GL_EXT_sRGB", sRGB, &extensionStrings); + InsertExtensionString("GL_ANGLE_depth_texture", depthTextures, &extensionStrings); + InsertExtensionString("GL_OES_depth32", depth32, &extensionStrings); + InsertExtensionString("GL_EXT_texture_storage", textureStorage, &extensionStrings); + InsertExtensionString("GL_OES_texture_npot", textureNPOT, &extensionStrings); + InsertExtensionString("GL_EXT_draw_buffers", drawBuffers, &extensionStrings); + InsertExtensionString("GL_EXT_texture_filter_anisotropic", textureFilterAnisotropic, &extensionStrings); + InsertExtensionString("GL_EXT_occlusion_query_boolean", occlusionQueryBoolean, &extensionStrings); + InsertExtensionString("GL_NV_fence", fence, &extensionStrings); + InsertExtensionString("GL_ANGLE_timer_query", timerQuery, &extensionStrings); + InsertExtensionString("GL_EXT_disjoint_timer_query", disjointTimerQuery, &extensionStrings); + InsertExtensionString("GL_EXT_robustness", robustness, &extensionStrings); + InsertExtensionString("GL_EXT_blend_minmax", blendMinMax, &extensionStrings); + InsertExtensionString("GL_ANGLE_framebuffer_blit", framebufferBlit, &extensionStrings); + InsertExtensionString("GL_ANGLE_framebuffer_multisample", framebufferMultisample, &extensionStrings); + InsertExtensionString("GL_ANGLE_instanced_arrays", instancedArrays, &extensionStrings); + InsertExtensionString("GL_ANGLE_pack_reverse_row_order", packReverseRowOrder, &extensionStrings); + InsertExtensionString("GL_OES_standard_derivatives", standardDerivatives, &extensionStrings); + InsertExtensionString("GL_EXT_shader_texture_lod", shaderTextureLOD, &extensionStrings); + InsertExtensionString("GL_NV_shader_framebuffer_fetch", NVshaderFramebufferFetch, &extensionStrings); + InsertExtensionString("GL_ARM_shader_framebuffer_fetch", ARMshaderFramebufferFetch, &extensionStrings); + InsertExtensionString("GL_EXT_shader_framebuffer_fetch", shaderFramebufferFetch, &extensionStrings); + InsertExtensionString("GL_EXT_frag_depth", fragDepth, &extensionStrings); + InsertExtensionString("GL_ANGLE_texture_usage", textureUsage, &extensionStrings); + InsertExtensionString("GL_ANGLE_translated_shader_source", translatedShaderSource, &extensionStrings); + InsertExtensionString("GL_OES_fbo_render_mipmap", fboRenderMipmap, &extensionStrings); + InsertExtensionString("GL_EXT_discard_framebuffer", discardFramebuffer, &extensionStrings); + InsertExtensionString("GL_EXT_debug_marker", debugMarker, &extensionStrings); + InsertExtensionString("GL_OES_EGL_image", eglImage, &extensionStrings); + InsertExtensionString("GL_OES_EGL_image_external", eglImageExternal, &extensionStrings); + InsertExtensionString("GL_OES_EGL_image_external_essl3", eglImageExternalEssl3, &extensionStrings); + InsertExtensionString("GL_NV_EGL_stream_consumer_external", eglStreamConsumerExternal, &extensionStrings); + InsertExtensionString("GL_EXT_unpack_subimage", unpackSubimage, &extensionStrings); + InsertExtensionString("GL_NV_pack_subimage", packSubimage, &extensionStrings); + InsertExtensionString("GL_EXT_color_buffer_float", colorBufferFloat, &extensionStrings); + InsertExtensionString("GL_OES_vertex_array_object", vertexArrayObject, &extensionStrings); + InsertExtensionString("GL_KHR_debug", debug, &extensionStrings); + // TODO(jmadill): Enable this when complete. + //InsertExtensionString("GL_KHR_no_error", noError, &extensionStrings); + + InsertExtensionString("GL_ANGLE_lossy_etc_decode", lossyETCDecode, &extensionStrings); + InsertExtensionString("GL_CHROMIUM_bind_uniform_location", bindUniformLocation, &extensionStrings); + InsertExtensionString("GL_CHROMIUM_sync_query", syncQuery, &extensionStrings); + InsertExtensionString("GL_CHROMIUM_copy_texture", copyTexture, &extensionStrings); + InsertExtensionString("GL_EXT_multisample_compatibility", multisampleCompatibility, &extensionStrings); + InsertExtensionString("GL_CHROMIUM_framebuffer_mixed_samples", framebufferMixedSamples, &extensionStrings); + InsertExtensionString("GL_EXT_texture_norm16", textureNorm16, &extensionStrings); + InsertExtensionString("GL_CHROMIUM_path_rendering", pathRendering, &extensionStrings); + // clang-format on return extensionStrings; } @@ -501,107 +555,6 @@ void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps) textureNorm16 = DetermineTextureNorm16Support(textureCaps); } -const ExtensionInfoMap &GetExtensionInfoMap() -{ - auto buildExtensionInfoMap = []() { - auto enableableExtension = [](ExtensionInfo::ExtensionBool member) { - ExtensionInfo info; - info.Enableable = true; - info.ExtensionsMember = member; - return info; - }; - - auto esOnlyExtension = [](ExtensionInfo::ExtensionBool member) { - ExtensionInfo info; - info.ExtensionsMember = member; - return info; - }; - - // clang-format off - ExtensionInfoMap map; - map["GL_OES_element_index_uint"] = enableableExtension(&Extensions::elementIndexUint); - map["GL_OES_packed_depth_stencil"] = esOnlyExtension(&Extensions::packedDepthStencil); - map["GL_OES_get_program_binary"] = esOnlyExtension(&Extensions::getProgramBinary); - map["GL_OES_rgb8_rgba8"] = esOnlyExtension(&Extensions::rgb8rgba8); - map["GL_EXT_texture_format_BGRA8888"] = esOnlyExtension(&Extensions::textureFormatBGRA8888); - map["GL_EXT_read_format_bgra"] = esOnlyExtension(&Extensions::readFormatBGRA); - map["GL_NV_pixel_buffer_object"] = esOnlyExtension(&Extensions::pixelBufferObject); - map["GL_OES_mapbuffer"] = esOnlyExtension(&Extensions::mapBuffer); - map["GL_EXT_map_buffer_range"] = esOnlyExtension(&Extensions::mapBufferRange); - map["GL_EXT_color_buffer_half_float"] = esOnlyExtension(&Extensions::colorBufferHalfFloat); - map["GL_OES_texture_half_float"] = esOnlyExtension(&Extensions::textureHalfFloat); - map["GL_OES_texture_half_float_linear"] = esOnlyExtension(&Extensions::textureHalfFloatLinear); - map["GL_OES_texture_float"] = esOnlyExtension(&Extensions::textureFloat); - map["GL_OES_texture_float_linear"] = esOnlyExtension(&Extensions::textureFloatLinear); - map["GL_EXT_texture_rg"] = esOnlyExtension(&Extensions::textureRG); - map["GL_EXT_texture_compression_dxt1"] = esOnlyExtension(&Extensions::textureCompressionDXT1); - map["GL_ANGLE_texture_compression_dxt3"] = esOnlyExtension(&Extensions::textureCompressionDXT3); - map["GL_ANGLE_texture_compression_dxt5"] = esOnlyExtension(&Extensions::textureCompressionDXT5); - map["GL_KHR_texture_compression_astc_hdr"] = esOnlyExtension(&Extensions::textureCompressionASTCHDR); - map["GL_KHR_texture_compression_astc_ldr"] = esOnlyExtension(&Extensions::textureCompressionASTCLDR); - map["GL_OES_compressed_ETC1_RGB8_texture"] = esOnlyExtension(&Extensions::compressedETC1RGB8Texture); - map["GL_EXT_sRGB"] = esOnlyExtension(&Extensions::sRGB); - map["GL_ANGLE_depth_texture"] = esOnlyExtension(&Extensions::depthTextures); - map["GL_OES_depth32"] = esOnlyExtension(&Extensions::depth32); - map["GL_EXT_texture_storage"] = esOnlyExtension(&Extensions::textureStorage); - map["GL_OES_texture_npot"] = esOnlyExtension(&Extensions::textureNPOT); - map["GL_EXT_draw_buffers"] = esOnlyExtension(&Extensions::drawBuffers); - map["GL_EXT_texture_filter_anisotropic"] = esOnlyExtension(&Extensions::textureFilterAnisotropic); - map["GL_EXT_occlusion_query_boolean"] = esOnlyExtension(&Extensions::occlusionQueryBoolean); - map["GL_NV_fence"] = esOnlyExtension(&Extensions::fence); - map["GL_ANGLE_timer_query"] = esOnlyExtension(&Extensions::timerQuery); - map["GL_EXT_disjoint_timer_query"] = esOnlyExtension(&Extensions::disjointTimerQuery); - map["GL_EXT_robustness"] = esOnlyExtension(&Extensions::robustness); - map["GL_EXT_blend_minmax"] = esOnlyExtension(&Extensions::blendMinMax); - map["GL_ANGLE_framebuffer_blit"] = esOnlyExtension(&Extensions::framebufferBlit); - map["GL_ANGLE_framebuffer_multisample"] = esOnlyExtension(&Extensions::framebufferMultisample); - map["GL_ANGLE_instanced_arrays"] = esOnlyExtension(&Extensions::instancedArrays); - map["GL_ANGLE_pack_reverse_row_order"] = esOnlyExtension(&Extensions::packReverseRowOrder); - map["GL_OES_standard_derivatives"] = esOnlyExtension(&Extensions::standardDerivatives); - map["GL_EXT_shader_texture_lod"] = esOnlyExtension(&Extensions::shaderTextureLOD); - map["GL_NV_shader_framebuffer_fetch"] = esOnlyExtension(&Extensions::NVshaderFramebufferFetch); - map["GL_ARM_shader_framebuffer_fetch"] = esOnlyExtension(&Extensions::ARMshaderFramebufferFetch); - map["GL_EXT_shader_framebuffer_fetch"] = esOnlyExtension(&Extensions::shaderFramebufferFetch); - map["GL_EXT_frag_depth"] = esOnlyExtension(&Extensions::fragDepth); - map["GL_ANGLE_texture_usage"] = esOnlyExtension(&Extensions::textureUsage); - map["GL_ANGLE_translated_shader_source"] = esOnlyExtension(&Extensions::translatedShaderSource); - map["GL_OES_fbo_render_mipmap"] = esOnlyExtension(&Extensions::fboRenderMipmap); - map["GL_EXT_discard_framebuffer"] = esOnlyExtension(&Extensions::discardFramebuffer); - map["GL_EXT_debug_marker"] = esOnlyExtension(&Extensions::debugMarker); - map["GL_OES_EGL_image"] = esOnlyExtension(&Extensions::eglImage); - map["GL_OES_EGL_image_external"] = esOnlyExtension(&Extensions::eglImageExternal); - map["GL_OES_EGL_image_external_essl3"] = esOnlyExtension(&Extensions::eglImageExternalEssl3); - map["GL_NV_EGL_stream_consumer_external"] = esOnlyExtension(&Extensions::eglStreamConsumerExternal); - map["GL_EXT_unpack_subimage"] = esOnlyExtension(&Extensions::unpackSubimage); - map["GL_NV_pack_subimage"] = esOnlyExtension(&Extensions::packSubimage); - map["GL_EXT_color_buffer_float"] = esOnlyExtension(&Extensions::colorBufferFloat); - map["GL_OES_vertex_array_object"] = esOnlyExtension(&Extensions::vertexArrayObject); - map["GL_KHR_debug"] = esOnlyExtension(&Extensions::debug); - // TODO(jmadill): Enable this when complete. - //map["GL_KHR_no_error"] = esOnlyExtension(&Extensions::noError); - map["GL_ANGLE_lossy_etc_decode"] = esOnlyExtension(&Extensions::lossyETCDecode); - map["GL_CHROMIUM_bind_uniform_location"] = esOnlyExtension(&Extensions::bindUniformLocation); - map["GL_CHROMIUM_sync_query"] = esOnlyExtension(&Extensions::syncQuery); - map["GL_CHROMIUM_copy_texture"] = esOnlyExtension(&Extensions::copyTexture); - map["GL_CHROMIUM_copy_compressed_texture"] = esOnlyExtension(&Extensions::copyCompressedTexture); - map["GL_ANGLE_webgl_compatibility"] = esOnlyExtension(&Extensions::webglCompatibility); - map["GL_CHROMIUM_bind_generates_resource"] = esOnlyExtension(&Extensions::bindGeneratesResource); - map["GL_ANGLE_robust_client_memory"] = esOnlyExtension(&Extensions::robustClientMemory); - map["GL_EXT_texture_sRGB_decode"] = esOnlyExtension(&Extensions::textureSRGBDecode); - map["GL_EXT_sRGB_write_control"] = esOnlyExtension(&Extensions::sRGBWriteControl); - map["GL_EXT_multisample_compatibility"] = esOnlyExtension(&Extensions::multisampleCompatibility); - map["GL_CHROMIUM_framebuffer_mixed_samples"] = esOnlyExtension(&Extensions::framebufferMixedSamples); - map["GL_EXT_texture_norm16"] = esOnlyExtension(&Extensions::textureNorm16); - map["GL_CHROMIUM_path_rendering"] = esOnlyExtension(&Extensions::pathRendering); - // clang-format on - - return map; - }; - - static const ExtensionInfoMap extensionInfo = buildExtensionInfoMap(); - return extensionInfo; -} - TypePrecision::TypePrecision() { range[0] = 0; @@ -764,7 +717,6 @@ Caps::Caps() DisplayExtensions::DisplayExtensions() : createContextRobustness(false), d3dShareHandleClientBuffer(false), - d3dTextureClientBuffer(false), surfaceD3DTexture2DShareHandle(false), querySurfacePointer(false), windowFixedSize(false), @@ -787,10 +739,7 @@ DisplayExtensions::DisplayExtensions() stream(false), streamConsumerGLTexture(false), streamConsumerGLTextureYUV(false), - streamProducerD3DTextureNV12(false), - createContextWebGLCompatibility(false), - createContextBindGeneratesResource(false), - swapBuffersWithDamage(false) + streamProducerD3DTextureNV12(false) { } @@ -799,37 +748,33 @@ std::vector<std::string> DisplayExtensions::getStrings() const std::vector<std::string> extensionStrings; // clang-format off - // | Extension name | Supported flag | Output vector | - InsertExtensionString("EGL_EXT_create_context_robustness", createContextRobustness, &extensionStrings); - InsertExtensionString("EGL_ANGLE_d3d_share_handle_client_buffer", d3dShareHandleClientBuffer, &extensionStrings); - InsertExtensionString("EGL_ANGLE_d3d_texture_client_buffer", d3dTextureClientBuffer, &extensionStrings); - InsertExtensionString("EGL_ANGLE_surface_d3d_texture_2d_share_handle", surfaceD3DTexture2DShareHandle, &extensionStrings); - InsertExtensionString("EGL_ANGLE_query_surface_pointer", querySurfacePointer, &extensionStrings); - InsertExtensionString("EGL_ANGLE_window_fixed_size", windowFixedSize, &extensionStrings); - InsertExtensionString("EGL_ANGLE_keyed_mutex", keyedMutex, &extensionStrings); - InsertExtensionString("EGL_ANGLE_surface_orientation", surfaceOrientation, &extensionStrings); - InsertExtensionString("EGL_ANGLE_direct_composition", directComposition, &extensionStrings); - InsertExtensionString("EGL_NV_post_sub_buffer", postSubBuffer, &extensionStrings); - InsertExtensionString("EGL_KHR_create_context", createContext, &extensionStrings); - InsertExtensionString("EGL_EXT_device_query", deviceQuery, &extensionStrings); - InsertExtensionString("EGL_KHR_image", image, &extensionStrings); - InsertExtensionString("EGL_KHR_image_base", imageBase, &extensionStrings); - InsertExtensionString("EGL_KHR_image_pixmap", imagePixmap, &extensionStrings); - InsertExtensionString("EGL_KHR_gl_texture_2D_image", glTexture2DImage, &extensionStrings); - InsertExtensionString("EGL_KHR_gl_texture_cubemap_image", glTextureCubemapImage, &extensionStrings); - InsertExtensionString("EGL_KHR_gl_texture_3D_image", glTexture3DImage, &extensionStrings); - InsertExtensionString("EGL_KHR_gl_renderbuffer_image", glRenderbufferImage, &extensionStrings); - InsertExtensionString("EGL_KHR_get_all_proc_addresses", getAllProcAddresses, &extensionStrings); - InsertExtensionString("EGL_KHR_stream", stream, &extensionStrings); - InsertExtensionString("EGL_KHR_stream_consumer_gltexture", streamConsumerGLTexture, &extensionStrings); - InsertExtensionString("EGL_NV_stream_consumer_gltexture_yuv", streamConsumerGLTextureYUV, &extensionStrings); - InsertExtensionString("EGL_ANGLE_flexible_surface_compatibility", flexibleSurfaceCompatibility, &extensionStrings); - InsertExtensionString("EGL_ANGLE_stream_producer_d3d_texture_nv12", streamProducerD3DTextureNV12, &extensionStrings); - InsertExtensionString("EGL_ANGLE_create_context_webgl_compatibility", createContextWebGLCompatibility, &extensionStrings); - InsertExtensionString("EGL_CHROMIUM_create_context_bind_generates_resource", createContextBindGeneratesResource, &extensionStrings); - InsertExtensionString("EGL_EXT_swap_buffers_with_damage", swapBuffersWithDamage, &extensionStrings); + // | Extension name | Supported flag | Output vector | + InsertExtensionString("EGL_EXT_create_context_robustness", createContextRobustness, &extensionStrings); + InsertExtensionString("EGL_ANGLE_d3d_share_handle_client_buffer", d3dShareHandleClientBuffer, &extensionStrings); + InsertExtensionString("EGL_ANGLE_surface_d3d_texture_2d_share_handle", surfaceD3DTexture2DShareHandle, &extensionStrings); + InsertExtensionString("EGL_ANGLE_query_surface_pointer", querySurfacePointer, &extensionStrings); + InsertExtensionString("EGL_ANGLE_window_fixed_size", windowFixedSize, &extensionStrings); + InsertExtensionString("EGL_ANGLE_keyed_mutex", keyedMutex, &extensionStrings); + InsertExtensionString("EGL_ANGLE_surface_orientation", surfaceOrientation, &extensionStrings); + InsertExtensionString("EGL_ANGLE_direct_composition", directComposition, &extensionStrings); + InsertExtensionString("EGL_NV_post_sub_buffer", postSubBuffer, &extensionStrings); + InsertExtensionString("EGL_KHR_create_context", createContext, &extensionStrings); + InsertExtensionString("EGL_EXT_device_query", deviceQuery, &extensionStrings); + InsertExtensionString("EGL_KHR_image", image, &extensionStrings); + InsertExtensionString("EGL_KHR_image_base", imageBase, &extensionStrings); + InsertExtensionString("EGL_KHR_image_pixmap", imagePixmap, &extensionStrings); + InsertExtensionString("EGL_KHR_gl_texture_2D_image", glTexture2DImage, &extensionStrings); + InsertExtensionString("EGL_KHR_gl_texture_cubemap_image", glTextureCubemapImage, &extensionStrings); + InsertExtensionString("EGL_KHR_gl_texture_3D_image", glTexture3DImage, &extensionStrings); + InsertExtensionString("EGL_KHR_gl_renderbuffer_image", glRenderbufferImage, &extensionStrings); + InsertExtensionString("EGL_KHR_get_all_proc_addresses", getAllProcAddresses, &extensionStrings); + InsertExtensionString("EGL_KHR_stream", stream, &extensionStrings); + InsertExtensionString("EGL_KHR_stream_consumer_gltexture", streamConsumerGLTexture, &extensionStrings); + InsertExtensionString("EGL_NV_stream_consumer_gltexture_yuv", streamConsumerGLTextureYUV, &extensionStrings); + InsertExtensionString("EGL_ANGLE_flexible_surface_compatibility", flexibleSurfaceCompatibility, &extensionStrings); + InsertExtensionString("EGL_ANGLE_stream_producer_d3d_texture_nv12", streamProducerD3DTextureNV12, &extensionStrings); // TODO(jmadill): Enable this when complete. - //InsertExtensionString("KHR_create_context_no_error", createContextNoError, &extensionStrings); + //InsertExtensionString("KHR_create_context_no_error", createContextNoError, &extensionStrings); // clang-format on return extensionStrings; @@ -877,7 +822,6 @@ std::vector<std::string> ClientExtensions::getStrings() const InsertExtensionString("EGL_ANGLE_platform_angle", platformANGLE, &extensionStrings); InsertExtensionString("EGL_ANGLE_platform_angle_d3d", platformANGLED3D, &extensionStrings); InsertExtensionString("EGL_ANGLE_platform_angle_opengl", platformANGLEOpenGL, &extensionStrings); - InsertExtensionString("EGL_ANGLE_platform_angle_null", platformANGLENULL, &extensionStrings); InsertExtensionString("EGL_ANGLE_device_creation", deviceCreation, &extensionStrings); InsertExtensionString("EGL_ANGLE_device_creation_d3d11", deviceCreationD3D11, &extensionStrings); InsertExtensionString("EGL_ANGLE_x11_visual", x11Visual, &extensionStrings); diff --git a/gfx/angle/src/libANGLE/Caps.h b/gfx/angle/src/libANGLE/Caps.h index 277b4a490..6382830eb 100755 --- a/gfx/angle/src/libANGLE/Caps.h +++ b/gfx/angle/src/libANGLE/Caps.h @@ -52,7 +52,6 @@ class TextureCapsMap void insert(GLenum internalFormat, const TextureCaps &caps); void remove(GLenum internalFormat); - void clear(); const TextureCaps &get(GLenum internalFormat) const; @@ -293,24 +292,6 @@ struct Extensions // GL_CHROMIUM_copy_texture bool copyTexture; - // GL_CHROMIUM_copy_compressed_texture - bool copyCompressedTexture; - - // GL_ANGLE_webgl_compatibility - bool webglCompatibility; - - // GL_CHROMIUM_bind_generates_resource - bool bindGeneratesResource; - - // GL_ANGLE_robust_client_memory - bool robustClientMemory; - - // GL_EXT_texture_sRGB_decode - bool textureSRGBDecode; - - // GL_EXT_sRGB_write_control - bool sRGBWriteControl; - // ES3 Extension support // GL_EXT_color_buffer_float @@ -331,19 +312,6 @@ struct Extensions bool pathRendering; }; -struct ExtensionInfo -{ - // If this extension can be enabled with glEnableExtension (GL_ANGLE_webgl_compatibility) - bool Enableable = false; - - // Pointer to a boolean member of the Extensions struct - typedef bool(Extensions::*ExtensionBool); - ExtensionBool ExtensionsMember = nullptr; -}; - -using ExtensionInfoMap = std::map<std::string, ExtensionInfo>; -const ExtensionInfoMap &GetExtensionInfoMap(); - struct Limitations { Limitations(); @@ -536,9 +504,6 @@ struct DisplayExtensions // EGL_ANGLE_d3d_share_handle_client_buffer bool d3dShareHandleClientBuffer; - // EGL_ANGLE_d3d_texture_client_buffer - bool d3dTextureClientBuffer; - // EGL_ANGLE_surface_d3d_texture_2d_share_handle bool surfaceD3DTexture2DShareHandle; @@ -607,15 +572,6 @@ struct DisplayExtensions // EGL_ANGLE_stream_producer_d3d_texture_nv12 bool streamProducerD3DTextureNV12; - - // EGL_ANGLE_create_context_webgl_compatibility - bool createContextWebGLCompatibility; - - // EGL_CHROMIUM_create_context_bind_generates_resource - bool createContextBindGeneratesResource; - - // EGL_EXT_swap_buffers_with_damage - bool swapBuffersWithDamage; }; struct DeviceExtensions @@ -654,9 +610,6 @@ struct ClientExtensions // EGL_ANGLE_platform_angle_opengl bool platformANGLEOpenGL; - // EGL_ANGLE_platform_angle_null - bool platformANGLENULL; - // EGL_ANGLE_device_creation bool deviceCreation; diff --git a/gfx/angle/src/libANGLE/Compiler.cpp b/gfx/angle/src/libANGLE/Compiler.cpp index 078491284..b745888f2 100755 --- a/gfx/angle/src/libANGLE/Compiler.cpp +++ b/gfx/angle/src/libANGLE/Compiler.cpp @@ -19,33 +19,31 @@ namespace gl namespace { -// Global count of active shader compiler handles. Needed to know when to call sh::Initialize and -// sh::Finalize. +// Global count of active shader compiler handles. Needed to know when to call ShInitialize and +// ShFinalize. size_t activeCompilerHandles = 0; -ShShaderSpec SelectShaderSpec(GLint majorVersion, GLint minorVersion, bool isWebGL) +ShShaderSpec SelectShaderSpec(GLint majorVersion, GLint minorVersion) { if (majorVersion >= 3) { if (minorVersion == 1) { - return isWebGL ? SH_WEBGL3_SPEC : SH_GLES3_1_SPEC; + return SH_GLES3_1_SPEC; } else { - return isWebGL ? SH_WEBGL2_SPEC : SH_GLES3_SPEC; + return SH_GLES3_SPEC; } } - return isWebGL ? SH_WEBGL_SPEC : SH_GLES2_SPEC; + return SH_GLES2_SPEC; } } // anonymous namespace Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state) : mImplementation(implFactory->createCompiler()), - mSpec(SelectShaderSpec(state.getClientMajorVersion(), - state.getClientMinorVersion(), - state.getExtensions().webglCompatibility)), + mSpec(SelectShaderSpec(state.getClientMajorVersion(), state.getClientMinorVersion())), mOutputType(mImplementation->getTranslatorOutputType()), mResources(), mFragmentCompiler(nullptr), @@ -57,7 +55,7 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state) const gl::Caps &caps = state.getCaps(); const gl::Extensions &extensions = state.getExtensions(); - sh::InitBuiltInResources(&mResources); + ShInitBuiltInResources(&mResources); mResources.MaxVertexAttribs = caps.maxVertexAttributes; mResources.MaxVertexUniformVectors = caps.maxVertexUniformVectors; mResources.MaxVaryingVectors = caps.maxVaryingVectors; @@ -122,7 +120,7 @@ Error Compiler::release() { if (mFragmentCompiler) { - sh::Destruct(mFragmentCompiler); + ShDestruct(mFragmentCompiler); mFragmentCompiler = nullptr; ASSERT(activeCompilerHandles > 0); @@ -131,7 +129,7 @@ Error Compiler::release() if (mVertexCompiler) { - sh::Destruct(mVertexCompiler); + ShDestruct(mVertexCompiler); mVertexCompiler = nullptr; ASSERT(activeCompilerHandles > 0); @@ -140,7 +138,7 @@ Error Compiler::release() if (mComputeCompiler) { - sh::Destruct(mComputeCompiler); + ShDestruct(mComputeCompiler); mComputeCompiler = nullptr; ASSERT(activeCompilerHandles > 0); @@ -149,7 +147,7 @@ Error Compiler::release() if (activeCompilerHandles == 0) { - sh::Finalize(); + ShFinalize(); } mImplementation->release(); @@ -181,10 +179,10 @@ ShHandle Compiler::getCompilerHandle(GLenum type) { if (activeCompilerHandles == 0) { - sh::Initialize(); + ShInitialize(); } - *compiler = sh::ConstructCompiler(type, mSpec, mOutputType, &mResources); + *compiler = ShConstructCompiler(type, mSpec, mOutputType, &mResources); activeCompilerHandles++; } diff --git a/gfx/angle/src/libANGLE/Context.cpp b/gfx/angle/src/libANGLE/Context.cpp index d74f33057..c79f3b7b7 100755 --- a/gfx/angle/src/libANGLE/Context.cpp +++ b/gfx/angle/src/libANGLE/Context.cpp @@ -35,11 +35,9 @@ #include "libANGLE/VertexArray.h" #include "libANGLE/formatutils.h" #include "libANGLE/validationES.h" -#include "libANGLE/Workarounds.h" #include "libANGLE/renderer/ContextImpl.h" #include "libANGLE/renderer/EGLImplFactory.h" #include "libANGLE/queryconversions.h" -#include "libANGLE/queryutils.h" namespace { @@ -97,21 +95,22 @@ std::vector<gl::Path *> GatherPaths(gl::ResourceManager &resourceManager, } template <typename T> -gl::Error GetQueryObjectParameter(gl::Query *query, GLenum pname, T *params) +gl::Error GetQueryObjectParameter(gl::Context *context, GLuint id, GLenum pname, T *params) { - ASSERT(query != nullptr); + gl::Query *queryObject = context->getQuery(id, false, GL_NONE); + ASSERT(queryObject != nullptr); switch (pname) { case GL_QUERY_RESULT_EXT: - return query->getResult(params); + return queryObject->getResult(params); case GL_QUERY_RESULT_AVAILABLE_EXT: { bool available; - gl::Error error = query->isResultAvailable(&available); + gl::Error error = queryObject->isResultAvailable(&available); if (!error.isError()) { - *params = gl::ConvertFromGLboolean<T>(available); + *params = static_cast<T>(available ? GL_TRUE : GL_FALSE); } return error; } @@ -149,11 +148,6 @@ EGLint GetClientMinorVersion(const egl::AttributeMap &attribs) return static_cast<EGLint>(attribs.get(EGL_CONTEXT_MINOR_VERSION, 0)); } -gl::Version GetClientVersion(const egl::AttributeMap &attribs) -{ - return gl::Version(GetClientMajorVersion(attribs), GetClientMinorVersion(attribs)); -} - GLenum GetResetStrategy(const egl::AttributeMap &attribs) { EGLAttrib attrib = attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, @@ -172,15 +166,12 @@ GLenum GetResetStrategy(const egl::AttributeMap &attribs) bool GetRobustAccess(const egl::AttributeMap &attribs) { - return (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE) || - ((attribs.get(EGL_CONTEXT_FLAGS_KHR, 0) & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) != - 0); + return (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE); } bool GetDebug(const egl::AttributeMap &attribs) { - return (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE) || - ((attribs.get(EGL_CONTEXT_FLAGS_KHR, 0) & EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR) != 0); + return (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE); } bool GetNoError(const egl::AttributeMap &attribs) @@ -188,16 +179,6 @@ bool GetNoError(const egl::AttributeMap &attribs) return (attribs.get(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, EGL_FALSE) == EGL_TRUE); } -bool GetWebGLContext(const egl::AttributeMap &attribs) -{ - return (attribs.get(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE, EGL_FALSE) == EGL_TRUE); -} - -bool GetBindGeneratesResource(const egl::AttributeMap &attribs) -{ - return (attribs.get(EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM, EGL_TRUE) == EGL_TRUE); -} - std::string GetObjectLabelFromPointer(GLsizei length, const GLchar *label) { std::string labelName; @@ -238,38 +219,34 @@ Context::Context(rx::EGLImplFactory *implFactory, const Context *shareContext, const egl::AttributeMap &attribs) - : ValidationContext(GetClientVersion(attribs), + : ValidationContext(GetClientMajorVersion(attribs), + GetClientMinorVersion(attribs), &mGLState, mCaps, mTextureCaps, mExtensions, nullptr, mLimitations, - mFramebufferMap, GetNoError(attribs)), mImplementation(implFactory->createContext(mState)), mCompiler(nullptr), + mClientMajorVersion(GetClientMajorVersion(attribs)), + mClientMinorVersion(GetClientMinorVersion(attribs)), mConfig(config), mClientType(EGL_OPENGL_ES_API), mHasBeenCurrent(false), mContextLost(false), mResetStatus(GL_NO_ERROR), - mContextLostForced(false), mResetStrategy(GetResetStrategy(attribs)), mRobustAccess(GetRobustAccess(attribs)), mCurrentSurface(nullptr), mResourceManager(nullptr) { - if (mRobustAccess) - { - UNIMPLEMENTED(); - } + ASSERT(!mRobustAccess); // Unimplemented - initCaps(GetWebGLContext(attribs)); - initWorkarounds(); + initCaps(); - mGLState.initialize(mCaps, mExtensions, getClientVersion(), GetDebug(attribs), - GetBindGeneratesResource(attribs)); + mGLState.initialize(mCaps, mExtensions, mClientMajorVersion, GetDebug(attribs)); mFenceNVHandleAllocator.setBaseHandle(0); @@ -297,7 +274,7 @@ Context::Context(rx::EGLImplFactory *implFactory, Texture *zeroTextureCube = new Texture(mImplementation.get(), 0, GL_TEXTURE_CUBE_MAP); mZeroTextures[GL_TEXTURE_CUBE_MAP].set(zeroTextureCube); - if (getClientVersion() >= Version(3, 0)) + if (mClientMajorVersion >= 3) { // TODO: These could also be enabled via extension Texture *zeroTexture3D = new Texture(mImplementation.get(), 0, GL_TEXTURE_3D); @@ -320,7 +297,7 @@ Context::Context(rx::EGLImplFactory *implFactory, bindArrayBuffer(0); bindElementArrayBuffer(0); - bindRenderbuffer(GL_RENDERBUFFER, 0); + bindRenderbuffer(0); bindGenericUniformBuffer(0); for (unsigned int i = 0; i < mCaps.maxCombinedUniformBlocks; i++) @@ -333,7 +310,7 @@ Context::Context(rx::EGLImplFactory *implFactory, bindPixelPackBuffer(0); bindPixelUnpackBuffer(0); - if (getClientVersion() >= Version(3, 0)) + if (mClientMajorVersion >= 3) { // [OpenGL ES 3.0.2] section 2.14.1 pg 85: // In the initial state, a default transform feedback object is bound and treated as @@ -379,7 +356,6 @@ Context::Context(rx::EGLImplFactory *implFactory, mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR); - mBlitDirtyBits.set(State::DIRTY_BIT_FRAMEBUFFER_SRGB); mBlitDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); @@ -830,6 +806,16 @@ Buffer *Context::getBuffer(GLuint handle) const return mResourceManager->getBuffer(handle); } +Shader *Context::getShader(GLuint handle) const +{ + return mResourceManager->getShader(handle); +} + +Program *Context::getProgram(GLuint handle) const +{ + return mResourceManager->getProgram(handle); +} + Texture *Context::getTexture(GLuint handle) const { return mResourceManager->getTexture(handle); @@ -986,6 +972,13 @@ void Context::bindDrawFramebuffer(GLuint framebufferHandle) mGLState.setDrawFramebufferBinding(framebuffer); } +void Context::bindRenderbuffer(GLuint renderbufferHandle) +{ + Renderbuffer *renderbuffer = + mResourceManager->checkRenderbufferAllocation(mImplementation.get(), renderbufferHandle); + mGLState.setRenderbufferBinding(renderbuffer); +} + void Context::bindVertexArray(GLuint vertexArrayHandle) { VertexArray *vertexArray = checkVertexArrayAllocation(vertexArrayHandle); @@ -1135,24 +1128,24 @@ void Context::getQueryiv(GLenum target, GLenum pname, GLint *params) } } -void Context::getQueryObjectiv(GLuint id, GLenum pname, GLint *params) +Error Context::getQueryObjectiv(GLuint id, GLenum pname, GLint *params) { - handleError(GetQueryObjectParameter(getQuery(id), pname, params)); + return GetQueryObjectParameter(this, id, pname, params); } -void Context::getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) +Error Context::getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) { - handleError(GetQueryObjectParameter(getQuery(id), pname, params)); + return GetQueryObjectParameter(this, id, pname, params); } -void Context::getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) +Error Context::getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) { - handleError(GetQueryObjectParameter(getQuery(id), pname, params)); + return GetQueryObjectParameter(this, id, pname, params); } -void Context::getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) +Error Context::getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) { - handleError(GetQueryObjectParameter(getQuery(id), pname, params)); + return GetQueryObjectParameter(this, id, pname, params); } Framebuffer *Context::getFramebuffer(unsigned int handle) const @@ -1301,10 +1294,10 @@ void Context::getIntegerv(GLenum pname, GLint *params) case GL_MIN_PROGRAM_TEXEL_OFFSET: *params = mCaps.minProgramTexelOffset; break; case GL_MAX_PROGRAM_TEXEL_OFFSET: *params = mCaps.maxProgramTexelOffset; break; case GL_MAJOR_VERSION: - *params = getClientVersion().major; + *params = mClientMajorVersion; break; case GL_MINOR_VERSION: - *params = getClientVersion().minor; + *params = mClientMinorVersion; break; case GL_MAX_ELEMENTS_INDICES: *params = mCaps.maxElementsIndices; break; case GL_MAX_ELEMENTS_VERTICES: *params = mCaps.maxElementsVertices; break; @@ -1539,6 +1532,7 @@ void Context::getIntegeri_v(GLenum target, GLuint index, GLint *data) GLenum nativeType; unsigned int numParams; bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); + UNUSED_ASSERTION_VARIABLE(queryStatus); ASSERT(queryStatus); if (nativeType == GL_INT) @@ -1571,6 +1565,7 @@ void Context::getInteger64i_v(GLenum target, GLuint index, GLint64 *data) GLenum nativeType; unsigned int numParams; bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); + UNUSED_ASSERTION_VARIABLE(queryStatus); ASSERT(queryStatus); if (nativeType == GL_INT_64_ANGLEX) @@ -1591,6 +1586,7 @@ void Context::getBooleani_v(GLenum target, GLuint index, GLboolean *data) GLenum nativeType; unsigned int numParams; bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); + UNUSED_ASSERTION_VARIABLE(queryStatus); ASSERT(queryStatus); if (nativeType == GL_BOOL) @@ -1919,12 +1915,7 @@ void Context::handleError(const Error &error) { if (error.isError()) { - GLenum code = error.getCode(); - mErrors.insert(code); - if (code == GL_OUT_OF_MEMORY && getWorkarounds().loseContextOnOutOfMemory) - { - markContextLost(); - } + mErrors.insert(error.getCode()); if (!error.getMessage().empty()) { @@ -1955,10 +1946,7 @@ GLenum Context::getError() void Context::markContextLost() { if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT) - { mResetStatus = GL_UNKNOWN_CONTEXT_RESET_EXT; - mContextLostForced = true; - } mContextLost = true; } @@ -1997,11 +1985,8 @@ GLenum Context::getResetStatus() mContextLost = true; } } - else if (!mContextLostForced && mResetStatus != GL_NO_ERROR) + else if (mResetStatus != GL_NO_ERROR) { - // If markContextLost was used to mark the context lost then - // assume that is not recoverable, and continue to report the - // lost reset status for the lifetime of this context. mResetStatus = mImplementation->getResetStatus(); } @@ -2092,13 +2077,11 @@ Framebuffer *Context::checkFramebufferAllocation(GLuint framebuffer) bool Context::isVertexArrayGenerated(GLuint vertexArray) { - ASSERT(mVertexArrayMap.find(0) != mVertexArrayMap.end()); return mVertexArrayMap.find(vertexArray) != mVertexArrayMap.end(); } bool Context::isTransformFeedbackGenerated(GLuint transformFeedback) { - ASSERT(mTransformFeedbackMap.find(0) != mTransformFeedbackMap.end()); return mTransformFeedbackMap.find(transformFeedback) != mTransformFeedbackMap.end(); } @@ -2192,44 +2175,102 @@ void Context::setVertexAttribDivisor(GLuint index, GLuint divisor) void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param) { - Sampler *samplerObject = - mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); - SetSamplerParameteri(samplerObject, pname, param); -} + mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); -void Context::samplerParameteriv(GLuint sampler, GLenum pname, const GLint *param) -{ - Sampler *samplerObject = - mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); - SetSamplerParameteriv(samplerObject, pname, param); + Sampler *samplerObject = getSampler(sampler); + ASSERT(samplerObject); + + // clang-format off + switch (pname) + { + case GL_TEXTURE_MIN_FILTER: samplerObject->setMinFilter(static_cast<GLenum>(param)); break; + case GL_TEXTURE_MAG_FILTER: samplerObject->setMagFilter(static_cast<GLenum>(param)); break; + case GL_TEXTURE_WRAP_S: samplerObject->setWrapS(static_cast<GLenum>(param)); break; + case GL_TEXTURE_WRAP_T: samplerObject->setWrapT(static_cast<GLenum>(param)); break; + case GL_TEXTURE_WRAP_R: samplerObject->setWrapR(static_cast<GLenum>(param)); break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: samplerObject->setMaxAnisotropy(std::min(static_cast<GLfloat>(param), getExtensions().maxTextureAnisotropy)); break; + case GL_TEXTURE_MIN_LOD: samplerObject->setMinLod(static_cast<GLfloat>(param)); break; + case GL_TEXTURE_MAX_LOD: samplerObject->setMaxLod(static_cast<GLfloat>(param)); break; + case GL_TEXTURE_COMPARE_MODE: samplerObject->setCompareMode(static_cast<GLenum>(param)); break; + case GL_TEXTURE_COMPARE_FUNC: samplerObject->setCompareFunc(static_cast<GLenum>(param)); break; + default: UNREACHABLE(); break; + } + // clang-format on } void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param) { - Sampler *samplerObject = - mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); - SetSamplerParameterf(samplerObject, pname, param); -} + mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); -void Context::samplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *param) -{ - Sampler *samplerObject = - mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); - SetSamplerParameterfv(samplerObject, pname, param); + Sampler *samplerObject = getSampler(sampler); + ASSERT(samplerObject); + + // clang-format off + switch (pname) + { + case GL_TEXTURE_MIN_FILTER: samplerObject->setMinFilter(uiround<GLenum>(param)); break; + case GL_TEXTURE_MAG_FILTER: samplerObject->setMagFilter(uiround<GLenum>(param)); break; + case GL_TEXTURE_WRAP_S: samplerObject->setWrapS(uiround<GLenum>(param)); break; + case GL_TEXTURE_WRAP_T: samplerObject->setWrapT(uiround<GLenum>(param)); break; + case GL_TEXTURE_WRAP_R: samplerObject->setWrapR(uiround<GLenum>(param)); break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: samplerObject->setMaxAnisotropy(std::min(param, getExtensions().maxTextureAnisotropy)); break; + case GL_TEXTURE_MIN_LOD: samplerObject->setMinLod(param); break; + case GL_TEXTURE_MAX_LOD: samplerObject->setMaxLod(param); break; + case GL_TEXTURE_COMPARE_MODE: samplerObject->setCompareMode(uiround<GLenum>(param)); break; + case GL_TEXTURE_COMPARE_FUNC: samplerObject->setCompareFunc(uiround<GLenum>(param)); break; + default: UNREACHABLE(); break; + } + // clang-format on } -void Context::getSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) +GLint Context::getSamplerParameteri(GLuint sampler, GLenum pname) { - const Sampler *samplerObject = - mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); - QuerySamplerParameteriv(samplerObject, pname, params); + mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); + + Sampler *samplerObject = getSampler(sampler); + ASSERT(samplerObject); + + // clang-format off + switch (pname) + { + case GL_TEXTURE_MIN_FILTER: return static_cast<GLint>(samplerObject->getMinFilter()); + case GL_TEXTURE_MAG_FILTER: return static_cast<GLint>(samplerObject->getMagFilter()); + case GL_TEXTURE_WRAP_S: return static_cast<GLint>(samplerObject->getWrapS()); + case GL_TEXTURE_WRAP_T: return static_cast<GLint>(samplerObject->getWrapT()); + case GL_TEXTURE_WRAP_R: return static_cast<GLint>(samplerObject->getWrapR()); + case GL_TEXTURE_MAX_ANISOTROPY_EXT: return static_cast<GLint>(samplerObject->getMaxAnisotropy()); + case GL_TEXTURE_MIN_LOD: return iround<GLint>(samplerObject->getMinLod()); + case GL_TEXTURE_MAX_LOD: return iround<GLint>(samplerObject->getMaxLod()); + case GL_TEXTURE_COMPARE_MODE: return static_cast<GLint>(samplerObject->getCompareMode()); + case GL_TEXTURE_COMPARE_FUNC: return static_cast<GLint>(samplerObject->getCompareFunc()); + default: UNREACHABLE(); return 0; + } + // clang-format on } -void Context::getSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) +GLfloat Context::getSamplerParameterf(GLuint sampler, GLenum pname) { - const Sampler *samplerObject = - mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); - QuerySamplerParameterfv(samplerObject, pname, params); + mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); + + Sampler *samplerObject = getSampler(sampler); + ASSERT(samplerObject); + + // clang-format off + switch (pname) + { + case GL_TEXTURE_MIN_FILTER: return static_cast<GLfloat>(samplerObject->getMinFilter()); + case GL_TEXTURE_MAG_FILTER: return static_cast<GLfloat>(samplerObject->getMagFilter()); + case GL_TEXTURE_WRAP_S: return static_cast<GLfloat>(samplerObject->getWrapS()); + case GL_TEXTURE_WRAP_T: return static_cast<GLfloat>(samplerObject->getWrapT()); + case GL_TEXTURE_WRAP_R: return static_cast<GLfloat>(samplerObject->getWrapR()); + case GL_TEXTURE_MAX_ANISOTROPY_EXT: return samplerObject->getMaxAnisotropy(); + case GL_TEXTURE_MIN_LOD: return samplerObject->getMinLod(); + case GL_TEXTURE_MAX_LOD: return samplerObject->getMaxLod(); + case GL_TEXTURE_COMPARE_MODE: return static_cast<GLfloat>(samplerObject->getCompareMode()); + case GL_TEXTURE_COMPARE_FUNC: return static_cast<GLfloat>(samplerObject->getCompareFunc()); + default: UNREACHABLE(); return 0; + } + // clang-format on } void Context::programParameteri(GLuint program, GLenum pname, GLint value) @@ -2251,30 +2292,26 @@ void Context::initRendererString() mRendererString = MakeStaticString(rendererString.str()); } -const char *Context::getRendererString() const +const std::string &Context::getRendererString() const { return mRendererString; } void Context::initExtensionStrings() { - for (const auto &extensionString : mExtensions.getStrings()) - { - mExtensionStrings.push_back(MakeStaticString(extensionString)); - } + mExtensionStrings = mExtensions.getStrings(); std::ostringstream combinedStringStream; - std::copy(mExtensionStrings.begin(), mExtensionStrings.end(), - std::ostream_iterator<const char *>(combinedStringStream, " ")); - mExtensionString = MakeStaticString(combinedStringStream.str()); + std::copy(mExtensionStrings.begin(), mExtensionStrings.end(), std::ostream_iterator<std::string>(combinedStringStream, " ")); + mExtensionString = combinedStringStream.str(); } -const char *Context::getExtensionString() const +const std::string &Context::getExtensionString() const { return mExtensionString; } -const char *Context::getExtensionString(size_t idx) const +const std::string &Context::getExtensionString(size_t idx) const { return mExtensionStrings[idx]; } @@ -2305,7 +2342,7 @@ bool Context::hasActiveTransformFeedback(GLuint program) const return false; } -void Context::initCaps(bool webGLContext) +void Context::initCaps() { mCaps = mImplementation->getNativeCaps(); @@ -2313,7 +2350,7 @@ void Context::initCaps(bool webGLContext) mLimitations = mImplementation->getNativeLimitations(); - if (getClientVersion() < Version(3, 0)) + if (mClientMajorVersion < 3) { // Disable ES3+ extensions mExtensions.colorBufferFloat = false; @@ -2321,7 +2358,7 @@ void Context::initCaps(bool webGLContext) mExtensions.textureNorm16 = false; } - if (getClientVersion() > Version(2, 0)) + if (mClientMajorVersion > 2) { // FIXME(geofflang): Don't support EXT_sRGB in non-ES2 contexts //mExtensions.sRGB = false; @@ -2330,7 +2367,6 @@ void Context::initCaps(bool webGLContext) // Some extensions are always available because they are implemented in the GL layer. mExtensions.bindUniformLocation = true; mExtensions.vertexArrayObject = true; - mExtensions.bindGeneratesResource = true; // Enable the no error extension if the context was created with the flag. mExtensions.noError = mSkipValidation; @@ -2342,9 +2378,6 @@ void Context::initCaps(bool webGLContext) mExtensions.maxDebugGroupStackDepth = 1024; mExtensions.maxLabelLength = 1024; - // Explicitly enable GL_ANGLE_robust_client_memory - mExtensions.robustClientMemory = true; - // Apply implementation limits mCaps.maxVertexAttributes = std::min<GLuint>(mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS); mCaps.maxVertexUniformBlocks = std::min<GLuint>(mCaps.maxVertexUniformBlocks, IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS); @@ -2352,25 +2385,7 @@ void Context::initCaps(bool webGLContext) mCaps.maxFragmentInputComponents = std::min<GLuint>(mCaps.maxFragmentInputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); - // WebGL compatibility - mExtensions.webglCompatibility = webGLContext; - for (const auto &extensionInfo : GetExtensionInfoMap()) - { - // If this context is for WebGL, disable all enableable extensions - if (webGLContext && extensionInfo.second.Enableable) - { - mExtensions.*(extensionInfo.second.ExtensionsMember) = false; - } - } - - // Generate texture caps - updateCaps(); -} - -void Context::updateCaps() -{ mCaps.compressedTextureFormats.clear(); - mTextureCaps.clear(); const TextureCapsMap &rendererFormats = mImplementation->getNativeTextureCaps(); for (TextureCapsMap::const_iterator i = rendererFormats.begin(); i != rendererFormats.end(); i++) @@ -2384,11 +2399,11 @@ void Context::updateCaps() // Caps are AND'd with the renderer caps because some core formats are still unsupported in // ES3. formatCaps.texturable = - formatCaps.texturable && formatInfo.textureSupport(getClientVersion(), mExtensions); + formatCaps.texturable && formatInfo.textureSupport(mClientMajorVersion, mExtensions); formatCaps.renderable = - formatCaps.renderable && formatInfo.renderSupport(getClientVersion(), mExtensions); + formatCaps.renderable && formatInfo.renderSupport(mClientMajorVersion, mExtensions); formatCaps.filterable = - formatCaps.filterable && formatInfo.filterSupport(getClientVersion(), mExtensions); + formatCaps.filterable && formatInfo.filterSupport(mClientMajorVersion, mExtensions); // OpenGL ES does not support multisampling with integer formats if (!formatInfo.renderSupport || formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT) @@ -2405,13 +2420,6 @@ void Context::updateCaps() } } -void Context::initWorkarounds() -{ - // Lose the context upon out of memory error if the application is - // expecting to watch for those events. - mWorkarounds.loseContextOnOutOfMemory = (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); -} - void Context::syncRendererState() { const State::DirtyBits &dirtyBits = mGLState.getDirtyBits(); @@ -2504,11 +2512,6 @@ void Context::readPixels(GLint x, GLenum type, GLvoid *pixels) { - if (width == 0 || height == 0) - { - return; - } - syncStateForReadPixels(); Framebuffer *framebufferObject = mGLState.getReadFramebuffer(); @@ -2547,11 +2550,6 @@ void Context::copyTexSubImage2D(GLenum target, GLsizei width, GLsizei height) { - if (width == 0 || height == 0) - { - return; - } - // Only sync the read FBO mGLState.syncDirtyObject(GL_READ_FRAMEBUFFER); @@ -2574,11 +2572,6 @@ void Context::copyTexSubImage3D(GLenum target, GLsizei width, GLsizei height) { - if (width == 0 || height == 0) - { - return; - } - // Only sync the read FBO mGLState.syncDirtyObject(GL_READ_FRAMEBUFFER); @@ -2931,32 +2924,6 @@ void Context::generateMipmap(GLenum target) handleError(texture->generateMipmap()); } -GLboolean Context::enableExtension(const char *name) -{ - const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); - ASSERT(extensionInfos.find(name) != extensionInfos.end()); - const auto &extension = extensionInfos.at(name); - ASSERT(extension.Enableable); - - if (mExtensions.*(extension.ExtensionsMember)) - { - // Extension already enabled - return GL_TRUE; - } - - const auto &nativeExtensions = mImplementation->getNativeExtensions(); - if (!(nativeExtensions.*(extension.ExtensionsMember))) - { - // Underlying implementation does not support this valid extension - return GL_FALSE; - } - - mExtensions.*(extension.ExtensionsMember) = true; - updateCaps(); - initExtensionStrings(); - return GL_TRUE; -} - void Context::copyTextureCHROMIUM(GLuint sourceId, GLuint destId, GLint internalFormat, @@ -3003,21 +2970,19 @@ void Context::copySubTextureCHROMIUM(GLuint sourceId, unpackUnmultiplyAlpha == GL_TRUE, sourceTexture)); } -void Context::compressedCopyTextureCHROMIUM(GLuint sourceId, GLuint destId) -{ - syncStateForTexImage(); - - gl::Texture *sourceTexture = getTexture(sourceId); - gl::Texture *destTexture = getTexture(destId); - handleError(destTexture->copyCompressedTexture(sourceTexture)); -} - -void Context::getBufferPointerv(GLenum target, GLenum pname, void **params) +void Context::getBufferPointerv(GLenum target, GLenum /*pname*/, void **params) { Buffer *buffer = mGLState.getTargetBuffer(target); ASSERT(buffer); - QueryBufferPointerv(buffer, pname, params); + if (!buffer->isMapped()) + { + *params = nullptr; + } + else + { + *params = buffer->getMapPointer(); + } } GLvoid *Context::mapBuffer(GLenum target, GLenum access) @@ -3104,21 +3069,11 @@ void Context::blendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf a mGLState.setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha)); } -void Context::blendEquation(GLenum mode) -{ - mGLState.setBlendEquation(mode, mode); -} - void Context::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { mGLState.setBlendEquation(modeRGB, modeAlpha); } -void Context::blendFunc(GLenum sfactor, GLenum dfactor) -{ - mGLState.setBlendFactors(sfactor, dfactor, sfactor, dfactor); -} - void Context::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { mGLState.setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); @@ -3475,119 +3430,4 @@ void Context::popDebugGroup() mGLState.getDebug().popGroup(); } -void Context::bufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) -{ - Buffer *buffer = mGLState.getTargetBuffer(target); - ASSERT(buffer); - handleError(buffer->bufferData(target, data, size, usage)); -} - -void Context::bufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) -{ - if (data == nullptr) - { - return; - } - - Buffer *buffer = mGLState.getTargetBuffer(target); - ASSERT(buffer); - handleError(buffer->bufferSubData(target, data, size, offset)); -} - -void Context::attachShader(GLuint program, GLuint shader) -{ - auto programObject = mResourceManager->getProgram(program); - auto shaderObject = mResourceManager->getShader(shader); - ASSERT(programObject && shaderObject); - programObject->attachShader(shaderObject); -} - -const Workarounds &Context::getWorkarounds() const -{ - return mWorkarounds; -} - -void Context::copyBufferSubData(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size) -{ - // if size is zero, the copy is a successful no-op - if (size == 0) - { - return; - } - - // TODO(jmadill): cache these. - Buffer *readBuffer = mGLState.getTargetBuffer(readTarget); - Buffer *writeBuffer = mGLState.getTargetBuffer(writeTarget); - - handleError(writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size)); -} - -void Context::bindAttribLocation(GLuint program, GLuint index, const GLchar *name) -{ - Program *programObject = getProgram(program); - // TODO(jmadill): Re-use this from the validation if possible. - ASSERT(programObject); - programObject->bindAttributeLocation(index, name); -} - -void Context::bindBuffer(GLenum target, GLuint buffer) -{ - switch (target) - { - case GL_ARRAY_BUFFER: - bindArrayBuffer(buffer); - break; - case GL_ELEMENT_ARRAY_BUFFER: - bindElementArrayBuffer(buffer); - break; - case GL_COPY_READ_BUFFER: - bindCopyReadBuffer(buffer); - break; - case GL_COPY_WRITE_BUFFER: - bindCopyWriteBuffer(buffer); - break; - case GL_PIXEL_PACK_BUFFER: - bindPixelPackBuffer(buffer); - break; - case GL_PIXEL_UNPACK_BUFFER: - bindPixelUnpackBuffer(buffer); - break; - case GL_UNIFORM_BUFFER: - bindGenericUniformBuffer(buffer); - break; - case GL_TRANSFORM_FEEDBACK_BUFFER: - bindGenericTransformFeedbackBuffer(buffer); - break; - - default: - UNREACHABLE(); - break; - } -} - -void Context::bindFramebuffer(GLenum target, GLuint framebuffer) -{ - if (target == GL_READ_FRAMEBUFFER || target == GL_FRAMEBUFFER) - { - bindReadFramebuffer(framebuffer); - } - - if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER) - { - bindDrawFramebuffer(framebuffer); - } -} - -void Context::bindRenderbuffer(GLenum target, GLuint renderbuffer) -{ - ASSERT(target == GL_RENDERBUFFER); - Renderbuffer *object = - mResourceManager->checkRenderbufferAllocation(mImplementation.get(), renderbuffer); - mGLState.setRenderbufferBinding(object); -} - } // namespace gl diff --git a/gfx/angle/src/libANGLE/Context.h b/gfx/angle/src/libANGLE/Context.h index 26c5d98e2..26182802f 100755 --- a/gfx/angle/src/libANGLE/Context.h +++ b/gfx/angle/src/libANGLE/Context.h @@ -22,7 +22,6 @@ #include "libANGLE/Error.h" #include "libANGLE/HandleAllocator.h" #include "libANGLE/VertexAttribute.h" -#include "libANGLE/Workarounds.h" #include "libANGLE/angletypes.h" namespace rx @@ -125,6 +124,7 @@ class Context final : public ValidationContext void bindTexture(GLenum target, GLuint handle); void bindReadFramebuffer(GLuint framebufferHandle); void bindDrawFramebuffer(GLuint framebufferHandle); + void bindRenderbuffer(GLuint renderbufferHandle); void bindVertexArray(GLuint vertexArrayHandle); void bindSampler(GLuint textureUnit, GLuint samplerHandle); void bindGenericUniformBuffer(GLuint bufferHandle); @@ -148,26 +148,25 @@ class Context final : public ValidationContext Error endQuery(GLenum target); Error queryCounter(GLuint id, GLenum target); void getQueryiv(GLenum target, GLenum pname, GLint *params); - void getQueryObjectiv(GLuint id, GLenum pname, GLint *params); - void getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params); - void getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params); - void getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params); + Error getQueryObjectiv(GLuint id, GLenum pname, GLint *params); + Error getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params); + Error getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params); + Error getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params); void setVertexAttribDivisor(GLuint index, GLuint divisor); void samplerParameteri(GLuint sampler, GLenum pname, GLint param); - void samplerParameteriv(GLuint sampler, GLenum pname, const GLint *param); void samplerParameterf(GLuint sampler, GLenum pname, GLfloat param); - void samplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *param); - - void getSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params); - void getSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params); + GLint getSamplerParameteri(GLuint sampler, GLenum pname); + GLfloat getSamplerParameterf(GLuint sampler, GLenum pname); void programParameteri(GLuint program, GLenum pname, GLint value); Buffer *getBuffer(GLuint handle) const; FenceNV *getFenceNV(GLuint handle); FenceSync *getFenceSync(GLsync handle) const; + Shader *getShader(GLuint handle) const; + Program *getProgram(GLuint handle) const; Texture *getTexture(GLuint handle) const; Framebuffer *getFramebuffer(GLuint handle) const; Renderbuffer *getRenderbuffer(GLuint handle) const; @@ -206,9 +205,7 @@ class Context final : public ValidationContext void activeTexture(GLenum texture); void blendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - void blendEquation(GLenum mode); void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); - void blendFunc(GLenum sfactor, GLenum dfactor); void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); void clearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); void clearDepthf(GLclampf depth); @@ -481,12 +478,9 @@ class Context final : public ValidationContext GLboolean unpackFlipY, GLboolean unpackPremultiplyAlpha, GLboolean unpackUnmultiplyAlpha); - void compressedCopyTextureCHROMIUM(GLuint sourceId, GLuint destId); void generateMipmap(GLenum target); - GLboolean enableExtension(const char *name); - Error flush(); Error finish(); @@ -573,20 +567,6 @@ class Context final : public ValidationContext GLint components, const GLfloat *coeffs); - void bufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); - void bufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); - void attachShader(GLuint program, GLuint shader); - void bindAttribLocation(GLuint program, GLuint index, const GLchar *name); - void bindBuffer(GLenum target, GLuint buffer); - void bindFramebuffer(GLenum target, GLuint framebuffer); - void bindRenderbuffer(GLenum target, GLuint renderbuffer); - - void copyBufferSubData(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size); - void handleError(const Error &error) override; GLenum getError(); @@ -599,14 +579,13 @@ class Context final : public ValidationContext EGLenum getClientType() const; EGLenum getRenderBuffer() const; - const char *getRendererString() const; + const std::string &getRendererString() const; - const char *getExtensionString() const; - const char *getExtensionString(size_t idx) const; + const std::string &getExtensionString() const; + const std::string &getExtensionString(size_t idx) const; size_t getExtensionStringCount() const; rx::ContextImpl *getImplementation() const { return mImplementation.get(); } - const Workarounds &getWorkarounds() const; private: void syncRendererState(); @@ -630,9 +609,7 @@ class Context final : public ValidationContext void initRendererString(); void initExtensionStrings(); - void initCaps(bool webGLContext); - void updateCaps(); - void initWorkarounds(); + void initCaps(); LabeledObject *getLabeledObject(GLenum identifier, GLuint name) const; LabeledObject *getLabeledObjectFromPtr(const void *ptr) const; @@ -650,6 +627,9 @@ class Context final : public ValidationContext State mGLState; + int mClientMajorVersion; + int mClientMinorVersion; + const egl::Config *mConfig; EGLenum mClientType; @@ -670,9 +650,9 @@ class Context final : public ValidationContext ResourceMap<TransformFeedback> mTransformFeedbackMap; HandleAllocator mTransformFeedbackAllocator; - const char *mRendererString; - const char *mExtensionString; - std::vector<const char *> mExtensionStrings; + std::string mRendererString; + std::string mExtensionString; + std::vector<std::string> mExtensionStrings; // Recorded errors typedef std::set<GLenum> ErrorSet; @@ -682,7 +662,6 @@ class Context final : public ValidationContext bool mHasBeenCurrent; bool mContextLost; GLenum mResetStatus; - bool mContextLostForced; GLenum mResetStrategy; bool mRobustAccess; egl::Surface *mCurrentSurface; @@ -697,8 +676,6 @@ class Context final : public ValidationContext State::DirtyObjects mClearDirtyObjects; State::DirtyBits mBlitDirtyBits; State::DirtyObjects mBlitDirtyObjects; - - Workarounds mWorkarounds; }; } // namespace gl diff --git a/gfx/angle/src/libANGLE/ContextState.cpp b/gfx/angle/src/libANGLE/ContextState.cpp index dbf867909..375893c72 100755 --- a/gfx/angle/src/libANGLE/ContextState.cpp +++ b/gfx/angle/src/libANGLE/ContextState.cpp @@ -15,23 +15,22 @@ namespace gl { ContextState::ContextState(uintptr_t contextIn, - const Version &clientVersion, + GLint clientMajorVersionIn, + GLint clientMinorVersionIn, State *stateIn, const Caps &capsIn, const TextureCapsMap &textureCapsIn, const Extensions &extensionsIn, const ResourceManager *resourceManagerIn, - const Limitations &limitationsIn, - const ResourceMap<Framebuffer> &framebufferMap) - : mClientVersion(clientVersion), + const Limitations &limitationsIn) + : mGLVersion(clientMajorVersionIn, clientMinorVersionIn), mContext(contextIn), mState(stateIn), mCaps(capsIn), mTextureCaps(textureCapsIn), mExtensions(extensionsIn), mResourceManager(resourceManagerIn), - mLimitations(limitationsIn), - mFramebufferMap(framebufferMap) + mLimitations(limitationsIn) { } @@ -44,24 +43,24 @@ const TextureCaps &ContextState::getTextureCap(GLenum internalFormat) const return mTextureCaps.get(internalFormat); } -ValidationContext::ValidationContext(const Version &clientVersion, +ValidationContext::ValidationContext(GLint clientMajorVersion, + GLint clientMinorVersion, State *state, const Caps &caps, const TextureCapsMap &textureCaps, const Extensions &extensions, const ResourceManager *resourceManager, const Limitations &limitations, - const ResourceMap<Framebuffer> &framebufferMap, bool skipValidation) : mState(reinterpret_cast<uintptr_t>(this), - clientVersion, + clientMajorVersion, + clientMinorVersion, state, caps, textureCaps, extensions, resourceManager, - limitations, - framebufferMap), + limitations), mSkipValidation(skipValidation) { } @@ -279,14 +278,6 @@ bool ValidationContext::getQueryParameterInfo(GLenum pname, GLenum *type, unsign *type = GL_INT; *numParams = 1; return true; - case GL_TEXTURE_BINDING_EXTERNAL_OES: - if (!getExtensions().eglStreamConsumerExternal && !getExtensions().eglImageExternal) - { - return false; - } - *type = GL_INT; - *numParams = 1; - return true; } if (getExtensions().debug) @@ -336,28 +327,6 @@ bool ValidationContext::getQueryParameterInfo(GLenum pname, GLenum *type, unsign } } - if (getExtensions().bindGeneratesResource) - { - switch (pname) - { - case GL_BIND_GENERATES_RESOURCE_CHROMIUM: - *type = GL_BOOL; - *numParams = 1; - return true; - } - } - - if (getExtensions().sRGBWriteControl) - { - switch (pname) - { - case GL_FRAMEBUFFER_SRGB_EXT: - *type = GL_BOOL; - *numParams = 1; - return true; - } - } - // Check for ES3.0+ parameter names which are also exposed as ES2 extensions switch (pname) { @@ -400,7 +369,9 @@ bool ValidationContext::getQueryParameterInfo(GLenum pname, GLenum *type, unsign return true; } - if (getClientVersion() < Version(3, 0)) + const GLVersion &glVersion = mState.getGLVersion(); + + if (!glVersion.isES3OrGreater()) { return false; } @@ -476,7 +447,7 @@ bool ValidationContext::getQueryParameterInfo(GLenum pname, GLenum *type, unsign } } - if (getClientVersion() < Version(3, 1)) + if (!glVersion.isES31()) { return false; } @@ -540,7 +511,9 @@ bool ValidationContext::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams) { - if (getClientVersion() < Version(3, 0)) + + const GLVersion &glVersion = mState.getGLVersion(); + if (!glVersion.isES3OrGreater()) { return false; } @@ -565,7 +538,7 @@ bool ValidationContext::getIndexedQueryParameterInfo(GLenum target, } } - if (getClientVersion() < Version(3, 1)) + if (!glVersion.isES31()) { return false; } @@ -584,35 +557,4 @@ bool ValidationContext::getIndexedQueryParameterInfo(GLenum target, return false; } -Program *ValidationContext::getProgram(GLuint handle) const -{ - return mState.mResourceManager->getProgram(handle); -} - -Shader *ValidationContext::getShader(GLuint handle) const -{ - return mState.mResourceManager->getShader(handle); -} - -bool ValidationContext::isTextureGenerated(GLuint texture) const -{ - return mState.mResourceManager->isTextureGenerated(texture); -} - -bool ValidationContext::isBufferGenerated(GLuint buffer) const -{ - return mState.mResourceManager->isBufferGenerated(buffer); -} - -bool ValidationContext::isRenderbufferGenerated(GLuint renderbuffer) const -{ - return mState.mResourceManager->isRenderbufferGenerated(renderbuffer); -} - -bool ValidationContext::isFramebufferGenerated(GLuint framebuffer) const -{ - ASSERT(mState.mFramebufferMap.find(0) != mState.mFramebufferMap.end()); - return mState.mFramebufferMap.find(framebuffer) != mState.mFramebufferMap.end(); -} - } // namespace gl diff --git a/gfx/angle/src/libANGLE/ContextState.h b/gfx/angle/src/libANGLE/ContextState.h index 494c1a3da..ecb3759f4 100755 --- a/gfx/angle/src/libANGLE/ContextState.h +++ b/gfx/angle/src/libANGLE/ContextState.h @@ -11,35 +11,51 @@ #include "common/angleutils.h" #include "libANGLE/State.h" -#include "libANGLE/Version.h" namespace gl { class ValidationContext; class ContextState; -static constexpr Version ES_2_0 = Version(2, 0); -static constexpr Version ES_3_0 = Version(3, 0); -static constexpr Version ES_3_1 = Version(3, 1); +class GLVersion final : angle::NonCopyable +{ + public: + GLVersion(GLint clientMajorVersion, GLint clientMinorVersion) + : mClientMajorVersion(clientMajorVersion), mClientMinorVersion(clientMinorVersion) + { + } + + GLint getClientMajorVersion() const { return mClientMajorVersion; } + GLint getClientMinorVersion() const { return mClientMinorVersion; } + + bool isES2() const { return mClientMajorVersion == 2; } + bool isES3() const { return mClientMajorVersion == 3 && mClientMinorVersion == 0; } + bool isES31() const { return mClientMajorVersion == 3 && mClientMinorVersion == 1; } + bool isES3OrGreater() const { return mClientMajorVersion >= 3; } + + private: + GLint mClientMajorVersion; + GLint mClientMinorVersion; +}; class ContextState final : public angle::NonCopyable { public: ContextState(uintptr_t context, - const Version &clientVersion, + GLint clientMajorVersion, + GLint clientMinorVersion, State *state, const Caps &caps, const TextureCapsMap &textureCaps, const Extensions &extensions, const ResourceManager *resourceManager, - const Limitations &limitations, - const ResourceMap<Framebuffer> &framebufferMap); + const Limitations &limitations); ~ContextState(); uintptr_t getContext() const { return mContext; } - GLint getClientMajorVersion() const { return mClientVersion.major; } - GLint getClientMinorVersion() const { return mClientVersion.minor; } - const Version &getClientVersion() const { return mClientVersion; } + GLint getClientMajorVersion() const { return mGLVersion.getClientMajorVersion(); } + GLint getClientMinorVersion() const { return mGLVersion.getClientMinorVersion(); } + const GLVersion &getGLVersion() const { return mGLVersion; } const State &getState() const { return *mState; } const Caps &getCaps() const { return mCaps; } const TextureCapsMap &getTextureCaps() const { return mTextureCaps; } @@ -53,7 +69,7 @@ class ContextState final : public angle::NonCopyable friend class Context; friend class ValidationContext; - Version mClientVersion; + GLVersion mGLVersion; uintptr_t mContext; State *mState; const Caps &mCaps; @@ -61,29 +77,28 @@ class ContextState final : public angle::NonCopyable const Extensions &mExtensions; const ResourceManager *mResourceManager; const Limitations &mLimitations; - const ResourceMap<Framebuffer> &mFramebufferMap; }; class ValidationContext : angle::NonCopyable { public: - ValidationContext(const Version &clientVersion, + ValidationContext(GLint clientMajorVersion, + GLint clientMinorVersion, State *state, const Caps &caps, const TextureCapsMap &textureCaps, const Extensions &extensions, const ResourceManager *resourceManager, const Limitations &limitations, - const ResourceMap<Framebuffer> &framebufferMap, bool skipValidation); virtual ~ValidationContext() {} virtual void handleError(const Error &error) = 0; const ContextState &getContextState() const { return mState; } - GLint getClientMajorVersion() const { return mState.getClientMajorVersion(); } - GLint getClientMinorVersion() const { return mState.getClientMinorVersion(); } - const Version &getClientVersion() const { return mState.getClientVersion(); } + int getClientMajorVersion() const { return mState.getClientMajorVersion(); } + int getClientMinorVersion() const { return mState.getClientMinorVersion(); } + const GLVersion &getGLVersion() const { return mState.mGLVersion; } const State &getGLState() const { return mState.getState(); } const Caps &getCaps() const { return mState.getCaps(); } const TextureCapsMap &getTextureCaps() const { return mState.getTextureCaps(); } @@ -95,14 +110,6 @@ class ValidationContext : angle::NonCopyable bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams); bool getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams); - Program *getProgram(GLuint handle) const; - Shader *getShader(GLuint handle) const; - - bool isTextureGenerated(GLuint texture) const; - bool isBufferGenerated(GLuint buffer) const; - bool isRenderbufferGenerated(GLuint renderbuffer) const; - bool isFramebufferGenerated(GLuint framebuffer) const; - protected: ContextState mState; bool mSkipValidation; diff --git a/gfx/angle/src/libANGLE/Display.cpp b/gfx/angle/src/libANGLE/Display.cpp index 39851f9f8..26bd0d28f 100755 --- a/gfx/angle/src/libANGLE/Display.cpp +++ b/gfx/angle/src/libANGLE/Display.cpp @@ -53,10 +53,6 @@ # endif #endif -#if defined(ANGLE_ENABLE_NULL) -#include "libANGLE/renderer/null/DisplayNULL.h" -#endif - namespace egl { @@ -213,12 +209,6 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap) break; #endif -#if defined(ANGLE_ENABLE_NULL) - case EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE: - impl = new rx::DisplayNULL(); - break; -#endif - default: UNREACHABLE(); break; @@ -587,11 +577,8 @@ Error Display::createPbufferSurface(const Config *configuration, const Attribute return egl::Error(EGL_SUCCESS); } -Error Display::createPbufferFromClientBuffer(const Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, - const AttributeMap &attribs, - Surface **outSurface) +Error Display::createPbufferFromClientBuffer(const Config *configuration, EGLClientBuffer shareHandle, + const AttributeMap &attribs, Surface **outSurface) { ASSERT(isInitialized()); @@ -601,7 +588,7 @@ Error Display::createPbufferFromClientBuffer(const Config *configuration, } std::unique_ptr<Surface> surface( - new PbufferSurface(mImplementation, configuration, buftype, clientBuffer, attribs)); + new PbufferSurface(mImplementation, configuration, shareHandle, attribs)); ANGLE_TRY(surface->initialize()); ASSERT(outSurface != nullptr); @@ -758,6 +745,7 @@ void Display::destroySurface(Surface *surface) } ASSERT(surfaceRemoved); + UNUSED_ASSERTION_VARIABLE(surfaceRemoved); } mImplementation->destroySurface(surface); @@ -841,15 +829,14 @@ bool Display::isValidConfig(const Config *config) const return mConfigSet.contains(config); } -bool Display::isValidContext(const gl::Context *context) const +bool Display::isValidContext(gl::Context *context) const { - return mContextSet.find(const_cast<gl::Context *>(context)) != mContextSet.end(); + return mContextSet.find(context) != mContextSet.end(); } -bool Display::isValidSurface(const Surface *surface) const +bool Display::isValidSurface(Surface *surface) const { - return mImplementation->getSurfaceSet().find(const_cast<Surface *>(surface)) != - mImplementation->getSurfaceSet().end(); + return mImplementation->getSurfaceSet().find(surface) != mImplementation->getSurfaceSet().end(); } bool Display::isValidImage(const Image *image) const @@ -887,10 +874,6 @@ static ClientExtensions GenerateClientExtensions() extensions.platformANGLEOpenGL = true; #endif -#if defined(ANGLE_ENABLE_NULL) - extensions.platformANGLENULL = true; -#endif - #if defined(ANGLE_ENABLE_D3D11) extensions.deviceCreation = true; extensions.deviceCreationD3D11 = true; @@ -935,8 +918,6 @@ void Display::initDisplayExtensions() // Some extensions are always available because they are implemented in the EGL layer. mDisplayExtensions.createContext = true; mDisplayExtensions.createContextNoError = true; - mDisplayExtensions.createContextWebGLCompatibility = true; - mDisplayExtensions.createContextBindGeneratesResource = true; // Force EGL_KHR_get_all_proc_addresses on. mDisplayExtensions.getAllProcAddresses = true; @@ -949,14 +930,6 @@ bool Display::isValidNativeWindow(EGLNativeWindowType window) const return mImplementation->isValidNativeWindow(window); } -Error Display::validateClientBuffer(const Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, - const AttributeMap &attribs) -{ - return mImplementation->validateClientBuffer(configuration, buftype, clientBuffer, attribs); -} - bool Display::isValidDisplay(const egl::Display *display) { const ANGLEPlatformDisplayMap *anglePlatformDisplayMap = GetANGLEPlatformDisplayMap(); diff --git a/gfx/angle/src/libANGLE/Display.h b/gfx/angle/src/libANGLE/Display.h index 15754ac37..c0dafb90f 100755 --- a/gfx/angle/src/libANGLE/Display.h +++ b/gfx/angle/src/libANGLE/Display.h @@ -57,10 +57,7 @@ class Display final : angle::NonCopyable Error createWindowSurface(const Config *configuration, EGLNativeWindowType window, const AttributeMap &attribs, Surface **outSurface); Error createPbufferSurface(const Config *configuration, const AttributeMap &attribs, Surface **outSurface); - Error createPbufferFromClientBuffer(const Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, - const AttributeMap &attribs, + Error createPbufferFromClientBuffer(const Config *configuration, EGLClientBuffer shareHandle, const AttributeMap &attribs, Surface **outSurface); Error createPixmapSurface(const Config *configuration, NativePixmapType nativePixmap, const AttributeMap &attribs, Surface **outSurface); @@ -85,17 +82,12 @@ class Display final : angle::NonCopyable bool isInitialized() const; bool isValidConfig(const Config *config) const; - bool isValidContext(const gl::Context *context) const; - bool isValidSurface(const egl::Surface *surface) const; + bool isValidContext(gl::Context *context) const; + bool isValidSurface(egl::Surface *surface) const; bool isValidImage(const Image *image) const; bool isValidStream(const Stream *stream) const; bool isValidNativeWindow(EGLNativeWindowType window) const; - Error validateClientBuffer(const Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, - const AttributeMap &attribs); - static bool isValidDisplay(const egl::Display *display); static bool isValidNativeDisplay(EGLNativeDisplayType display); static bool hasExistingWindowSurface(EGLNativeWindowType window); diff --git a/gfx/angle/src/libANGLE/HandleAllocator.cpp b/gfx/angle/src/libANGLE/HandleAllocator.cpp index c090b3dfc..4815855d5 100755 --- a/gfx/angle/src/libANGLE/HandleAllocator.cpp +++ b/gfx/angle/src/libANGLE/HandleAllocator.cpp @@ -63,14 +63,11 @@ GLuint HandleAllocator::allocate() GLuint freeListHandle = listIt->begin; ASSERT(freeListHandle > 0); + listIt->begin++; if (listIt->begin == listIt->end) { mUnallocatedList.erase(listIt); } - else - { - listIt->begin++; - } return freeListHandle; } @@ -104,7 +101,7 @@ void HandleAllocator::reserve(GLuint handle) if (handle == begin || handle == end) { - if (begin == end) + if (begin + 1 == end) { mUnallocatedList.erase(boundIt); } @@ -120,12 +117,18 @@ void HandleAllocator::reserve(GLuint handle) return; } - ASSERT(begin < handle && handle < end); - // need to split the range auto placementIt = mUnallocatedList.erase(boundIt); - placementIt = mUnallocatedList.insert(placementIt, HandleRange(handle + 1, end)); - mUnallocatedList.insert(placementIt, HandleRange(begin, handle - 1)); + + if (handle + 1 != end) + { + placementIt = mUnallocatedList.insert(placementIt, HandleRange(handle + 1, end)); + } + if (begin != handle) + { + ASSERT(begin < handle); + mUnallocatedList.insert(placementIt, HandleRange(begin, handle)); + } } } // namespace gl diff --git a/gfx/angle/src/libANGLE/HandleAllocator.h b/gfx/angle/src/libANGLE/HandleAllocator.h index c7e0a0d85..1888d57cf 100755 --- a/gfx/angle/src/libANGLE/HandleAllocator.h +++ b/gfx/angle/src/libANGLE/HandleAllocator.h @@ -41,7 +41,6 @@ class HandleAllocator final : angle::NonCopyable typedef std::vector<GLuint> HandleList; HandleList mFreeValues; - // Represents an inclusive range [begin, end] struct HandleRange { HandleRange(GLuint beginIn, GLuint endIn) : begin(beginIn), end(endIn) {} diff --git a/gfx/angle/src/libANGLE/HandleAllocator_unittest.cpp b/gfx/angle/src/libANGLE/HandleAllocator_unittest.cpp index bfcbd8f01..726b64bab 100755 --- a/gfx/angle/src/libANGLE/HandleAllocator_unittest.cpp +++ b/gfx/angle/src/libANGLE/HandleAllocator_unittest.cpp @@ -90,7 +90,8 @@ TEST(HandleAllocatorTest, Reallocation) EXPECT_EQ(finalResult, 1); } -// The following test covers reserving a handle with max uint value. See http://anglebug.com/1052 +// The following test covers reserving a handle with max uint value. +// See http://anglebug.com/1052 TEST(HandleAllocatorTest, ReserveMaxUintHandle) { gl::HandleAllocator allocator; @@ -102,19 +103,6 @@ TEST(HandleAllocatorTest, ReserveMaxUintHandle) EXPECT_EQ(1u, normalHandle); } -// The following test covers reserving a handle with max uint value minus one then max uint value. -TEST(HandleAllocatorTest, ReserveMaxUintHandle2) -{ - gl::HandleAllocator allocator; - - GLuint maxUintHandle = std::numeric_limits<GLuint>::max(); - allocator.reserve(maxUintHandle - 1); - allocator.reserve(maxUintHandle); - - GLuint normalHandle = allocator.allocate(); - EXPECT_EQ(1u, normalHandle); -} - // To test if the allocator keep the handle in a sorted order. TEST(HandleAllocatorTest, SortedOrderHandle) { diff --git a/gfx/angle/src/libANGLE/HandleRangeAllocator.cpp b/gfx/angle/src/libANGLE/HandleRangeAllocator.cpp index 500a79629..f219f954f 100755 --- a/gfx/angle/src/libANGLE/HandleRangeAllocator.cpp +++ b/gfx/angle/src/libANGLE/HandleRangeAllocator.cpp @@ -49,6 +49,7 @@ GLuint HandleRangeAllocator::allocateAtOrAbove(GLuint wanted) } GLuint firstId = current->first; + UNUSED_ASSERTION_VARIABLE(firstId); GLuint lastId = current->second; ASSERT(wanted >= firstId); diff --git a/gfx/angle/src/libANGLE/ImageIndex.cpp b/gfx/angle/src/libANGLE/ImageIndex.cpp index f74ce19d9..38c1941a3 100755 --- a/gfx/angle/src/libANGLE/ImageIndex.cpp +++ b/gfx/angle/src/libANGLE/ImageIndex.cpp @@ -135,12 +135,7 @@ ImageIndexIterator::ImageIndexIterator(GLenum type, const Range<GLint> &mipRange GLint ImageIndexIterator::maxLayer() const { - if (mLayerCounts) - { - ASSERT(mCurrentMip >= 0); - return (mCurrentMip < mMipRange.end) ? mLayerCounts[mCurrentMip] : 0; - } - return mLayerRange.end; + return (mLayerCounts ? static_cast<GLint>(mLayerCounts[mCurrentMip]) : mLayerRange.end); } ImageIndex ImageIndexIterator::next() @@ -154,29 +149,21 @@ ImageIndex ImageIndexIterator::next() if (mCurrentLayer != ImageIndex::ENTIRE_LEVEL) { - if (mCurrentLayer < maxLayer() - 1) + if (mCurrentLayer < maxLayer()-1) { mCurrentLayer++; } - else if (mCurrentMip < mMipRange.end - 1) + else if (mCurrentMip < mMipRange.end-1) { mCurrentMip++; mCurrentLayer = mLayerRange.start; } - else - { - done(); - } } - else if (mCurrentMip < mMipRange.end - 1) + else if (mCurrentMip < mMipRange.end-1) { mCurrentMip++; mCurrentLayer = mLayerRange.start; } - else - { - done(); - } return value; } @@ -198,10 +185,4 @@ bool ImageIndexIterator::hasNext() const return (mCurrentMip < mMipRange.end || mCurrentLayer < maxLayer()); } -void ImageIndexIterator::done() -{ - mCurrentMip = mMipRange.end; - mCurrentLayer = maxLayer(); } - -} // namespace gl diff --git a/gfx/angle/src/libANGLE/ImageIndex.h b/gfx/angle/src/libANGLE/ImageIndex.h index 5961f0cb0..52ac40c45 100755 --- a/gfx/angle/src/libANGLE/ImageIndex.h +++ b/gfx/angle/src/libANGLE/ImageIndex.h @@ -68,7 +68,6 @@ class ImageIndexIterator const Range<GLint> &layerRange, const GLsizei *layerCounts); GLint maxLayer() const; - void done(); GLenum mType; Range<GLint> mMipRange; diff --git a/gfx/angle/src/libANGLE/ImageIndexIterator_unittest.cpp b/gfx/angle/src/libANGLE/ImageIndexIterator_unittest.cpp index 2f97e8eba..2dc0b2ab7 100755 --- a/gfx/angle/src/libANGLE/ImageIndexIterator_unittest.cpp +++ b/gfx/angle/src/libANGLE/ImageIndexIterator_unittest.cpp @@ -41,8 +41,6 @@ TEST(ImageIndexTest, Iterator2D) EXPECT_EQ(current.mipIndex, nextIndex.mipIndex); EXPECT_EQ(current.layerIndex, nextIndex.layerIndex); } - - EXPECT_FALSE(iter.hasNext()); } TEST(ImageIndexTest, IteratorCube) @@ -66,8 +64,6 @@ TEST(ImageIndexTest, IteratorCube) EXPECT_TRUE(nextIndex.hasLayer()); } } - - EXPECT_FALSE(iter.hasNext()); } TEST(ImageIndexTest, Iterator3D) @@ -89,8 +85,6 @@ TEST(ImageIndexTest, Iterator3D) EXPECT_TRUE(nextIndex.hasLayer()); } } - - EXPECT_FALSE(iter.hasNext()); } TEST(ImageIndexTest, Iterator2DArray) @@ -115,8 +109,6 @@ TEST(ImageIndexTest, Iterator2DArray) EXPECT_TRUE(nextIndex.hasLayer()); } } - - EXPECT_FALSE(iter.hasNext()); } } // namespace diff --git a/gfx/angle/src/libANGLE/Path.h b/gfx/angle/src/libANGLE/Path.h index b103c8460..40e2cf289 100755 --- a/gfx/angle/src/libANGLE/Path.h +++ b/gfx/angle/src/libANGLE/Path.h @@ -49,7 +49,9 @@ class Path final : angle::NonCopyable bool hasPathData() const { return mHasData; } - rx::PathImpl *getImplementation() const { return mPath; } + const rx::PathImpl *getImplementation() const { return mPath; } + + rx::PathImpl *getImplementation() { return mPath; } private: rx::PathImpl *mPath; diff --git a/gfx/angle/src/libANGLE/Program.cpp b/gfx/angle/src/libANGLE/Program.cpp index 06d8d1534..7f4226da1 100755 --- a/gfx/angle/src/libANGLE/Program.cpp +++ b/gfx/angle/src/libANGLE/Program.cpp @@ -377,27 +377,39 @@ const std::string &Program::getLabel() const return mState.mLabel; } -void Program::attachShader(Shader *shader) +bool Program::attachShader(Shader *shader) { switch (shader->getType()) { case GL_VERTEX_SHADER: { - ASSERT(!mState.mAttachedVertexShader); + if (mState.mAttachedVertexShader) + { + return false; + } + mState.mAttachedVertexShader = shader; mState.mAttachedVertexShader->addRef(); break; } case GL_FRAGMENT_SHADER: { - ASSERT(!mState.mAttachedFragmentShader); + if (mState.mAttachedFragmentShader) + { + return false; + } + mState.mAttachedFragmentShader = shader; mState.mAttachedFragmentShader->addRef(); break; } case GL_COMPUTE_SHADER: { - ASSERT(!mState.mAttachedComputeShader); + if (mState.mAttachedComputeShader) + { + return false; + } + mState.mAttachedComputeShader = shader; mState.mAttachedComputeShader->addRef(); break; @@ -405,6 +417,8 @@ void Program::attachShader(Shader *shader) default: UNREACHABLE(); } + + return true; } bool Program::detachShader(Shader *shader) @@ -509,7 +523,7 @@ BindingInfo Program::getFragmentInputBindingInfo(GLint index) const if (arrayIndex == GL_INVALID_INDEX) arrayIndex = 0; - ret.name = in.mappedName + "[" + ToString(arrayIndex) + "]"; + ret.name = in.mappedName + "[" + std::to_string(arrayIndex) + "]"; } else { @@ -597,10 +611,11 @@ Error Program::link(const ContextState &data) return NoError(); } - ANGLE_TRY_RESULT(mProgram->link(data, mInfoLog), mLinked); - if (!mLinked) + rx::LinkResult result = mProgram->link(data, mInfoLog); + + if (result.error.isError() || !result.linkSuccess) { - return NoError(); + return result.error; } } else @@ -653,10 +668,10 @@ Error Program::link(const ContextState &data) linkOutputVariables(); - ANGLE_TRY_RESULT(mProgram->link(data, mInfoLog), mLinked); - if (!mLinked) + rx::LinkResult result = mProgram->link(data, mInfoLog); + if (result.error.isError() || !result.linkSuccess) { - return NoError(); + return result.error; } gatherTransformFeedbackVaryings(mergedVaryings); @@ -664,6 +679,7 @@ Error Program::link(const ContextState &data) gatherInterfaceBlockInfo(); + mLinked = true; return NoError(); } @@ -843,9 +859,14 @@ Error Program::loadBinary(GLenum binaryFormat, const void *binary, GLsizei lengt stream.readInt(&mSamplerUniformRange.start); stream.readInt(&mSamplerUniformRange.end); - ANGLE_TRY_RESULT(mProgram->load(mInfoLog, &stream), mLinked); + rx::LinkResult result = mProgram->load(mInfoLog, &stream); + if (result.error.isError() || !result.linkSuccess) + { + return result.error; + } - return NoError(); + mLinked = true; + return Error(GL_NO_ERROR); #endif // #if ANGLE_PROGRAM_BINARY_LOAD == ANGLE_ENABLED } @@ -1336,128 +1357,128 @@ GLuint Program::getUniformIndex(const std::string &name) const void Program::setUniform1fv(GLint location, GLsizei count, const GLfloat *v) { - GLsizei clampedCount = setUniformInternal(location, count, 1, v); - mProgram->setUniform1fv(location, clampedCount, v); + setUniformInternal(location, count * 1, v); + mProgram->setUniform1fv(location, count, v); } void Program::setUniform2fv(GLint location, GLsizei count, const GLfloat *v) { - GLsizei clampedCount = setUniformInternal(location, count, 2, v); - mProgram->setUniform2fv(location, clampedCount, v); + setUniformInternal(location, count * 2, v); + mProgram->setUniform2fv(location, count, v); } void Program::setUniform3fv(GLint location, GLsizei count, const GLfloat *v) { - GLsizei clampedCount = setUniformInternal(location, count, 3, v); - mProgram->setUniform3fv(location, clampedCount, v); + setUniformInternal(location, count * 3, v); + mProgram->setUniform3fv(location, count, v); } void Program::setUniform4fv(GLint location, GLsizei count, const GLfloat *v) { - GLsizei clampedCount = setUniformInternal(location, count, 4, v); - mProgram->setUniform4fv(location, clampedCount, v); + setUniformInternal(location, count * 4, v); + mProgram->setUniform4fv(location, count, v); } void Program::setUniform1iv(GLint location, GLsizei count, const GLint *v) { - GLsizei clampedCount = setUniformInternal(location, count, 1, v); - mProgram->setUniform1iv(location, clampedCount, v); + setUniformInternal(location, count * 1, v); + mProgram->setUniform1iv(location, count, v); } void Program::setUniform2iv(GLint location, GLsizei count, const GLint *v) { - GLsizei clampedCount = setUniformInternal(location, count, 2, v); - mProgram->setUniform2iv(location, clampedCount, v); + setUniformInternal(location, count * 2, v); + mProgram->setUniform2iv(location, count, v); } void Program::setUniform3iv(GLint location, GLsizei count, const GLint *v) { - GLsizei clampedCount = setUniformInternal(location, count, 3, v); - mProgram->setUniform3iv(location, clampedCount, v); + setUniformInternal(location, count * 3, v); + mProgram->setUniform3iv(location, count, v); } void Program::setUniform4iv(GLint location, GLsizei count, const GLint *v) { - GLsizei clampedCount = setUniformInternal(location, count, 4, v); - mProgram->setUniform4iv(location, clampedCount, v); + setUniformInternal(location, count * 4, v); + mProgram->setUniform4iv(location, count, v); } void Program::setUniform1uiv(GLint location, GLsizei count, const GLuint *v) { - GLsizei clampedCount = setUniformInternal(location, count, 1, v); - mProgram->setUniform1uiv(location, clampedCount, v); + setUniformInternal(location, count * 1, v); + mProgram->setUniform1uiv(location, count, v); } void Program::setUniform2uiv(GLint location, GLsizei count, const GLuint *v) { - GLsizei clampedCount = setUniformInternal(location, count, 2, v); - mProgram->setUniform2uiv(location, clampedCount, v); + setUniformInternal(location, count * 2, v); + mProgram->setUniform2uiv(location, count, v); } void Program::setUniform3uiv(GLint location, GLsizei count, const GLuint *v) { - GLsizei clampedCount = setUniformInternal(location, count, 3, v); - mProgram->setUniform3uiv(location, clampedCount, v); + setUniformInternal(location, count * 3, v); + mProgram->setUniform3uiv(location, count, v); } void Program::setUniform4uiv(GLint location, GLsizei count, const GLuint *v) { - GLsizei clampedCount = setUniformInternal(location, count, 4, v); - mProgram->setUniform4uiv(location, clampedCount, v); + setUniformInternal(location, count * 4, v); + mProgram->setUniform4uiv(location, count, v); } void Program::setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) { - GLsizei clampedCount = setMatrixUniformInternal<2, 2>(location, count, transpose, v); - mProgram->setUniformMatrix2fv(location, clampedCount, transpose, v); + setMatrixUniformInternal<2, 2>(location, count, transpose, v); + mProgram->setUniformMatrix2fv(location, count, transpose, v); } void Program::setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) { - GLsizei clampedCount = setMatrixUniformInternal<3, 3>(location, count, transpose, v); - mProgram->setUniformMatrix3fv(location, clampedCount, transpose, v); + setMatrixUniformInternal<3, 3>(location, count, transpose, v); + mProgram->setUniformMatrix3fv(location, count, transpose, v); } void Program::setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) { - GLsizei clampedCount = setMatrixUniformInternal<4, 4>(location, count, transpose, v); - mProgram->setUniformMatrix4fv(location, clampedCount, transpose, v); + setMatrixUniformInternal<4, 4>(location, count, transpose, v); + mProgram->setUniformMatrix4fv(location, count, transpose, v); } void Program::setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) { - GLsizei clampedCount = setMatrixUniformInternal<2, 3>(location, count, transpose, v); - mProgram->setUniformMatrix2x3fv(location, clampedCount, transpose, v); + setMatrixUniformInternal<2, 3>(location, count, transpose, v); + mProgram->setUniformMatrix2x3fv(location, count, transpose, v); } void Program::setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) { - GLsizei clampedCount = setMatrixUniformInternal<2, 4>(location, count, transpose, v); - mProgram->setUniformMatrix2x4fv(location, clampedCount, transpose, v); + setMatrixUniformInternal<2, 4>(location, count, transpose, v); + mProgram->setUniformMatrix2x4fv(location, count, transpose, v); } void Program::setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) { - GLsizei clampedCount = setMatrixUniformInternal<3, 2>(location, count, transpose, v); - mProgram->setUniformMatrix3x2fv(location, clampedCount, transpose, v); + setMatrixUniformInternal<3, 2>(location, count, transpose, v); + mProgram->setUniformMatrix3x2fv(location, count, transpose, v); } void Program::setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) { - GLsizei clampedCount = setMatrixUniformInternal<3, 4>(location, count, transpose, v); - mProgram->setUniformMatrix3x4fv(location, clampedCount, transpose, v); + setMatrixUniformInternal<3, 4>(location, count, transpose, v); + mProgram->setUniformMatrix3x4fv(location, count, transpose, v); } void Program::setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) { - GLsizei clampedCount = setMatrixUniformInternal<4, 2>(location, count, transpose, v); - mProgram->setUniformMatrix4x2fv(location, clampedCount, transpose, v); + setMatrixUniformInternal<4, 2>(location, count, transpose, v); + mProgram->setUniformMatrix4x2fv(location, count, transpose, v); } void Program::setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) { - GLsizei clampedCount = setMatrixUniformInternal<4, 3>(location, count, transpose, v); - mProgram->setUniformMatrix4x3fv(location, clampedCount, transpose, v); + setMatrixUniformInternal<4, 3>(location, count, transpose, v); + mProgram->setUniformMatrix4x3fv(location, count, transpose, v); } void Program::getUniformfv(GLint location, GLfloat *v) const @@ -1612,6 +1633,44 @@ void Program::getActiveUniformBlockName(GLuint uniformBlockIndex, GLsizei bufSiz } } +void Program::getActiveUniformBlockiv(GLuint uniformBlockIndex, GLenum pname, GLint *params) const +{ + ASSERT( + uniformBlockIndex < + mState.mUniformBlocks.size()); // index must be smaller than getActiveUniformBlockCount() + + const UniformBlock &uniformBlock = mState.mUniformBlocks[uniformBlockIndex]; + + switch (pname) + { + case GL_UNIFORM_BLOCK_DATA_SIZE: + *params = static_cast<GLint>(uniformBlock.dataSize); + break; + case GL_UNIFORM_BLOCK_NAME_LENGTH: + *params = + static_cast<GLint>(uniformBlock.name.size() + 1 + (uniformBlock.isArray ? 3 : 0)); + break; + case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: + *params = static_cast<GLint>(uniformBlock.memberUniformIndexes.size()); + break; + case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: + { + for (unsigned int blockMemberIndex = 0; blockMemberIndex < uniformBlock.memberUniformIndexes.size(); blockMemberIndex++) + { + params[blockMemberIndex] = static_cast<GLint>(uniformBlock.memberUniformIndexes[blockMemberIndex]); + } + } + break; + case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: + *params = static_cast<GLint>(uniformBlock.vertexStaticUse); + break; + case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: + *params = static_cast<GLint>(uniformBlock.fragmentStaticUse); + break; + default: UNREACHABLE(); + } +} + GLint Program::getActiveUniformBlockMaxLength() const { int maxLength = 0; @@ -2401,6 +2460,7 @@ bool Program::linkValidateTransformFeedback(InfoLog &infoLog, // All transform feedback varyings are expected to exist since packVaryings checks for them. ASSERT(found); + UNUSED_ASSERTION_VARIABLE(found); } if (mState.mTransformFeedbackBufferMode == GL_INTERLEAVED_ATTRIBS && @@ -2751,13 +2811,7 @@ void Program::defineUniformBlock(const sh::InterfaceBlock &interfaceBlock, GLenu size_t blockSize = 0; // Don't define this block at all if it's not active in the implementation. - std::stringstream blockNameStr; - blockNameStr << interfaceBlock.name; - if (interfaceBlock.arraySize > 0) - { - blockNameStr << "[0]"; - } - if (!mProgram->getUniformBlockSize(blockNameStr.str(), &blockSize)) + if (!mProgram->getUniformBlockSize(interfaceBlock.name, &blockSize)) { return; } @@ -2803,10 +2857,15 @@ void Program::defineUniformBlock(const sh::InterfaceBlock &interfaceBlock, GLenu UNREACHABLE(); } - // Since all block elements in an array share the same active uniforms, they will all be - // active once any uniform member is used. So, since interfaceBlock.name[0] was active, - // here we will add every block element in the array. - block.dataSize = static_cast<unsigned int>(blockSize); + // TODO(jmadill): Determine if we can ever have an inactive array element block. + size_t blockElementSize = 0; + if (!mProgram->getUniformBlockSize(block.nameWithArrayIndex(), &blockElementSize)) + { + continue; + } + + ASSERT(blockElementSize == blockSize); + block.dataSize = static_cast<unsigned int>(blockElementSize); mState.mUniformBlocks.push_back(block); } } @@ -2842,32 +2901,18 @@ void Program::defineUniformBlock(const sh::InterfaceBlock &interfaceBlock, GLenu } template <typename T> -GLsizei Program::setUniformInternal(GLint location, GLsizei countIn, int vectorSize, const T *v) +void Program::setUniformInternal(GLint location, GLsizei count, const T *v) { const VariableLocation &locationInfo = mState.mUniformLocations[location]; LinkedUniform *linkedUniform = &mState.mUniforms[locationInfo.index]; uint8_t *destPointer = linkedUniform->getDataPtrToElement(locationInfo.element); - // OpenGL ES 3.0.4 spec pg 67: "Values for any array element that exceeds the highest array - // element index used, as reported by GetActiveUniform, will be ignored by the GL." - unsigned int remainingElements = linkedUniform->elementCount() - locationInfo.element; - GLsizei maxElementCount = - static_cast<GLsizei>(remainingElements * linkedUniform->getElementComponents()); - - GLsizei count = countIn; - GLsizei clampedCount = count * vectorSize; - if (clampedCount > maxElementCount) - { - clampedCount = maxElementCount; - count = maxElementCount / vectorSize; - } - if (VariableComponentType(linkedUniform->type) == GL_BOOL) { // Do a cast conversion for boolean types. From the spec: // "The uniform is set to FALSE if the input value is 0 or 0.0f, and set to TRUE otherwise." GLint *destAsInt = reinterpret_cast<GLint *>(destPointer); - for (GLsizei component = 0; component < clampedCount; ++component) + for (GLsizei component = 0; component < count; ++component) { destAsInt[component] = (v[component] != static_cast<T>(0) ? GL_TRUE : GL_FALSE); } @@ -2875,39 +2920,32 @@ GLsizei Program::setUniformInternal(GLint location, GLsizei countIn, int vectorS else { // Invalide the validation cache if we modify the sampler data. - if (linkedUniform->isSampler() && memcmp(destPointer, v, sizeof(T) * clampedCount) != 0) + if (linkedUniform->isSampler() && memcmp(destPointer, v, sizeof(T) * count) != 0) { mCachedValidateSamplersResult.reset(); } - memcpy(destPointer, v, sizeof(T) * clampedCount); + memcpy(destPointer, v, sizeof(T) * count); } - - return count; } template <size_t cols, size_t rows, typename T> -GLsizei Program::setMatrixUniformInternal(GLint location, - GLsizei count, - GLboolean transpose, - const T *v) +void Program::setMatrixUniformInternal(GLint location, + GLsizei count, + GLboolean transpose, + const T *v) { if (!transpose) { - return setUniformInternal(location, count, cols * rows, v); + setUniformInternal(location, count * cols * rows, v); + return; } // Perform a transposing copy. const VariableLocation &locationInfo = mState.mUniformLocations[location]; LinkedUniform *linkedUniform = &mState.mUniforms[locationInfo.index]; T *destPtr = reinterpret_cast<T *>(linkedUniform->getDataPtrToElement(locationInfo.element)); - - // OpenGL ES 3.0.4 spec pg 67: "Values for any array element that exceeds the highest array - // element index used, as reported by GetActiveUniform, will be ignored by the GL." - unsigned int remainingElements = linkedUniform->elementCount() - locationInfo.element; - GLsizei clampedCount = std::min(count, static_cast<GLsizei>(remainingElements)); - - for (GLsizei element = 0; element < clampedCount; ++element) + for (GLsizei element = 0; element < count; ++element) { size_t elementOffset = element * rows * cols; @@ -2919,8 +2957,6 @@ GLsizei Program::setMatrixUniformInternal(GLint location, } } } - - return clampedCount; } template <typename DestT> diff --git a/gfx/angle/src/libANGLE/Program.h b/gfx/angle/src/libANGLE/Program.h index 18bec495f..03212a5cd 100755 --- a/gfx/angle/src/libANGLE/Program.h +++ b/gfx/angle/src/libANGLE/Program.h @@ -241,16 +241,13 @@ class Program final : angle::NonCopyable, public LabeledObject void setLabel(const std::string &label) override; const std::string &getLabel() const override; - rx::ProgramImpl *getImplementation() const { return mProgram; } + rx::ProgramImpl *getImplementation() { return mProgram; } + const rx::ProgramImpl *getImplementation() const { return mProgram; } - void attachShader(Shader *shader); + bool attachShader(Shader *shader); bool detachShader(Shader *shader); int getAttachedShadersCount() const; - const Shader *getAttachedVertexShader() const { return mState.mAttachedVertexShader; } - const Shader *getAttachedFragmentShader() const { return mState.mAttachedFragmentShader; } - const Shader *getAttachedComputeShader() const { return mState.mAttachedComputeShader; } - void bindAttributeLocation(GLuint index, const char *name); void bindUniformLocation(GLuint index, const char *name); @@ -327,6 +324,7 @@ class Program final : angle::NonCopyable, public LabeledObject void getUniformuiv(GLint location, GLuint *params) const; void getActiveUniformBlockName(GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName) const; + void getActiveUniformBlockiv(GLuint uniformBlockIndex, GLenum pname, GLint *params) const; GLuint getActiveUniformBlockCount() const; GLint getActiveUniformBlockMaxLength() const; @@ -460,15 +458,11 @@ class Program final : angle::NonCopyable, public LabeledObject void defineUniformBlock(const sh::InterfaceBlock &interfaceBlock, GLenum shaderType); - // Both these function update the cached uniform values and return a modified "count" - // so that the uniform update doesn't overflow the uniform. template <typename T> - GLsizei setUniformInternal(GLint location, GLsizei count, int vectorSize, const T *v); + void setUniformInternal(GLint location, GLsizei count, const T *v); + template <size_t cols, size_t rows, typename T> - GLsizei setMatrixUniformInternal(GLint location, - GLsizei count, - GLboolean transpose, - const T *v); + void setMatrixUniformInternal(GLint location, GLsizei count, GLboolean transpose, const T *v); template <typename DestT> void getUniformInternal(GLint location, DestT *dataOut) const; diff --git a/gfx/angle/src/libANGLE/Renderbuffer.cpp b/gfx/angle/src/libANGLE/Renderbuffer.cpp index 7b30a46be..977117d24 100755 --- a/gfx/angle/src/libANGLE/Renderbuffer.cpp +++ b/gfx/angle/src/libANGLE/Renderbuffer.cpp @@ -95,12 +95,17 @@ Error Renderbuffer::setStorageEGLImageTarget(egl::Image *image) return NoError(); } -rx::RenderbufferImpl *Renderbuffer::getImplementation() const +rx::RenderbufferImpl *Renderbuffer::getImplementation() { ASSERT(mRenderbuffer); return mRenderbuffer; } +const rx::RenderbufferImpl *Renderbuffer::getImplementation() const +{ + return mRenderbuffer; +} + GLsizei Renderbuffer::getWidth() const { return mWidth; diff --git a/gfx/angle/src/libANGLE/Renderbuffer.h b/gfx/angle/src/libANGLE/Renderbuffer.h index 57cc08279..eceda70bc 100755 --- a/gfx/angle/src/libANGLE/Renderbuffer.h +++ b/gfx/angle/src/libANGLE/Renderbuffer.h @@ -42,7 +42,8 @@ class Renderbuffer final : public egl::ImageSibling, Error setStorageMultisample(size_t samples, GLenum internalformat, size_t width, size_t height); Error setStorageEGLImageTarget(egl::Image *imageTarget); - rx::RenderbufferImpl *getImplementation() const; + rx::RenderbufferImpl *getImplementation(); + const rx::RenderbufferImpl *getImplementation() const; GLsizei getWidth() const; GLsizei getHeight() const; diff --git a/gfx/angle/src/libANGLE/ResourceManager.cpp b/gfx/angle/src/libANGLE/ResourceManager.cpp index cfb965d92..3fdfe47d9 100755 --- a/gfx/angle/src/libANGLE/ResourceManager.cpp +++ b/gfx/angle/src/libANGLE/ResourceManager.cpp @@ -309,7 +309,7 @@ Buffer *ResourceManager::getBuffer(unsigned int handle) } } -Shader *ResourceManager::getShader(unsigned int handle) const +Shader *ResourceManager::getShader(unsigned int handle) { auto shader = mShaderMap.find(handle); @@ -438,7 +438,7 @@ Buffer *ResourceManager::checkBufferAllocation(rx::GLImplFactory *factory, GLuin return bufferMapIt->second; } - Buffer *buffer = new Buffer(factory, handle); + Buffer *buffer = new Buffer(factory->createBuffer(), handle); buffer->addRef(); if (handleAllocated) @@ -544,19 +544,4 @@ bool ResourceManager::isSampler(GLuint sampler) return mSamplerMap.find(sampler) != mSamplerMap.end(); } -bool ResourceManager::isTextureGenerated(GLuint texture) const -{ - return texture == 0 || mTextureMap.find(texture) != mTextureMap.end(); -} - -bool ResourceManager::isBufferGenerated(GLuint buffer) const -{ - return buffer == 0 || mBufferMap.find(buffer) != mBufferMap.end(); -} - -bool ResourceManager::isRenderbufferGenerated(GLuint renderbuffer) const -{ - return renderbuffer == 0 || mRenderbufferMap.find(renderbuffer) != mRenderbufferMap.end(); -} - } // namespace gl diff --git a/gfx/angle/src/libANGLE/ResourceManager.h b/gfx/angle/src/libANGLE/ResourceManager.h index f6a0002ed..a673257e1 100755 --- a/gfx/angle/src/libANGLE/ResourceManager.h +++ b/gfx/angle/src/libANGLE/ResourceManager.h @@ -64,7 +64,7 @@ class ResourceManager : angle::NonCopyable void deletePaths(GLuint first, GLsizei range); Buffer *getBuffer(GLuint handle); - Shader *getShader(GLuint handle) const; + Shader *getShader(GLuint handle); Program *getProgram(GLuint handle) const; Texture *getTexture(GLuint handle); Renderbuffer *getRenderbuffer(GLuint handle); @@ -85,11 +85,6 @@ class ResourceManager : angle::NonCopyable bool isSampler(GLuint sampler); - // GL_CHROMIUM_bind_generates_resource - bool isTextureGenerated(GLuint texture) const; - bool isBufferGenerated(GLuint buffer) const; - bool isRenderbufferGenerated(GLuint renderbuffer) const; - private: void createTextureInternal(GLuint handle); diff --git a/gfx/angle/src/libANGLE/ResourceManager_unittest.cpp b/gfx/angle/src/libANGLE/ResourceManager_unittest.cpp index a9dff145b..ded2dc538 100755 --- a/gfx/angle/src/libANGLE/ResourceManager_unittest.cpp +++ b/gfx/angle/src/libANGLE/ResourceManager_unittest.cpp @@ -48,7 +48,7 @@ TEST_F(ResourceManagerTest, ReallocateBoundTexture) TEST_F(ResourceManagerTest, ReallocateBoundBuffer) { - EXPECT_CALL(mMockFactory, createBuffer(_)).Times(1).RetiresOnSaturation(); + EXPECT_CALL(mMockFactory, createBuffer()).Times(1).RetiresOnSaturation(); mResourceManager->checkBufferAllocation(&mMockFactory, 1); GLuint newBuffer = mResourceManager->createBuffer(); diff --git a/gfx/angle/src/libANGLE/Sampler.cpp b/gfx/angle/src/libANGLE/Sampler.cpp index 369c3cbaa..dc1d7c94a 100755 --- a/gfx/angle/src/libANGLE/Sampler.cpp +++ b/gfx/angle/src/libANGLE/Sampler.cpp @@ -135,24 +135,18 @@ GLenum Sampler::getCompareFunc() const return mSamplerState.compareFunc; } -void Sampler::setSRGBDecode(GLenum sRGBDecode) -{ - mSamplerState.sRGBDecode = sRGBDecode; -} - -GLenum Sampler::getSRGBDecode() const -{ - return mSamplerState.sRGBDecode; -} - const SamplerState &Sampler::getSamplerState() const { return mSamplerState; } -rx::SamplerImpl *Sampler::getImplementation() const +const rx::SamplerImpl *Sampler::getImplementation() const { return mImpl; } +rx::SamplerImpl *Sampler::getImplementation() +{ + return mImpl; +} } diff --git a/gfx/angle/src/libANGLE/Sampler.h b/gfx/angle/src/libANGLE/Sampler.h index 156d61f66..f950bc04e 100755 --- a/gfx/angle/src/libANGLE/Sampler.h +++ b/gfx/angle/src/libANGLE/Sampler.h @@ -62,12 +62,10 @@ class Sampler final : public RefCountObject, public LabeledObject void setCompareFunc(GLenum compareFunc); GLenum getCompareFunc() const; - void setSRGBDecode(GLenum sRGBDecode); - GLenum getSRGBDecode() const; - const SamplerState &getSamplerState() const; - rx::SamplerImpl *getImplementation() const; + const rx::SamplerImpl *getImplementation() const; + rx::SamplerImpl *getImplementation(); private: rx::SamplerImpl *mImpl; diff --git a/gfx/angle/src/libANGLE/Shader.cpp b/gfx/angle/src/libANGLE/Shader.cpp index a4c68950b..904345d58 100755 --- a/gfx/angle/src/libANGLE/Shader.cpp +++ b/gfx/angle/src/libANGLE/Shader.cpp @@ -20,7 +20,6 @@ #include "libANGLE/renderer/GLImplFactory.h" #include "libANGLE/renderer/ShaderImpl.h" #include "libANGLE/ResourceManager.h" -#include "libANGLE/Context.h" namespace gl { @@ -228,7 +227,7 @@ void Shader::getTranslatedSourceWithDebugInfo(GLsizei bufSize, GLsizei *length, getSourceImpl(debugInfo, bufSize, length, buffer); } -void Shader::compile(const Context *context) +void Shader::compile(Compiler *compiler) { mState.mTranslatedSource.clear(); mInfoLog.clear(); @@ -239,23 +238,14 @@ void Shader::compile(const Context *context) mState.mActiveAttributes.clear(); mState.mActiveOutputVariables.clear(); - Compiler *compiler = context->getCompiler(); ShHandle compilerHandle = compiler->getCompilerHandle(mState.mShaderType); std::stringstream sourceStream; std::string sourcePath; - ShCompileOptions additionalOptions = + int additionalOptions = mImplementation->prepareSourceAndReturnOptions(&sourceStream, &sourcePath); - ShCompileOptions compileOptions = (SH_OBJECT_CODE | SH_VARIABLES | additionalOptions); - - // Add default options to WebGL shaders to prevent unexpected behavior during compilation. - if (context->getExtensions().webglCompatibility) - { - compileOptions |= SH_LIMIT_CALL_STACK_DEPTH; - compileOptions |= SH_LIMIT_EXPRESSION_COMPLEXITY; - compileOptions |= SH_ENFORCE_PACKING_RESTRICTIONS; - } + int compileOptions = (SH_OBJECT_CODE | SH_VARIABLES | additionalOptions); // Some targets (eg D3D11 Feature Level 9_3 and below) do not support non-constant loop indexes // in fragment shaders. Shader compilation will fail. To provide a better error message we can @@ -276,17 +266,17 @@ void Shader::compile(const Context *context) sourceCStrings.push_back(sourceString.c_str()); bool result = - sh::Compile(compilerHandle, &sourceCStrings[0], sourceCStrings.size(), compileOptions); + ShCompile(compilerHandle, &sourceCStrings[0], sourceCStrings.size(), compileOptions); if (!result) { - mInfoLog = sh::GetInfoLog(compilerHandle); + mInfoLog = ShGetInfoLog(compilerHandle); TRACE("\n%s", mInfoLog.c_str()); mCompiled = false; return; } - mState.mTranslatedSource = sh::GetObjectCode(compilerHandle); + mState.mTranslatedSource = ShGetObjectCode(compilerHandle); #ifndef NDEBUG // Prefix translated shader with commented out un-translated shader. @@ -311,22 +301,22 @@ void Shader::compile(const Context *context) #endif // Gather the shader information - mState.mShaderVersion = sh::GetShaderVersion(compilerHandle); + mState.mShaderVersion = ShGetShaderVersion(compilerHandle); - mState.mVaryings = GetShaderVariables(sh::GetVaryings(compilerHandle)); - mState.mUniforms = GetShaderVariables(sh::GetUniforms(compilerHandle)); - mState.mInterfaceBlocks = GetShaderVariables(sh::GetInterfaceBlocks(compilerHandle)); + mState.mVaryings = GetShaderVariables(ShGetVaryings(compilerHandle)); + mState.mUniforms = GetShaderVariables(ShGetUniforms(compilerHandle)); + mState.mInterfaceBlocks = GetShaderVariables(ShGetInterfaceBlocks(compilerHandle)); switch (mState.mShaderType) { case GL_COMPUTE_SHADER: { - mState.mLocalSize = sh::GetComputeShaderLocalGroupSize(compilerHandle); + mState.mLocalSize = ShGetComputeShaderLocalGroupSize(compilerHandle); break; } case GL_VERTEX_SHADER: { - mState.mActiveAttributes = GetActiveShaderVariables(sh::GetAttributes(compilerHandle)); + mState.mActiveAttributes = GetActiveShaderVariables(ShGetAttributes(compilerHandle)); break; } case GL_FRAGMENT_SHADER: @@ -334,7 +324,7 @@ void Shader::compile(const Context *context) // TODO(jmadill): Figure out why we only sort in the FS, and if we need to. std::sort(mState.mVaryings.begin(), mState.mVaryings.end(), CompareShaderVar); mState.mActiveOutputVariables = - GetActiveShaderVariables(sh::GetOutputVariables(compilerHandle)); + GetActiveShaderVariables(ShGetOutputVariables(compilerHandle)); break; } default: diff --git a/gfx/angle/src/libANGLE/Shader.h b/gfx/angle/src/libANGLE/Shader.h index ee42a80a3..d73400a80 100755 --- a/gfx/angle/src/libANGLE/Shader.h +++ b/gfx/angle/src/libANGLE/Shader.h @@ -36,7 +36,6 @@ class Compiler; class ContextState; struct Limitations; class ResourceManager; -class Context; class ShaderState final : angle::NonCopyable { @@ -97,7 +96,7 @@ class Shader final : angle::NonCopyable, public LabeledObject GLenum getType() const { return mType; } GLuint getHandle() const; - rx::ShaderImpl *getImplementation() const { return mImplementation; } + const rx::ShaderImpl *getImplementation() const { return mImplementation; } void deleteSource(); void setSource(GLsizei count, const char *const *string, const GLint *length); @@ -111,7 +110,7 @@ class Shader final : angle::NonCopyable, public LabeledObject void getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) const; void getTranslatedSourceWithDebugInfo(GLsizei bufSize, GLsizei *length, char *buffer) const; - void compile(const Context *context); + void compile(Compiler *compiler); bool isCompiled() const { return mCompiled; } void addRef(); diff --git a/gfx/angle/src/libANGLE/State.cpp b/gfx/angle/src/libANGLE/State.cpp index a56bb1c5d..6c3f04ded 100755 --- a/gfx/angle/src/libANGLE/State.cpp +++ b/gfx/angle/src/libANGLE/State.cpp @@ -50,7 +50,6 @@ State::State() mLineWidth(0), mGenerateMipmapHint(GL_NONE), mFragmentShaderDerivativeHint(GL_NONE), - mBindGeneratesResource(true), mNearZ(0), mFarZ(0), mReadFramebuffer(nullptr), @@ -60,8 +59,7 @@ State::State() mActiveSampler(0), mPrimitiveRestart(false), mMultiSampling(false), - mSampleAlphaToOne(false), - mFramebufferSRGB(true) + mSampleAlphaToOne(false) { } @@ -72,9 +70,8 @@ State::~State() void State::initialize(const Caps &caps, const Extensions &extensions, - const Version &clientVersion, - bool debug, - bool bindGeneratesResource) + GLuint clientVersion, + bool debug) { mMaxDrawBuffers = caps.maxDrawBuffers; mMaxCombinedTextureImageUnits = caps.maxCombinedTextureImageUnits; @@ -140,8 +137,6 @@ void State::initialize(const Caps &caps, mGenerateMipmapHint = GL_DONT_CARE; mFragmentShaderDerivativeHint = GL_DONT_CARE; - mBindGeneratesResource = bindGeneratesResource; - mLineWidth = 1.0f; mViewport.x = 0; @@ -164,7 +159,7 @@ void State::initialize(const Caps &caps, mSamplerTextures[GL_TEXTURE_2D].resize(caps.maxCombinedTextureImageUnits); mSamplerTextures[GL_TEXTURE_CUBE_MAP].resize(caps.maxCombinedTextureImageUnits); - if (clientVersion >= Version(3, 0)) + if (clientVersion >= 3) { // TODO: These could also be enabled via extension mSamplerTextures[GL_TEXTURE_2D_ARRAY].resize(caps.maxCombinedTextureImageUnits); @@ -638,9 +633,6 @@ void State::setEnableFeature(GLenum feature, bool enabled) case GL_DEBUG_OUTPUT: mDebug.setOutputEnabled(enabled); break; - case GL_FRAMEBUFFER_SRGB_EXT: - setFramebufferSRGB(enabled); - break; default: UNREACHABLE(); } } @@ -666,10 +658,6 @@ bool State::getEnableFeature(GLenum feature) const return mDebug.isOutputSynchronous(); case GL_DEBUG_OUTPUT: return mDebug.isOutputEnabled(); - case GL_BIND_GENERATES_RESOURCE_CHROMIUM: - return isBindGeneratesResourceEnabled(); - case GL_FRAMEBUFFER_SRGB_EXT: - return getFramebufferSRGB(); default: UNREACHABLE(); return false; } } @@ -700,11 +688,6 @@ void State::setFragmentShaderDerivativeHint(GLenum hint) // Ignore for now. It is valid for implementations to ignore hint. } -bool State::isBindGeneratesResourceEnabled() const -{ - return mBindGeneratesResource; -} - void State::setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height) { mViewport.x = x; @@ -1462,17 +1445,6 @@ GLuint State::getPathStencilMask() const return mPathStencilMask; } -void State::setFramebufferSRGB(bool sRGB) -{ - mFramebufferSRGB = sRGB; - mDirtyBits.set(DIRTY_BIT_FRAMEBUFFER_SRGB); -} - -bool State::getFramebufferSRGB() const -{ - return mFramebufferSRGB; -} - void State::getBooleanv(GLenum pname, GLboolean *params) { switch (pname) @@ -1514,12 +1486,6 @@ void State::getBooleanv(GLenum pname, GLboolean *params) case GL_SAMPLE_ALPHA_TO_ONE_EXT: *params = mSampleAlphaToOne; break; - case GL_BIND_GENERATES_RESOURCE_CHROMIUM: - *params = isBindGeneratesResourceEnabled() ? GL_TRUE : GL_FALSE; - break; - case GL_FRAMEBUFFER_SRGB_EXT: - *params = getFramebufferSRGB() ? GL_TRUE : GL_FALSE; - break; default: UNREACHABLE(); break; @@ -1764,11 +1730,6 @@ void State::getIntegerv(const ContextState &data, GLenum pname, GLint *params) *params = getSamplerTextureId(static_cast<unsigned int>(mActiveSampler), GL_TEXTURE_2D_ARRAY); break; - case GL_TEXTURE_BINDING_EXTERNAL_OES: - ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits); - *params = getSamplerTextureId(static_cast<unsigned int>(mActiveSampler), - GL_TEXTURE_EXTERNAL_OES); - break; case GL_UNIFORM_BUFFER_BINDING: *params = mGenericUniformBuffer.id(); break; diff --git a/gfx/angle/src/libANGLE/State.h b/gfx/angle/src/libANGLE/State.h index 160a7abd8..e91affe53 100755 --- a/gfx/angle/src/libANGLE/State.h +++ b/gfx/angle/src/libANGLE/State.h @@ -21,7 +21,6 @@ #include "libANGLE/Sampler.h" #include "libANGLE/Texture.h" #include "libANGLE/TransformFeedback.h" -#include "libANGLE/Version.h" #include "libANGLE/VertexAttribute.h" #include "libANGLE/angletypes.h" @@ -42,9 +41,8 @@ class State : angle::NonCopyable void initialize(const Caps &caps, const Extensions &extensions, - const Version &clientVersion, - bool debug, - bool bindGeneratesResource); + GLuint clientVersion, + bool debug); void reset(); // State chunk getters @@ -149,9 +147,6 @@ class State : angle::NonCopyable void setGenerateMipmapHint(GLenum hint); void setFragmentShaderDerivativeHint(GLenum hint); - // GL_CHROMIUM_bind_generates_resource - bool isBindGeneratesResourceEnabled() const; - // Viewport state setter/getter void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height); const Rectangle &getViewport() const; @@ -291,10 +286,6 @@ class State : angle::NonCopyable GLint getPathStencilRef() const; GLuint getPathStencilMask() const; - // GL_EXT_sRGB_write_control - void setFramebufferSRGB(bool sRGB); - bool getFramebufferSRGB() const; - // State query functions void getBooleanv(GLenum pname, GLboolean *params); void getFloatv(GLenum pname, GLfloat *params); @@ -368,7 +359,6 @@ class State : angle::NonCopyable DIRTY_BIT_PATH_RENDERING_MATRIX_MV, // CHROMIUM_path_rendering path model view matrix DIRTY_BIT_PATH_RENDERING_MATRIX_PROJ, // CHROMIUM_path_rendering path projection matrix DIRTY_BIT_PATH_RENDERING_STENCIL_STATE, - DIRTY_BIT_FRAMEBUFFER_SRGB, // GL_EXT_sRGB_write_control DIRTY_BIT_CURRENT_VALUE_0, DIRTY_BIT_CURRENT_VALUE_MAX = DIRTY_BIT_CURRENT_VALUE_0 + MAX_VERTEX_ATTRIBS, DIRTY_BIT_INVALID = DIRTY_BIT_CURRENT_VALUE_MAX, @@ -428,8 +418,6 @@ class State : angle::NonCopyable GLenum mGenerateMipmapHint; GLenum mFragmentShaderDerivativeHint; - bool mBindGeneratesResource; - Rectangle mViewport; float mNearZ; float mFarZ; @@ -485,9 +473,6 @@ class State : angle::NonCopyable GLint mPathStencilRef; GLuint mPathStencilMask; - // GL_EXT_sRGB_write_control - bool mFramebufferSRGB; - DirtyBits mDirtyBits; DirtyObjects mDirtyObjects; }; diff --git a/gfx/angle/src/libANGLE/Surface.cpp b/gfx/angle/src/libANGLE/Surface.cpp index 43e71df31..6028b7f67 100755 --- a/gfx/angle/src/libANGLE/Surface.cpp +++ b/gfx/angle/src/libANGLE/Surface.cpp @@ -138,11 +138,6 @@ Error Surface::swap() return mImplementation->swap(); } -Error Surface::swapWithDamage(EGLint *rects, EGLint n_rects) -{ - return mImplementation->swapWithDamage(rects, n_rects); -} - Error Surface::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) { return mImplementation->postSubBuffer(x, y, width, height); @@ -211,23 +206,19 @@ EGLint Surface::getHeight() const Error Surface::bindTexImage(gl::Texture *texture, EGLint buffer) { ASSERT(!mTexture.get()); - ANGLE_TRY(mImplementation->bindTexImage(texture, buffer)); texture->bindTexImageFromSurface(this); mTexture.set(texture); - - return Error(EGL_SUCCESS); + return mImplementation->bindTexImage(texture, buffer); } Error Surface::releaseTexImage(EGLint buffer) { - ANGLE_TRY(mImplementation->releaseTexImage(buffer)); - ASSERT(mTexture.get()); mTexture->releaseTexImageFromSurface(); mTexture.set(nullptr); - return Error(EGL_SUCCESS); + return mImplementation->releaseTexImage(buffer); } void Surface::releaseTexImageFromTexture() @@ -307,13 +298,12 @@ PbufferSurface::PbufferSurface(rx::EGLImplFactory *implFactory, PbufferSurface::PbufferSurface(rx::EGLImplFactory *implFactory, const Config *config, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const AttributeMap &attribs) : Surface(EGL_PBUFFER_BIT, config, attribs) { mImplementation = - implFactory->createPbufferFromClientBuffer(mState, config, buftype, clientBuffer, attribs); + implFactory->createPbufferFromClientBuffer(mState, config, shareHandle, attribs); } PbufferSurface::~PbufferSurface() diff --git a/gfx/angle/src/libANGLE/Surface.h b/gfx/angle/src/libANGLE/Surface.h index fc6cc6ae7..4e60771af 100755 --- a/gfx/angle/src/libANGLE/Surface.h +++ b/gfx/angle/src/libANGLE/Surface.h @@ -55,7 +55,6 @@ class Surface : public gl::FramebufferAttachmentObject Error initialize(); Error swap(); - Error swapWithDamage(EGLint *rects, EGLint n_rects); Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height); Error querySurfacePointerANGLE(EGLint attribute, void **value); Error bindTexImage(gl::Texture *texture, EGLint buffer); @@ -162,8 +161,7 @@ class PbufferSurface final : public Surface const AttributeMap &attribs); PbufferSurface(rx::EGLImplFactory *implFactory, const Config *config, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const AttributeMap &attribs); ~PbufferSurface() override; }; diff --git a/gfx/angle/src/libANGLE/Surface_unittest.cpp b/gfx/angle/src/libANGLE/Surface_unittest.cpp index 7f361eedd..e4fe782ee 100755 --- a/gfx/angle/src/libANGLE/Surface_unittest.cpp +++ b/gfx/angle/src/libANGLE/Surface_unittest.cpp @@ -31,7 +31,6 @@ class MockSurfaceImpl : public rx::SurfaceImpl MOCK_METHOD0(initialize, egl::Error()); MOCK_METHOD1(createDefaultFramebuffer, rx::FramebufferImpl *(const gl::FramebufferState &data)); MOCK_METHOD0(swap, egl::Error()); - MOCK_METHOD2(swapWithDamage, egl::Error(EGLint *, EGLint)); MOCK_METHOD4(postSubBuffer, egl::Error(EGLint, EGLint, EGLint, EGLint)); MOCK_METHOD2(querySurfacePointerANGLE, egl::Error(EGLint, void**)); MOCK_METHOD2(bindTexImage, egl::Error(gl::Texture*, EGLint)); diff --git a/gfx/angle/src/libANGLE/Texture.cpp b/gfx/angle/src/libANGLE/Texture.cpp index edba11bd4..ae46973d0 100755 --- a/gfx/angle/src/libANGLE/Texture.cpp +++ b/gfx/angle/src/libANGLE/Texture.cpp @@ -301,13 +301,9 @@ bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState, // depth and stencil format (see table 3.13), the value of TEXTURE_COMPARE_- // MODE is NONE, and either the magnification filter is not NEAREST or the mini- // fication filter is neither NEAREST nor NEAREST_MIPMAP_NEAREST. - if (baseImageDesc.format.info->depthBits > 0 && data.getClientMajorVersion() >= 3) + if (baseImageDesc.format.info->depthBits > 0 && data.getClientMajorVersion() > 2) { - // Note: we restrict this validation to sized types. For the OES_depth_textures - // extension, due to some underspecification problems, we must allow linear filtering - // for legacy compatibility with WebGL 1. - // See http://crbug.com/649200 - if (samplerState.compareMode == GL_NONE && baseImageDesc.format.sized) + if (samplerState.compareMode == GL_NONE) { if ((samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST) || @@ -516,7 +512,6 @@ Texture::~Texture() void Texture::setLabel(const std::string &label) { mLabel = label; - mDirtyBits.set(DIRTY_BIT_LABEL); } const std::string &Texture::getLabel() const @@ -532,7 +527,6 @@ GLenum Texture::getTarget() const void Texture::setSwizzleRed(GLenum swizzleRed) { mState.mSwizzleState.swizzleRed = swizzleRed; - mDirtyBits.set(DIRTY_BIT_SWIZZLE_RED); } GLenum Texture::getSwizzleRed() const @@ -543,7 +537,6 @@ GLenum Texture::getSwizzleRed() const void Texture::setSwizzleGreen(GLenum swizzleGreen) { mState.mSwizzleState.swizzleGreen = swizzleGreen; - mDirtyBits.set(DIRTY_BIT_SWIZZLE_GREEN); } GLenum Texture::getSwizzleGreen() const @@ -554,7 +547,6 @@ GLenum Texture::getSwizzleGreen() const void Texture::setSwizzleBlue(GLenum swizzleBlue) { mState.mSwizzleState.swizzleBlue = swizzleBlue; - mDirtyBits.set(DIRTY_BIT_SWIZZLE_BLUE); } GLenum Texture::getSwizzleBlue() const @@ -565,7 +557,6 @@ GLenum Texture::getSwizzleBlue() const void Texture::setSwizzleAlpha(GLenum swizzleAlpha) { mState.mSwizzleState.swizzleAlpha = swizzleAlpha; - mDirtyBits.set(DIRTY_BIT_SWIZZLE_ALPHA); } GLenum Texture::getSwizzleAlpha() const @@ -576,7 +567,6 @@ GLenum Texture::getSwizzleAlpha() const void Texture::setMinFilter(GLenum minFilter) { mState.mSamplerState.minFilter = minFilter; - mDirtyBits.set(DIRTY_BIT_MIN_FILTER); } GLenum Texture::getMinFilter() const @@ -587,7 +577,6 @@ GLenum Texture::getMinFilter() const void Texture::setMagFilter(GLenum magFilter) { mState.mSamplerState.magFilter = magFilter; - mDirtyBits.set(DIRTY_BIT_MAG_FILTER); } GLenum Texture::getMagFilter() const @@ -598,7 +587,6 @@ GLenum Texture::getMagFilter() const void Texture::setWrapS(GLenum wrapS) { mState.mSamplerState.wrapS = wrapS; - mDirtyBits.set(DIRTY_BIT_WRAP_S); } GLenum Texture::getWrapS() const @@ -609,7 +597,6 @@ GLenum Texture::getWrapS() const void Texture::setWrapT(GLenum wrapT) { mState.mSamplerState.wrapT = wrapT; - mDirtyBits.set(DIRTY_BIT_WRAP_T); } GLenum Texture::getWrapT() const @@ -620,7 +607,6 @@ GLenum Texture::getWrapT() const void Texture::setWrapR(GLenum wrapR) { mState.mSamplerState.wrapR = wrapR; - mDirtyBits.set(DIRTY_BIT_WRAP_R); } GLenum Texture::getWrapR() const @@ -631,7 +617,6 @@ GLenum Texture::getWrapR() const void Texture::setMaxAnisotropy(float maxAnisotropy) { mState.mSamplerState.maxAnisotropy = maxAnisotropy; - mDirtyBits.set(DIRTY_BIT_MAX_ANISOTROPY); } float Texture::getMaxAnisotropy() const @@ -642,7 +627,6 @@ float Texture::getMaxAnisotropy() const void Texture::setMinLod(GLfloat minLod) { mState.mSamplerState.minLod = minLod; - mDirtyBits.set(DIRTY_BIT_MIN_LOD); } GLfloat Texture::getMinLod() const @@ -653,7 +637,6 @@ GLfloat Texture::getMinLod() const void Texture::setMaxLod(GLfloat maxLod) { mState.mSamplerState.maxLod = maxLod; - mDirtyBits.set(DIRTY_BIT_MAX_LOD); } GLfloat Texture::getMaxLod() const @@ -664,7 +647,6 @@ GLfloat Texture::getMaxLod() const void Texture::setCompareMode(GLenum compareMode) { mState.mSamplerState.compareMode = compareMode; - mDirtyBits.set(DIRTY_BIT_COMPARE_MODE); } GLenum Texture::getCompareMode() const @@ -675,7 +657,6 @@ GLenum Texture::getCompareMode() const void Texture::setCompareFunc(GLenum compareFunc) { mState.mSamplerState.compareFunc = compareFunc; - mDirtyBits.set(DIRTY_BIT_COMPARE_FUNC); } GLenum Texture::getCompareFunc() const @@ -683,17 +664,6 @@ GLenum Texture::getCompareFunc() const return mState.mSamplerState.compareFunc; } -void Texture::setSRGBDecode(GLenum sRGBDecode) -{ - mState.mSamplerState.sRGBDecode = sRGBDecode; - mDirtyBits.set(DIRTY_BIT_SRGB_DECODE); -} - -GLenum Texture::getSRGBDecode() const -{ - return mState.mSamplerState.sRGBDecode; -} - const SamplerState &Texture::getSamplerState() const { return mState.mSamplerState; @@ -704,7 +674,6 @@ void Texture::setBaseLevel(GLuint baseLevel) if (mState.setBaseLevel(baseLevel)) { mTexture->setBaseLevel(mState.getEffectiveBaseLevel()); - mDirtyBits.set(DIRTY_BIT_BASE_LEVEL); } } @@ -716,7 +685,6 @@ GLuint Texture::getBaseLevel() const void Texture::setMaxLevel(GLuint maxLevel) { mState.setMaxLevel(maxLevel); - mDirtyBits.set(DIRTY_BIT_MAX_LEVEL); } GLuint Texture::getMaxLevel() const @@ -737,7 +705,6 @@ GLuint Texture::getImmutableLevels() const void Texture::setUsage(GLenum usage) { mState.mUsage = usage; - mDirtyBits.set(DIRTY_BIT_USAGE); } GLenum Texture::getUsage() const @@ -932,21 +899,6 @@ Error Texture::copySubTexture(const Offset &destOffset, unpackUnmultiplyAlpha, source); } -Error Texture::copyCompressedTexture(const Texture *source) -{ - // Release from previous calls to eglBindTexImage, to avoid calling the Impl after - releaseTexImageInternal(); - orphanImages(); - - ANGLE_TRY(mTexture->copyCompressedTexture(source)); - - ASSERT(source->getTarget() != GL_TEXTURE_CUBE_MAP && getTarget() != GL_TEXTURE_CUBE_MAP); - const auto &sourceDesc = source->mState.getImageDesc(source->getTarget(), 0); - mState.setImageDesc(getTarget(), 0, sourceDesc); - - return NoError(); -} - Error Texture::setStorage(GLenum target, GLsizei levels, GLenum internalFormat, const Extents &size) { ASSERT(target == mState.mTarget); @@ -961,14 +913,6 @@ Error Texture::setStorage(GLenum target, GLsizei levels, GLenum internalFormat, mState.mImmutableLevels = static_cast<GLuint>(levels); mState.clearImageDescs(); mState.setImageDescChain(0, static_cast<GLuint>(levels - 1), size, Format(internalFormat)); - - // Changing the texture to immutable can trigger a change in the base and max levels: - // GLES 3.0.4 section 3.8.10 pg 158: - // "For immutable-format textures, levelbase is clamped to the range[0;levels],levelmax is then - // clamped to the range[levelbase;levels]. - mDirtyBits.set(DIRTY_BIT_BASE_LEVEL); - mDirtyBits.set(DIRTY_BIT_MAX_LEVEL); - mDirtyChannel.signal(); return NoError(); @@ -991,7 +935,6 @@ Error Texture::generateMipmap() if (maxLevel > baseLevel) { - syncImplState(); ANGLE_TRY(mTexture->generateMipmap()); const ImageDesc &baseImageInfo = @@ -1140,12 +1083,6 @@ GLuint Texture::getId() const return id(); } -void Texture::syncImplState() -{ - mTexture->syncState(mDirtyBits); - mDirtyBits.reset(); -} - rx::FramebufferAttachmentObjectImpl *Texture::getAttachmentImpl() const { return mTexture; diff --git a/gfx/angle/src/libANGLE/Texture.h b/gfx/angle/src/libANGLE/Texture.h index 583a69a7b..36cef52cd 100755 --- a/gfx/angle/src/libANGLE/Texture.h +++ b/gfx/angle/src/libANGLE/Texture.h @@ -217,9 +217,6 @@ class Texture final : public egl::ImageSibling, void setCompareFunc(GLenum compareFunc); GLenum getCompareFunc() const; - void setSRGBDecode(GLenum sRGBDecode); - GLenum getSRGBDecode() const; - const SamplerState &getSamplerState() const; void setBaseLevel(GLuint baseLevel); @@ -298,7 +295,6 @@ class Texture final : public egl::ImageSibling, bool unpackPremultiplyAlpha, bool unpackUnmultiplyAlpha, const Texture *source); - Error copyCompressedTexture(const Texture *source); Error setStorage(GLenum target, GLsizei levels, GLenum internalFormat, const Extents &size); @@ -309,7 +305,8 @@ class Texture final : public egl::ImageSibling, egl::Surface *getBoundSurface() const; egl::Stream *getBoundStream() const; - rx::TextureImpl *getImplementation() const { return mTexture; } + rx::TextureImpl *getImplementation() { return mTexture; } + const rx::TextureImpl *getImplementation() const { return mTexture; } // FramebufferAttachmentObject implementation Extents getAttachmentSize(const FramebufferAttachment::Target &target) const override; @@ -320,40 +317,6 @@ class Texture final : public egl::ImageSibling, void onDetach() override; GLuint getId() const override; - enum DirtyBitType - { - // Sampler state - DIRTY_BIT_MIN_FILTER, - DIRTY_BIT_MAG_FILTER, - DIRTY_BIT_WRAP_S, - DIRTY_BIT_WRAP_T, - DIRTY_BIT_WRAP_R, - DIRTY_BIT_MAX_ANISOTROPY, - DIRTY_BIT_MIN_LOD, - DIRTY_BIT_MAX_LOD, - DIRTY_BIT_COMPARE_MODE, - DIRTY_BIT_COMPARE_FUNC, - DIRTY_BIT_SRGB_DECODE, - - // Texture state - DIRTY_BIT_SWIZZLE_RED, - DIRTY_BIT_SWIZZLE_GREEN, - DIRTY_BIT_SWIZZLE_BLUE, - DIRTY_BIT_SWIZZLE_ALPHA, - DIRTY_BIT_BASE_LEVEL, - DIRTY_BIT_MAX_LEVEL, - - // Misc - DIRTY_BIT_LABEL, - DIRTY_BIT_USAGE, - - DIRTY_BIT_COUNT, - }; - using DirtyBits = std::bitset<DIRTY_BIT_COUNT>; - - void syncImplState(); - bool hasAnyDirtyBit() const { return mDirtyBits.any(); } - private: rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override; @@ -370,7 +333,6 @@ class Texture final : public egl::ImageSibling, void releaseImageFromStream(); TextureState mState; - DirtyBits mDirtyBits; rx::TextureImpl *mTexture; std::string mLabel; diff --git a/gfx/angle/src/libANGLE/Thread.cpp b/gfx/angle/src/libANGLE/Thread.cpp deleted file mode 100644 index 1abf449ce..000000000 --- a/gfx/angle/src/libANGLE/Thread.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// -// Copyright(c) 2016 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. -// - -// Thread.cpp : Defines the Thread class which represents a global EGL thread. - -#include "libANGLE/Thread.h" - -#include "libANGLE/Context.h" -#include "libANGLE/Error.h" - -namespace egl -{ -Thread::Thread() - : mError(EGL_SUCCESS), - mAPI(EGL_OPENGL_ES_API), - mDisplay(static_cast<egl::Display *>(EGL_NO_DISPLAY)), - mDrawSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)), - mReadSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)), - mContext(static_cast<gl::Context *>(EGL_NO_CONTEXT)) -{ -} - -void Thread::setError(const Error &error) -{ - mError = error.getCode(); -} - -EGLint Thread::getError() const -{ - return mError; -} - -void Thread::setAPI(EGLenum api) -{ - mAPI = api; -} - -EGLenum Thread::getAPI() const -{ - return mAPI; -} - -void Thread::setCurrent(Display *display, - Surface *drawSurface, - Surface *readSurface, - gl::Context *context) -{ - mDisplay = display; - mDrawSurface = drawSurface; - mReadSurface = readSurface; - mContext = context; -} - -Display *Thread::getDisplay() const -{ - return mDisplay; -} - -Surface *Thread::getDrawSurface() const -{ - return mDrawSurface; -} - -Surface *Thread::getReadSurface() const -{ - return mReadSurface; -} - -gl::Context *Thread::getContext() const -{ - return mContext; -} - -gl::Context *Thread::getValidContext() const -{ - if (mContext && mContext->isContextLost()) - { - mContext->handleError(gl::Error(GL_OUT_OF_MEMORY, "Context has been lost.")); - return nullptr; - } - - return mContext; -} - -} // namespace egl diff --git a/gfx/angle/src/libANGLE/Thread.h b/gfx/angle/src/libANGLE/Thread.h deleted file mode 100644 index 7a67dc62b..000000000 --- a/gfx/angle/src/libANGLE/Thread.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// Copyright(c) 2016 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. -// - -// Thread.h : Defines the Thread class which represents a global EGL thread. - -#ifndef LIBANGLE_THREAD_H_ -#define LIBANGLE_THREAD_H_ - -#include <EGL/egl.h> - -namespace gl -{ -class Context; -} // namespace gl - -namespace egl -{ -class Error; -class Display; -class Surface; - -class Thread -{ - public: - Thread(); - - void setError(const Error &error); - EGLint getError() const; - - void setAPI(EGLenum api); - EGLenum getAPI() const; - - void setCurrent(Display *display, - Surface *drawSurface, - Surface *readSurface, - gl::Context *context); - Display *getDisplay() const; - Surface *getDrawSurface() const; - Surface *getReadSurface() const; - gl::Context *getContext() const; - gl::Context *getValidContext() const; - - private: - EGLint mError; - EGLenum mAPI; - egl::Display *mDisplay; - egl::Surface *mDrawSurface; - egl::Surface *mReadSurface; - gl::Context *mContext; -}; - -} // namespace egl - -#endif // LIBANGLE_THREAD_H_ diff --git a/gfx/angle/src/libANGLE/TransformFeedback_unittest.cpp b/gfx/angle/src/libANGLE/TransformFeedback_unittest.cpp index aa464d105..07a0959e2 100755 --- a/gfx/angle/src/libANGLE/TransformFeedback_unittest.cpp +++ b/gfx/angle/src/libANGLE/TransformFeedback_unittest.cpp @@ -101,16 +101,9 @@ TEST_F(TransformFeedbackTest, SideEffectsOfPauseAndResume) TEST_F(TransformFeedbackTest, BufferBinding) { rx::MockBufferImpl *bufferImpl = new rx::MockBufferImpl; + gl::Buffer *buffer = new gl::Buffer(bufferImpl, 1); EXPECT_CALL(*bufferImpl, destructor()).Times(1).RetiresOnSaturation(); - rx::MockGLFactory mockGLFactory; - EXPECT_CALL(mockGLFactory, createBuffer(_)) - .Times(1) - .WillOnce(Return(bufferImpl)) - .RetiresOnSaturation(); - - gl::Buffer *buffer = new gl::Buffer(&mockGLFactory, 1); - static const size_t bindIndex = 0; EXPECT_EQ(mFeedback->getIndexedBufferCount(), mCaps.maxTransformFeedbackSeparateAttributes); diff --git a/gfx/angle/src/libANGLE/Uniform.cpp b/gfx/angle/src/libANGLE/Uniform.cpp index 3caa3f5e2..9b4b47aa2 100755 --- a/gfx/angle/src/libANGLE/Uniform.cpp +++ b/gfx/angle/src/libANGLE/Uniform.cpp @@ -109,11 +109,6 @@ size_t LinkedUniform::getElementSize() const return VariableExternalSize(type); } -size_t LinkedUniform::getElementComponents() const -{ - return VariableComponentCount(type); -} - uint8_t *LinkedUniform::getDataPtrToElement(size_t elementIndex) { ASSERT((!isArray() && elementIndex == 0) || (isArray() && elementIndex < arraySize)); diff --git a/gfx/angle/src/libANGLE/Uniform.h b/gfx/angle/src/libANGLE/Uniform.h index 3b822e52b..4d7d24e3b 100755 --- a/gfx/angle/src/libANGLE/Uniform.h +++ b/gfx/angle/src/libANGLE/Uniform.h @@ -36,7 +36,6 @@ struct LinkedUniform : public sh::Uniform bool isInDefaultBlock() const; bool isField() const; size_t getElementSize() const; - size_t getElementComponents() const; uint8_t *getDataPtrToElement(size_t elementIndex); const uint8_t *getDataPtrToElement(size_t elementIndex) const; diff --git a/gfx/angle/src/libANGLE/Version.h b/gfx/angle/src/libANGLE/Version.h index 4c9730c7b..62985d0da 100755 --- a/gfx/angle/src/libANGLE/Version.h +++ b/gfx/angle/src/libANGLE/Version.h @@ -16,8 +16,8 @@ namespace gl struct Version { - constexpr Version(); - constexpr Version(GLuint major, GLuint minor); + Version(); + Version(GLuint major, GLuint minor); GLuint major; GLuint minor; @@ -26,9 +26,8 @@ struct Version bool operator==(const Version &a, const Version &b); bool operator!=(const Version &a, const Version &b); bool operator>=(const Version &a, const Version &b); -bool operator<=(const Version &a, const Version &b); bool operator<(const Version &a, const Version &b); -bool operator>(const Version &a, const Version &b); + } #include "Version.inl" diff --git a/gfx/angle/src/libANGLE/Version.inl b/gfx/angle/src/libANGLE/Version.inl index 495209720..427f6ca17 100755 --- a/gfx/angle/src/libANGLE/Version.inl +++ b/gfx/angle/src/libANGLE/Version.inl @@ -6,54 +6,38 @@ // Version.inl: Encapsulation of a GL version. -#include <tuple> - namespace gl { -constexpr Version::Version() +inline Version::Version() : Version(0, 0) { } -// Avoid conflicts with linux system defines -#undef major -#undef minor - -constexpr Version::Version(GLuint major_, GLuint minor_) - : major(major_), - minor(minor_) +inline Version::Version(GLuint major_, GLuint minor_) { + major = major_; + minor = minor_; } inline bool operator==(const Version &a, const Version &b) { - return std::tie(a.major, a.minor) == std::tie(b.major, b.minor); + return a.major == b.major && a.minor == b.minor; } inline bool operator!=(const Version &a, const Version &b) { - return std::tie(a.major, a.minor) != std::tie(b.major, b.minor); + return !(a == b); } inline bool operator>=(const Version &a, const Version &b) { - return std::tie(a.major, a.minor) >= std::tie(b.major, b.minor); -} - -inline bool operator<=(const Version &a, const Version &b) -{ - return std::tie(a.major, a.minor) <= std::tie(b.major, b.minor); + return a.major > b.major || (a.major == b.major && a.minor >= b.minor); } inline bool operator<(const Version &a, const Version &b) { - return std::tie(a.major, a.minor) < std::tie(b.major, b.minor); -} - -inline bool operator>(const Version &a, const Version &b) -{ - return std::tie(a.major, a.minor) > std::tie(b.major, b.minor); + return !(a >= b); } } diff --git a/gfx/angle/src/libANGLE/VertexArray.h b/gfx/angle/src/libANGLE/VertexArray.h index 65c62f1ba..da660e040 100755 --- a/gfx/angle/src/libANGLE/VertexArray.h +++ b/gfx/angle/src/libANGLE/VertexArray.h @@ -87,7 +87,8 @@ class VertexArray final : public LabeledObject return mState.getVertexAttributes(); } - rx::VertexArrayImpl *getImplementation() const { return mVertexArray; } + rx::VertexArrayImpl *getImplementation() { return mVertexArray; } + const rx::VertexArrayImpl *getImplementation() const { return mVertexArray; } size_t getMaxEnabledAttribute() const { return mState.getMaxEnabledAttribute(); } diff --git a/gfx/angle/src/libANGLE/VertexAttribute.h b/gfx/angle/src/libANGLE/VertexAttribute.h index a8cc8573b..d1ee1b47a 100755 --- a/gfx/angle/src/libANGLE/VertexAttribute.h +++ b/gfx/angle/src/libANGLE/VertexAttribute.h @@ -39,6 +39,9 @@ struct VertexAttribute bool operator==(const VertexAttribute &a, const VertexAttribute &b); bool operator!=(const VertexAttribute &a, const VertexAttribute &b); +template <typename T> +T QuerySingleVertexAttributeParameter(const VertexAttribute& attrib, GLenum pname); + size_t ComputeVertexAttributeTypeSize(const VertexAttribute& attrib); size_t ComputeVertexAttributeStride(const VertexAttribute& attrib); size_t ComputeVertexAttributeElementCount(const VertexAttribute &attrib, diff --git a/gfx/angle/src/libANGLE/VertexAttribute.inl b/gfx/angle/src/libANGLE/VertexAttribute.inl index a1f88f317..0cd31f676 100755 --- a/gfx/angle/src/libANGLE/VertexAttribute.inl +++ b/gfx/angle/src/libANGLE/VertexAttribute.inl @@ -27,6 +27,33 @@ inline bool operator!=(const VertexAttribute &a, const VertexAttribute &b) return !(a == b); } +template <typename T> +T QuerySingleVertexAttributeParameter(const VertexAttribute& attrib, GLenum pname) +{ + switch (pname) + { + case GL_VERTEX_ATTRIB_ARRAY_ENABLED: + return static_cast<T>(attrib.enabled ? GL_TRUE : GL_FALSE); + case GL_VERTEX_ATTRIB_ARRAY_SIZE: + return static_cast<T>(attrib.size); + case GL_VERTEX_ATTRIB_ARRAY_STRIDE: + return static_cast<T>(attrib.stride); + case GL_VERTEX_ATTRIB_ARRAY_TYPE: + return static_cast<T>(attrib.type); + case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: + return static_cast<T>(attrib.normalized ? GL_TRUE : GL_FALSE); + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: + return static_cast<T>(attrib.buffer.id()); + case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: + return static_cast<T>(attrib.divisor); + case GL_VERTEX_ATTRIB_ARRAY_INTEGER: + return static_cast<T>(attrib.pureInteger ? GL_TRUE : GL_FALSE); + default: + UNREACHABLE(); + return static_cast<T>(0); + } +} + inline VertexAttribCurrentValueData::VertexAttribCurrentValueData() : Type(GL_FLOAT) { diff --git a/gfx/angle/src/libANGLE/Workarounds.h b/gfx/angle/src/libANGLE/Workarounds.h deleted file mode 100644 index c5533c1c8..000000000 --- a/gfx/angle/src/libANGLE/Workarounds.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright (c) 2016 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. -// - -// Workarounds.h: Workarounds for driver bugs and other behaviors seen -// on all platforms. - -#ifndef LIBANGLE_WORKAROUNDS_H_ -#define LIBANGLE_WORKAROUNDS_H_ - -namespace gl -{ - -struct Workarounds -{ - // Force the context to be lost (via KHR_robustness) if a GL_OUT_OF_MEMORY error occurs. The - // driver may be in an inconsistent state if this happens, and some users of ANGLE rely on this - // notification to prevent further execution. - bool loseContextOnOutOfMemory = false; -}; -} // namespace gl - -#endif // LIBANGLE_WORKAROUNDS_H_ diff --git a/gfx/angle/src/libANGLE/angletypes.cpp b/gfx/angle/src/libANGLE/angletypes.cpp index 70a3ae645..0cd69963e 100755 --- a/gfx/angle/src/libANGLE/angletypes.cpp +++ b/gfx/angle/src/libANGLE/angletypes.cpp @@ -49,8 +49,7 @@ SamplerState::SamplerState() minLod(-1000.0f), maxLod(1000.0f), compareMode(GL_NONE), - compareFunc(GL_LEQUAL), - sRGBDecode(GL_DECODE_EXT) + compareFunc(GL_LEQUAL) { } diff --git a/gfx/angle/src/libANGLE/angletypes.h b/gfx/angle/src/libANGLE/angletypes.h index 4c345c3d0..e6923c8ad 100755 --- a/gfx/angle/src/libANGLE/angletypes.h +++ b/gfx/angle/src/libANGLE/angletypes.h @@ -192,46 +192,64 @@ struct SamplerState GLenum compareMode; GLenum compareFunc; - - GLenum sRGBDecode; }; bool operator==(const SamplerState &a, const SamplerState &b); bool operator!=(const SamplerState &a, const SamplerState &b); -struct PixelStoreStateBase +struct PixelUnpackState { BindingPointer<Buffer> pixelBuffer; - GLint alignment = 4; - GLint rowLength = 0; - GLint skipRows = 0; - GLint skipPixels = 0; - GLint imageHeight = 0; - GLint skipImages = 0; -}; - -struct PixelUnpackState : PixelStoreStateBase -{ - PixelUnpackState() {} + GLint alignment; + GLint rowLength; + GLint skipRows; + GLint skipPixels; + GLint imageHeight; + GLint skipImages; + + PixelUnpackState() + : alignment(4), + rowLength(0), + skipRows(0), + skipPixels(0), + imageHeight(0), + skipImages(0) + {} PixelUnpackState(GLint alignmentIn, GLint rowLengthIn) - { - alignment = alignmentIn; - rowLength = rowLengthIn; - } + : alignment(alignmentIn), + rowLength(rowLengthIn), + skipRows(0), + skipPixels(0), + imageHeight(0), + skipImages(0) + {} }; -struct PixelPackState : PixelStoreStateBase +struct PixelPackState { - PixelPackState() {} - - PixelPackState(GLint alignmentIn, bool reverseRowOrderIn) - : reverseRowOrder(reverseRowOrderIn) - { - alignment = alignmentIn; - } - - bool reverseRowOrder = false; + BindingPointer<Buffer> pixelBuffer; + GLint alignment; + bool reverseRowOrder; + GLint rowLength; + GLint skipRows; + GLint skipPixels; + + PixelPackState() + : alignment(4), + reverseRowOrder(false), + rowLength(0), + skipRows(0), + skipPixels(0) + {} + + explicit PixelPackState(GLint alignmentIn, bool reverseRowOrderIn) + : alignment(alignmentIn), + reverseRowOrder(reverseRowOrderIn), + rowLength(0), + skipRows(0), + skipPixels(0) + {} }; // Used in Program and VertexArray. @@ -248,6 +266,17 @@ using ResourceMap = std::unordered_map<GLuint, ResourceT *>; namespace rx { +enum VendorID : uint32_t +{ + VENDOR_ID_UNKNOWN = 0x0, + VENDOR_ID_AMD = 0x1002, + VENDOR_ID_INTEL = 0x8086, + VENDOR_ID_NVIDIA = 0x10DE, + // This is Qualcomm PCI Vendor ID. + // Android doesn't have a PCI bus, but all we need is a unique id. + VENDOR_ID_QUALCOMM = 0x5143, +}; + // A macro that determines whether an object has a given runtime type. #if defined(__clang__) #if __has_feature(cxx_rtti) @@ -288,6 +317,12 @@ inline DestT *GetImplAs(SrcT *src) return GetAs<DestT>(src->getImplementation()); } +template <typename DestT, typename SrcT> +inline const DestT *GetImplAs(const SrcT *src) +{ + return GetAs<const DestT>(src->getImplementation()); +} + } #include "angletypes.inl" diff --git a/gfx/angle/src/libANGLE/es3_copy_conversion_formats.json b/gfx/angle/src/libANGLE/es3_copy_conversion_formats.json deleted file mode 100644 index 39b71fd93..000000000 --- a/gfx/angle/src/libANGLE/es3_copy_conversion_formats.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "From ES 3.0.1 spec, table 3.15": - [ - [ "GL_ALPHA", "GL_RGBA" ], - [ "GL_LUMINANCE", "GL_RED" ], - [ "GL_LUMINANCE", "GL_RG" ], - [ "GL_LUMINANCE", "GL_RGB" ], - [ "GL_LUMINANCE", "GL_RGBA" ], - [ "GL_LUMINANCE_ALPHA", "GL_RGBA" ], - [ "GL_RED", "GL_RED" ], - [ "GL_RED", "GL_RG" ], - [ "GL_RED", "GL_RGB" ], - [ "GL_RED", "GL_RGBA" ], - [ "GL_RG", "GL_RG" ], - [ "GL_RG", "GL_RGB" ], - [ "GL_RG", "GL_RGBA" ], - [ "GL_RGB", "GL_RGB" ], - [ "GL_RGB", "GL_RGBA" ], - [ "GL_RGBA", "GL_RGBA" ] - ], - - "Necessary for ANGLE back-buffers": - [ - [ "GL_ALPHA", "GL_BGRA_EXT" ], - [ "GL_LUMINANCE", "GL_BGRA_EXT" ], - [ "GL_LUMINANCE_ALPHA", "GL_BGRA_EXT" ], - [ "GL_RED", "GL_BGRA_EXT" ], - [ "GL_RG", "GL_BGRA_EXT" ], - [ "GL_RGB", "GL_BGRA_EXT" ], - [ "GL_RGBA", "GL_BGRA_EXT" ], - [ "GL_BGRA_EXT", "GL_BGRA_EXT" ], - - [ "GL_RED_INTEGER", "GL_RED_INTEGER" ], - [ "GL_RED_INTEGER", "GL_RG_INTEGER" ], - [ "GL_RED_INTEGER", "GL_RGB_INTEGER" ], - [ "GL_RED_INTEGER", "GL_RGBA_INTEGER" ], - [ "GL_RG_INTEGER", "GL_RG_INTEGER" ], - [ "GL_RG_INTEGER", "GL_RGB_INTEGER" ], - [ "GL_RG_INTEGER", "GL_RGBA_INTEGER" ], - [ "GL_RGB_INTEGER", "GL_RGB_INTEGER" ], - [ "GL_RGB_INTEGER", "GL_RGBA_INTEGER" ], - [ "GL_RGBA_INTEGER", "GL_RGBA_INTEGER" ] - ] -} diff --git a/gfx/angle/src/libANGLE/es3_copy_conversion_table_autogen.cpp b/gfx/angle/src/libANGLE/es3_copy_conversion_table_autogen.cpp deleted file mode 100644 index 3647445c5..000000000 --- a/gfx/angle/src/libANGLE/es3_copy_conversion_table_autogen.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// GENERATED FILE - DO NOT EDIT. -// Generated by gen_copy_conversion_table.py using data from es3_copy_conversion_formats.json. -// -// Copyright 2016 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. -// -// format_map: -// Determining the sized internal format from a (format,type) pair. -// Also check es3 format combinations for validity. - -#include "angle_gl.h" -#include "common/debug.h" - -namespace gl -{ - -bool ValidES3CopyConversion(GLenum textureFormat, GLenum framebufferFormat) -{ - switch (textureFormat) - { - case GL_ALPHA: - switch (framebufferFormat) - { - case GL_BGRA_EXT: - case GL_RGBA: - return true; - default: - break; - } - break; - - case GL_BGRA_EXT: - switch (framebufferFormat) - { - case GL_BGRA_EXT: - return true; - default: - break; - } - break; - - case GL_LUMINANCE: - switch (framebufferFormat) - { - case GL_BGRA_EXT: - case GL_RED: - case GL_RG: - case GL_RGB: - case GL_RGBA: - return true; - default: - break; - } - break; - - case GL_LUMINANCE_ALPHA: - switch (framebufferFormat) - { - case GL_BGRA_EXT: - case GL_RGBA: - return true; - default: - break; - } - break; - - case GL_RED: - switch (framebufferFormat) - { - case GL_BGRA_EXT: - case GL_RED: - case GL_RG: - case GL_RGB: - case GL_RGBA: - return true; - default: - break; - } - break; - - case GL_RED_INTEGER: - switch (framebufferFormat) - { - case GL_RED_INTEGER: - case GL_RGBA_INTEGER: - case GL_RGB_INTEGER: - case GL_RG_INTEGER: - return true; - default: - break; - } - break; - - case GL_RG: - switch (framebufferFormat) - { - case GL_BGRA_EXT: - case GL_RG: - case GL_RGB: - case GL_RGBA: - return true; - default: - break; - } - break; - - case GL_RGB: - switch (framebufferFormat) - { - case GL_BGRA_EXT: - case GL_RGB: - case GL_RGBA: - return true; - default: - break; - } - break; - - case GL_RGBA: - switch (framebufferFormat) - { - case GL_BGRA_EXT: - case GL_RGBA: - return true; - default: - break; - } - break; - - case GL_RGBA_INTEGER: - switch (framebufferFormat) - { - case GL_RGBA_INTEGER: - return true; - default: - break; - } - break; - - case GL_RGB_INTEGER: - switch (framebufferFormat) - { - case GL_RGBA_INTEGER: - case GL_RGB_INTEGER: - return true; - default: - break; - } - break; - - case GL_RG_INTEGER: - switch (framebufferFormat) - { - case GL_RGBA_INTEGER: - case GL_RGB_INTEGER: - case GL_RG_INTEGER: - return true; - default: - break; - } - break; - - default: - break; - } - - return false; -} - -} // namespace gl diff --git a/gfx/angle/src/libANGLE/es3_format_type_combinations.json b/gfx/angle/src/libANGLE/es3_format_type_combinations.json deleted file mode 100644 index fb12242e7..000000000 --- a/gfx/angle/src/libANGLE/es3_format_type_combinations.json +++ /dev/null @@ -1,171 +0,0 @@ -{ - "Format combinations from ES 3.0.1 spec, table 3.2": - [ - [ "GL_RGBA8", "GL_RGBA", "GL_UNSIGNED_BYTE" ], - [ "GL_RGB5_A1", "GL_RGBA", "GL_UNSIGNED_BYTE" ], - [ "GL_RGBA4", "GL_RGBA", "GL_UNSIGNED_BYTE" ], - [ "GL_SRGB8_ALPHA8", "GL_RGBA", "GL_UNSIGNED_BYTE" ], - [ "GL_RGBA8_SNORM", "GL_RGBA", "GL_BYTE" ], - [ "GL_RGBA4", "GL_RGBA", "GL_UNSIGNED_SHORT_4_4_4_4" ], - [ "GL_RGB10_A2", "GL_RGBA", "GL_UNSIGNED_INT_2_10_10_10_REV" ], - [ "GL_RGB5_A1", "GL_RGBA", "GL_UNSIGNED_INT_2_10_10_10_REV" ], - [ "GL_RGB5_A1", "GL_RGBA", "GL_UNSIGNED_SHORT_5_5_5_1" ], - [ "GL_RGBA16F", "GL_RGBA", "GL_HALF_FLOAT" ], - [ "GL_RGBA16F", "GL_RGBA", "GL_HALF_FLOAT_OES" ], - [ "GL_RGBA32F", "GL_RGBA", "GL_FLOAT" ], - [ "GL_RGBA16F", "GL_RGBA", "GL_FLOAT" ], - [ "GL_RGBA8UI", "GL_RGBA_INTEGER", "GL_UNSIGNED_BYTE" ], - [ "GL_RGBA8I", "GL_RGBA_INTEGER", "GL_BYTE" ], - [ "GL_RGBA16UI", "GL_RGBA_INTEGER", "GL_UNSIGNED_SHORT" ], - [ "GL_RGBA16I", "GL_RGBA_INTEGER", "GL_SHORT" ], - [ "GL_RGBA32UI", "GL_RGBA_INTEGER", "GL_UNSIGNED_INT" ], - [ "GL_RGBA32I", "GL_RGBA_INTEGER", "GL_INT" ], - [ "GL_RGB10_A2UI", "GL_RGBA_INTEGER", "GL_UNSIGNED_INT_2_10_10_10_REV" ], - [ "GL_RGB8", "GL_RGB", "GL_UNSIGNED_BYTE" ], - [ "GL_RGB565", "GL_RGB", "GL_UNSIGNED_BYTE" ], - [ "GL_SRGB8", "GL_RGB", "GL_UNSIGNED_BYTE" ], - [ "GL_RGB8_SNORM", "GL_RGB", "GL_BYTE" ], - [ "GL_RGB565", "GL_RGB", "GL_UNSIGNED_SHORT_5_6_5" ], - [ "GL_R11F_G11F_B10F", "GL_RGB", "GL_UNSIGNED_INT_10F_11F_11F_REV" ], - [ "GL_RGB9_E5", "GL_RGB", "GL_UNSIGNED_INT_5_9_9_9_REV" ], - [ "GL_RGB16F", "GL_RGB", "GL_HALF_FLOAT" ], - [ "GL_RGB16F", "GL_RGB", "GL_HALF_FLOAT_OES" ], - [ "GL_R11F_G11F_B10F", "GL_RGB", "GL_HALF_FLOAT" ], - [ "GL_R11F_G11F_B10F", "GL_RGB", "GL_HALF_FLOAT_OES" ], - [ "GL_RGB9_E5", "GL_RGB", "GL_HALF_FLOAT" ], - [ "GL_RGB9_E5", "GL_RGB", "GL_HALF_FLOAT_OES" ], - [ "GL_RGB32F", "GL_RGB", "GL_FLOAT" ], - [ "GL_RGB16F", "GL_RGB", "GL_FLOAT" ], - [ "GL_R11F_G11F_B10F", "GL_RGB", "GL_FLOAT" ], - [ "GL_RGB9_E5", "GL_RGB", "GL_FLOAT" ], - [ "GL_RGB8UI", "GL_RGB_INTEGER", "GL_UNSIGNED_BYTE" ], - [ "GL_RGB8I", "GL_RGB_INTEGER", "GL_BYTE" ], - [ "GL_RGB16UI", "GL_RGB_INTEGER", "GL_UNSIGNED_SHORT" ], - [ "GL_RGB16I", "GL_RGB_INTEGER", "GL_SHORT" ], - [ "GL_RGB32UI", "GL_RGB_INTEGER", "GL_UNSIGNED_INT" ], - [ "GL_RGB32I", "GL_RGB_INTEGER", "GL_INT" ], - [ "GL_RG8", "GL_RG", "GL_UNSIGNED_BYTE" ], - [ "GL_RG8_SNORM", "GL_RG", "GL_BYTE" ], - [ "GL_RG16F", "GL_RG", "GL_HALF_FLOAT" ], - [ "GL_RG16F", "GL_RG", "GL_HALF_FLOAT_OES" ], - [ "GL_RG32F", "GL_RG", "GL_FLOAT" ], - [ "GL_RG16F", "GL_RG", "GL_FLOAT" ], - [ "GL_RG8UI", "GL_RG_INTEGER", "GL_UNSIGNED_BYTE" ], - [ "GL_RG8I", "GL_RG_INTEGER", "GL_BYTE" ], - [ "GL_RG16UI", "GL_RG_INTEGER", "GL_UNSIGNED_SHORT" ], - [ "GL_RG16I", "GL_RG_INTEGER", "GL_SHORT" ], - [ "GL_RG32UI", "GL_RG_INTEGER", "GL_UNSIGNED_INT" ], - [ "GL_RG32I", "GL_RG_INTEGER", "GL_INT" ], - [ "GL_R8", "GL_RED", "GL_UNSIGNED_BYTE" ], - [ "GL_R8_SNORM", "GL_RED", "GL_BYTE" ], - [ "GL_R16F", "GL_RED", "GL_HALF_FLOAT" ], - [ "GL_R16F", "GL_RED", "GL_HALF_FLOAT_OES" ], - [ "GL_R32F", "GL_RED", "GL_FLOAT" ], - [ "GL_R16F", "GL_RED", "GL_FLOAT" ], - [ "GL_R8UI", "GL_RED_INTEGER", "GL_UNSIGNED_BYTE" ], - [ "GL_R8I", "GL_RED_INTEGER", "GL_BYTE" ], - [ "GL_R16UI", "GL_RED_INTEGER", "GL_UNSIGNED_SHORT" ], - [ "GL_R16I", "GL_RED_INTEGER", "GL_SHORT" ], - [ "GL_R32UI", "GL_RED_INTEGER", "GL_UNSIGNED_INT" ], - [ "GL_R32I", "GL_RED_INTEGER", "GL_INT" ] - ], - "Unsized formats": - [ - [ "GL_RGBA", "GL_RGBA", "GL_UNSIGNED_BYTE" ], - [ "GL_RGBA", "GL_RGBA", "GL_UNSIGNED_SHORT_4_4_4_4" ], - [ "GL_RGBA", "GL_RGBA", "GL_UNSIGNED_SHORT_5_5_5_1" ], - [ "GL_RGB", "GL_RGB", "GL_UNSIGNED_BYTE" ], - [ "GL_RGB", "GL_RGB", "GL_UNSIGNED_SHORT_5_6_5" ], - [ "GL_LUMINANCE_ALPHA", "GL_LUMINANCE_ALPHA", "GL_UNSIGNED_BYTE" ], - [ "GL_LUMINANCE", "GL_LUMINANCE", "GL_UNSIGNED_BYTE" ], - [ "GL_ALPHA", "GL_ALPHA", "GL_UNSIGNED_BYTE" ], - [ "GL_SRGB_ALPHA_EXT", "GL_SRGB_ALPHA_EXT", "GL_UNSIGNED_BYTE" ], - [ "GL_SRGB_EXT", "GL_SRGB_EXT", "GL_UNSIGNED_BYTE" ], - [ "GL_RG", "GL_RG", "GL_UNSIGNED_BYTE" ], - [ "GL_RG", "GL_RG", "GL_FLOAT" ], - [ "GL_RG", "GL_RG", "GL_HALF_FLOAT" ], - [ "GL_RG", "GL_RG", "GL_HALF_FLOAT_OES" ], - [ "GL_RED", "GL_RED", "GL_UNSIGNED_BYTE" ], - [ "GL_RED", "GL_RED", "GL_FLOAT" ], - [ "GL_RED", "GL_RED", "GL_HALF_FLOAT" ], - [ "GL_RED", "GL_RED", "GL_HALF_FLOAT_OES" ], - [ "GL_DEPTH_STENCIL", "GL_DEPTH_STENCIL", "GL_UNSIGNED_INT_24_8" ] - ], - "Depth stencil formats": - [ - [ "GL_DEPTH_COMPONENT16", "GL_DEPTH_COMPONENT", "GL_UNSIGNED_SHORT" ], - [ "GL_DEPTH_COMPONENT24", "GL_DEPTH_COMPONENT", "GL_UNSIGNED_INT" ], - [ "GL_DEPTH_COMPONENT16", "GL_DEPTH_COMPONENT", "GL_UNSIGNED_INT" ], - [ "GL_DEPTH_COMPONENT32F", "GL_DEPTH_COMPONENT", "GL_FLOAT" ], - [ "GL_DEPTH24_STENCIL8", "GL_DEPTH_STENCIL", "GL_UNSIGNED_INT_24_8" ], - [ "GL_DEPTH32F_STENCIL8", "GL_DEPTH_STENCIL", "GL_FLOAT_32_UNSIGNED_INT_24_8_REV" ] - ], - "From GL_EXT_sRGB": - [ - [ "GL_SRGB8_ALPHA8_EXT", "GL_SRGB_ALPHA_EXT", "GL_UNSIGNED_BYTE" ], - [ "GL_SRGB8", "GL_SRGB_EXT", "GL_UNSIGNED_BYTE" ] - ], - "From GL_OES_texture_float": - [ - [ "GL_RGBA", "GL_RGBA", "GL_FLOAT" ], - [ "GL_RGB", "GL_RGB", "GL_FLOAT" ], - [ "GL_LUMINANCE_ALPHA", "GL_LUMINANCE_ALPHA", "GL_FLOAT" ], - [ "GL_LUMINANCE", "GL_LUMINANCE", "GL_FLOAT" ], - [ "GL_ALPHA", "GL_ALPHA", "GL_FLOAT" ] - ], - "From GL_OES_texture_half_float": - [ - [ "GL_RGBA", "GL_RGBA", "GL_HALF_FLOAT_OES" ], - [ "GL_RGB", "GL_RGB", "GL_HALF_FLOAT_OES" ], - [ "GL_LUMINANCE_ALPHA", "GL_LUMINANCE_ALPHA", "GL_HALF_FLOAT" ], - [ "GL_LUMINANCE_ALPHA", "GL_LUMINANCE_ALPHA", "GL_HALF_FLOAT_OES" ], - [ "GL_LUMINANCE", "GL_LUMINANCE", "GL_HALF_FLOAT" ], - [ "GL_LUMINANCE", "GL_LUMINANCE", "GL_HALF_FLOAT_OES" ], - [ "GL_ALPHA", "GL_ALPHA", "GL_HALF_FLOAT" ], - [ "GL_ALPHA", "GL_ALPHA", "GL_HALF_FLOAT_OES" ] - ], - "From GL_EXT_texture_format_BGRA8888": - [ - [ "GL_BGRA_EXT", "GL_BGRA_EXT", "GL_UNSIGNED_BYTE" ] - ], - "From GL_EXT_texture_storage": - [ - [ "GL_ALPHA8_EXT", "GL_ALPHA", "GL_UNSIGNED_BYTE" ], - [ "GL_LUMINANCE8_EXT", "GL_LUMINANCE", "GL_UNSIGNED_BYTE" ], - [ "GL_LUMINANCE8_ALPHA8_EXT", "GL_LUMINANCE_ALPHA", "GL_UNSIGNED_BYTE" ], - [ "GL_ALPHA32F_EXT", "GL_ALPHA", "GL_FLOAT" ], - [ "GL_LUMINANCE32F_EXT", "GL_LUMINANCE", "GL_FLOAT" ], - [ "GL_LUMINANCE_ALPHA32F_EXT", "GL_LUMINANCE_ALPHA", "GL_FLOAT" ], - [ "GL_ALPHA16F_EXT", "GL_ALPHA", "GL_HALF_FLOAT" ], - [ "GL_ALPHA16F_EXT", "GL_ALPHA", "GL_HALF_FLOAT_OES" ], - [ "GL_LUMINANCE16F_EXT", "GL_LUMINANCE", "GL_HALF_FLOAT" ], - [ "GL_LUMINANCE16F_EXT", "GL_LUMINANCE", "GL_HALF_FLOAT_OES" ], - [ "GL_LUMINANCE_ALPHA16F_EXT", "GL_LUMINANCE_ALPHA", "GL_HALF_FLOAT" ], - [ "GL_LUMINANCE_ALPHA16F_EXT", "GL_LUMINANCE_ALPHA", "GL_HALF_FLOAT_OES" ] - ], - "From GL_EXT_texture_storage and GL_EXT_texture_format_BGRA8888": - [ - [ "GL_BGRA8_EXT", "GL_BGRA_EXT", "GL_UNSIGNED_BYTE" ], - [ "GL_BGRA4_ANGLEX", "GL_BGRA_EXT", "GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT" ], - [ "GL_BGRA4_ANGLEX", "GL_BGRA_EXT", "GL_UNSIGNED_BYTE" ], - [ "GL_BGR5_A1_ANGLEX", "GL_BGRA_EXT", "GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT" ], - [ "GL_BGR5_A1_ANGLEX", "GL_BGRA_EXT", "GL_UNSIGNED_BYTE" ] - ], - "From GL_ANGLE_depth_texture and OES_depth_texture": - [ - [ "GL_DEPTH_COMPONENT32_OES", "GL_DEPTH_COMPONENT", "GL_UNSIGNED_INT_24_8" ], - [ "GL_DEPTH_COMPONENT", "GL_DEPTH_COMPONENT", "GL_UNSIGNED_SHORT" ], - [ "GL_DEPTH_COMPONENT", "GL_DEPTH_COMPONENT", "GL_UNSIGNED_INT" ] - ], - "From GL_EXT_texture_norm16": - [ - [ "GL_R16_EXT", "GL_RED", "GL_UNSIGNED_SHORT" ], - [ "GL_RG16_EXT", "GL_RG", "GL_UNSIGNED_SHORT" ], - [ "GL_RGB16_EXT", "GL_RGB", "GL_UNSIGNED_SHORT" ], - [ "GL_RGBA16_EXT", "GL_RGBA", "GL_UNSIGNED_SHORT" ], - [ "GL_R16_SNORM_EXT", "GL_RED", "GL_SHORT" ], - [ "GL_RG16_SNORM_EXT", "GL_RG", "GL_SHORT" ], - [ "GL_RGB16_SNORM_EXT", "GL_RGB", "GL_SHORT" ], - [ "GL_RGBA16_SNORM_EXT", "GL_RGBA", "GL_SHORT" ] - ] -} diff --git a/gfx/angle/src/libANGLE/format_map_autogen.cpp b/gfx/angle/src/libANGLE/format_map_autogen.cpp deleted file mode 100644 index 707d38426..000000000 --- a/gfx/angle/src/libANGLE/format_map_autogen.cpp +++ /dev/null @@ -1,1530 +0,0 @@ -// GENERATED FILE - DO NOT EDIT. -// Generated by gen_format_map.py using data from format_map_data.json. -// ES3 format info from es3_format_type_combinations.json. -// -// Copyright 2016 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. -// -// format_map: -// Determining the sized internal format from a (format,type) pair. -// Also check es3 format combinations for validity. - -#include "angle_gl.h" -#include "common/debug.h" - -namespace gl -{ - -GLenum GetSizedFormatInternal(GLenum format, GLenum type) -{ - switch (format) - { - case GL_ALPHA: - switch (type) - { - case GL_FLOAT: - return GL_ALPHA32F_EXT; - case GL_HALF_FLOAT: - return GL_ALPHA16F_EXT; - case GL_HALF_FLOAT_OES: - return GL_ALPHA16F_EXT; - case GL_UNSIGNED_BYTE: - return GL_ALPHA8_EXT; - default: - break; - } - break; - - case GL_BGRA_EXT: - switch (type) - { - case GL_UNSIGNED_BYTE: - return GL_BGRA8_EXT; - case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: - return GL_BGR5_A1_ANGLEX; - case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: - return GL_BGRA4_ANGLEX; - case GL_UNSIGNED_SHORT_5_6_5: - return GL_BGR565_ANGLEX; - default: - break; - } - break; - - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - switch (type) - { - case GL_UNSIGNED_BYTE: - return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - default: - break; - } - break; - - case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: - switch (type) - { - case GL_UNSIGNED_BYTE: - return GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE; - default: - break; - } - break; - - case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: - switch (type) - { - case GL_UNSIGNED_BYTE: - return GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE; - default: - break; - } - break; - - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - switch (type) - { - case GL_UNSIGNED_BYTE: - return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - default: - break; - } - break; - - case GL_DEPTH_COMPONENT: - switch (type) - { - case GL_FLOAT: - return GL_DEPTH_COMPONENT32F; - case GL_UNSIGNED_INT: - return GL_DEPTH_COMPONENT32_OES; - case GL_UNSIGNED_SHORT: - return GL_DEPTH_COMPONENT16; - default: - break; - } - break; - - case GL_DEPTH_STENCIL: - switch (type) - { - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - return GL_DEPTH32F_STENCIL8; - case GL_UNSIGNED_INT_24_8: - return GL_DEPTH24_STENCIL8; - default: - break; - } - break; - - case GL_LUMINANCE: - switch (type) - { - case GL_FLOAT: - return GL_LUMINANCE32F_EXT; - case GL_HALF_FLOAT: - return GL_LUMINANCE16F_EXT; - case GL_HALF_FLOAT_OES: - return GL_LUMINANCE16F_EXT; - case GL_UNSIGNED_BYTE: - return GL_LUMINANCE8_EXT; - default: - break; - } - break; - - case GL_LUMINANCE_ALPHA: - switch (type) - { - case GL_FLOAT: - return GL_LUMINANCE_ALPHA32F_EXT; - case GL_HALF_FLOAT: - return GL_LUMINANCE_ALPHA16F_EXT; - case GL_HALF_FLOAT_OES: - return GL_LUMINANCE_ALPHA16F_EXT; - case GL_UNSIGNED_BYTE: - return GL_LUMINANCE8_ALPHA8_EXT; - default: - break; - } - break; - - case GL_RED: - switch (type) - { - case GL_BYTE: - return GL_R8_SNORM; - case GL_FLOAT: - return GL_R32F; - case GL_HALF_FLOAT: - return GL_R16F; - case GL_HALF_FLOAT_OES: - return GL_R16F; - case GL_SHORT: - return GL_R16_SNORM_EXT; - case GL_UNSIGNED_BYTE: - return GL_R8; - case GL_UNSIGNED_SHORT: - return GL_R16_EXT; - default: - break; - } - break; - - case GL_RED_INTEGER: - switch (type) - { - case GL_BYTE: - return GL_R8I; - case GL_INT: - return GL_R32I; - case GL_SHORT: - return GL_R16I; - case GL_UNSIGNED_BYTE: - return GL_R8UI; - case GL_UNSIGNED_INT: - return GL_R32UI; - case GL_UNSIGNED_SHORT: - return GL_R16UI; - default: - break; - } - break; - - case GL_RG: - switch (type) - { - case GL_BYTE: - return GL_RG8_SNORM; - case GL_FLOAT: - return GL_RG32F; - case GL_HALF_FLOAT: - return GL_RG16F; - case GL_HALF_FLOAT_OES: - return GL_RG16F; - case GL_SHORT: - return GL_RG16_SNORM_EXT; - case GL_UNSIGNED_BYTE: - return GL_RG8; - case GL_UNSIGNED_SHORT: - return GL_RG16_EXT; - default: - break; - } - break; - - case GL_RGB: - switch (type) - { - case GL_BYTE: - return GL_RGB8_SNORM; - case GL_FLOAT: - return GL_RGB32F; - case GL_HALF_FLOAT: - return GL_RGB16F; - case GL_HALF_FLOAT_OES: - return GL_RGB16F; - case GL_SHORT: - return GL_RGB16_SNORM_EXT; - case GL_UNSIGNED_BYTE: - return GL_RGB8; - case GL_UNSIGNED_INT_10F_11F_11F_REV: - return GL_R11F_G11F_B10F; - case GL_UNSIGNED_INT_5_9_9_9_REV: - return GL_RGB9_E5; - case GL_UNSIGNED_SHORT: - return GL_RGB16_EXT; - case GL_UNSIGNED_SHORT_5_6_5: - return GL_RGB565; - default: - break; - } - break; - - case GL_RGBA: - switch (type) - { - case GL_BYTE: - return GL_RGBA8_SNORM; - case GL_FLOAT: - return GL_RGBA32F; - case GL_HALF_FLOAT: - return GL_RGBA16F; - case GL_HALF_FLOAT_OES: - return GL_RGBA16F; - case GL_SHORT: - return GL_RGBA16_SNORM_EXT; - case GL_UNSIGNED_BYTE: - return GL_RGBA8; - case GL_UNSIGNED_INT_2_10_10_10_REV: - return GL_RGB10_A2; - case GL_UNSIGNED_SHORT: - return GL_RGBA16_EXT; - case GL_UNSIGNED_SHORT_4_4_4_4: - return GL_RGBA4; - case GL_UNSIGNED_SHORT_5_5_5_1: - return GL_RGB5_A1; - default: - break; - } - break; - - case GL_RGBA_INTEGER: - switch (type) - { - case GL_BYTE: - return GL_RGBA8I; - case GL_INT: - return GL_RGBA32I; - case GL_SHORT: - return GL_RGBA16I; - case GL_UNSIGNED_BYTE: - return GL_RGBA8UI; - case GL_UNSIGNED_INT: - return GL_RGBA32UI; - case GL_UNSIGNED_INT_2_10_10_10_REV: - return GL_RGB10_A2UI; - case GL_UNSIGNED_SHORT: - return GL_RGBA16UI; - default: - break; - } - break; - - case GL_RGB_INTEGER: - switch (type) - { - case GL_BYTE: - return GL_RGB8I; - case GL_INT: - return GL_RGB32I; - case GL_SHORT: - return GL_RGB16I; - case GL_UNSIGNED_BYTE: - return GL_RGB8UI; - case GL_UNSIGNED_INT: - return GL_RGB32UI; - case GL_UNSIGNED_SHORT: - return GL_RGB16UI; - default: - break; - } - break; - - case GL_RG_INTEGER: - switch (type) - { - case GL_BYTE: - return GL_RG8I; - case GL_INT: - return GL_RG32I; - case GL_SHORT: - return GL_RG16I; - case GL_UNSIGNED_BYTE: - return GL_RG8UI; - case GL_UNSIGNED_INT: - return GL_RG32UI; - case GL_UNSIGNED_SHORT: - return GL_RG16UI; - default: - break; - } - break; - - case GL_SRGB_ALPHA_EXT: - switch (type) - { - case GL_UNSIGNED_BYTE: - return GL_SRGB8_ALPHA8; - default: - break; - } - break; - - case GL_SRGB_EXT: - switch (type) - { - case GL_UNSIGNED_BYTE: - return GL_SRGB8; - default: - break; - } - break; - - case GL_STENCIL: - switch (type) - { - case GL_UNSIGNED_BYTE: - return GL_STENCIL_INDEX8; - default: - break; - } - break; - - case GL_NONE: - return GL_NONE; - - default: - break; - } - - return GL_NONE; -} - -bool ValidES3Format(GLenum format) -{ - switch (format) - { - case GL_ALPHA: - case GL_BGRA_EXT: - case GL_DEPTH_COMPONENT: - case GL_DEPTH_STENCIL: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_RED: - case GL_RED_INTEGER: - case GL_RG: - case GL_RGB: - case GL_RGBA: - case GL_RGBA_INTEGER: - case GL_RGB_INTEGER: - case GL_RG_INTEGER: - case GL_SRGB_ALPHA_EXT: - case GL_SRGB_EXT: - return true; - - default: - return false; - } -} - -bool ValidES3Type(GLenum type) -{ - switch (type) - { - case GL_BYTE: - case GL_FLOAT: - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - case GL_HALF_FLOAT: - case GL_HALF_FLOAT_OES: - case GL_INT: - case GL_SHORT: - case GL_UNSIGNED_BYTE: - case GL_UNSIGNED_INT: - case GL_UNSIGNED_INT_10F_11F_11F_REV: - case GL_UNSIGNED_INT_24_8: - case GL_UNSIGNED_INT_2_10_10_10_REV: - case GL_UNSIGNED_INT_5_9_9_9_REV: - case GL_UNSIGNED_SHORT: - case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_5_6_5: - return true; - - default: - return false; - } -} - -bool ValidES3FormatCombination(GLenum format, GLenum type, GLenum internalFormat) -{ - ASSERT(ValidES3Format(format) && ValidES3Type(type)); - - switch (format) - { - case GL_RGB_INTEGER: - switch (type) - { - case GL_INT: - { - switch (internalFormat) - { - case GL_RGB32I: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_SHORT: - { - switch (internalFormat) - { - case GL_RGB16UI: - return true; - default: - break; - } - break; - } - case GL_SHORT: - { - switch (internalFormat) - { - case GL_RGB16I: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_RGB8UI: - return true; - default: - break; - } - break; - } - case GL_BYTE: - { - switch (internalFormat) - { - case GL_RGB8I: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_INT: - { - switch (internalFormat) - { - case GL_RGB32UI: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_RGBA_INTEGER: - switch (type) - { - case GL_INT: - { - switch (internalFormat) - { - case GL_RGBA32I: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_SHORT: - { - switch (internalFormat) - { - case GL_RGBA16UI: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_INT_2_10_10_10_REV: - { - switch (internalFormat) - { - case GL_RGB10_A2UI: - return true; - default: - break; - } - break; - } - case GL_SHORT: - { - switch (internalFormat) - { - case GL_RGBA16I: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_RGBA8UI: - return true; - default: - break; - } - break; - } - case GL_BYTE: - { - switch (internalFormat) - { - case GL_RGBA8I: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_INT: - { - switch (internalFormat) - { - case GL_RGBA32UI: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_RGB: - switch (type) - { - case GL_UNSIGNED_INT_10F_11F_11F_REV: - { - switch (internalFormat) - { - case GL_R11F_G11F_B10F: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_SHORT: - { - switch (internalFormat) - { - case GL_RGB16_EXT: - return true; - default: - break; - } - break; - } - case GL_SHORT: - { - switch (internalFormat) - { - case GL_RGB16_SNORM_EXT: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_RGB: - case GL_RGB8: - case GL_RGB565: - case GL_SRGB8: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_SHORT_5_6_5: - { - switch (internalFormat) - { - case GL_RGB: - case GL_RGB565: - return true; - default: - break; - } - break; - } - case GL_HALF_FLOAT_OES: - { - switch (internalFormat) - { - case GL_RGB: - case GL_RGB16F: - case GL_R11F_G11F_B10F: - case GL_RGB9_E5: - return true; - default: - break; - } - break; - } - case GL_HALF_FLOAT: - { - switch (internalFormat) - { - case GL_RGB16F: - case GL_R11F_G11F_B10F: - case GL_RGB9_E5: - return true; - default: - break; - } - break; - } - case GL_FLOAT: - { - switch (internalFormat) - { - case GL_RGB: - case GL_RGB32F: - case GL_RGB16F: - case GL_R11F_G11F_B10F: - case GL_RGB9_E5: - return true; - default: - break; - } - break; - } - case GL_BYTE: - { - switch (internalFormat) - { - case GL_RGB8_SNORM: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_INT_5_9_9_9_REV: - { - switch (internalFormat) - { - case GL_RGB9_E5: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_LUMINANCE_ALPHA: - switch (type) - { - case GL_HALF_FLOAT: - { - switch (internalFormat) - { - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE_ALPHA16F_EXT: - return true; - default: - break; - } - break; - } - case GL_FLOAT: - { - switch (internalFormat) - { - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE_ALPHA32F_EXT: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE8_ALPHA8_EXT: - return true; - default: - break; - } - break; - } - case GL_HALF_FLOAT_OES: - { - switch (internalFormat) - { - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE_ALPHA16F_EXT: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_ALPHA: - switch (type) - { - case GL_HALF_FLOAT: - { - switch (internalFormat) - { - case GL_ALPHA: - case GL_ALPHA16F_EXT: - return true; - default: - break; - } - break; - } - case GL_FLOAT: - { - switch (internalFormat) - { - case GL_ALPHA: - case GL_ALPHA32F_EXT: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_ALPHA: - case GL_ALPHA8_EXT: - return true; - default: - break; - } - break; - } - case GL_HALF_FLOAT_OES: - { - switch (internalFormat) - { - case GL_ALPHA: - case GL_ALPHA16F_EXT: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_RGBA: - switch (type) - { - case GL_UNSIGNED_SHORT: - { - switch (internalFormat) - { - case GL_RGBA16_EXT: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_INT_2_10_10_10_REV: - { - switch (internalFormat) - { - case GL_RGB10_A2: - case GL_RGB5_A1: - return true; - default: - break; - } - break; - } - case GL_SHORT: - { - switch (internalFormat) - { - case GL_RGBA16_SNORM_EXT: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_SHORT_4_4_4_4: - { - switch (internalFormat) - { - case GL_RGBA: - case GL_RGBA4: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_RGBA: - case GL_RGBA8: - case GL_RGB5_A1: - case GL_RGBA4: - case GL_SRGB8_ALPHA8: - return true; - default: - break; - } - break; - } - case GL_HALF_FLOAT_OES: - { - switch (internalFormat) - { - case GL_RGBA: - case GL_RGBA16F: - return true; - default: - break; - } - break; - } - case GL_HALF_FLOAT: - { - switch (internalFormat) - { - case GL_RGBA16F: - return true; - default: - break; - } - break; - } - case GL_FLOAT: - { - switch (internalFormat) - { - case GL_RGBA: - case GL_RGBA32F: - case GL_RGBA16F: - return true; - default: - break; - } - break; - } - case GL_BYTE: - { - switch (internalFormat) - { - case GL_RGBA8_SNORM: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_SHORT_5_5_5_1: - { - switch (internalFormat) - { - case GL_RGBA: - case GL_RGB5_A1: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_LUMINANCE: - switch (type) - { - case GL_HALF_FLOAT: - { - switch (internalFormat) - { - case GL_LUMINANCE: - case GL_LUMINANCE16F_EXT: - return true; - default: - break; - } - break; - } - case GL_FLOAT: - { - switch (internalFormat) - { - case GL_LUMINANCE: - case GL_LUMINANCE32F_EXT: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_LUMINANCE: - case GL_LUMINANCE8_EXT: - return true; - default: - break; - } - break; - } - case GL_HALF_FLOAT_OES: - { - switch (internalFormat) - { - case GL_LUMINANCE: - case GL_LUMINANCE16F_EXT: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_RG_INTEGER: - switch (type) - { - case GL_INT: - { - switch (internalFormat) - { - case GL_RG32I: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_SHORT: - { - switch (internalFormat) - { - case GL_RG16UI: - return true; - default: - break; - } - break; - } - case GL_SHORT: - { - switch (internalFormat) - { - case GL_RG16I: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_RG8UI: - return true; - default: - break; - } - break; - } - case GL_BYTE: - { - switch (internalFormat) - { - case GL_RG8I: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_INT: - { - switch (internalFormat) - { - case GL_RG32UI: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_RED_INTEGER: - switch (type) - { - case GL_INT: - { - switch (internalFormat) - { - case GL_R32I: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_SHORT: - { - switch (internalFormat) - { - case GL_R16UI: - return true; - default: - break; - } - break; - } - case GL_SHORT: - { - switch (internalFormat) - { - case GL_R16I: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_R8UI: - return true; - default: - break; - } - break; - } - case GL_BYTE: - { - switch (internalFormat) - { - case GL_R8I: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_INT: - { - switch (internalFormat) - { - case GL_R32UI: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_RED: - switch (type) - { - case GL_UNSIGNED_SHORT: - { - switch (internalFormat) - { - case GL_R16_EXT: - return true; - default: - break; - } - break; - } - case GL_SHORT: - { - switch (internalFormat) - { - case GL_R16_SNORM_EXT: - return true; - default: - break; - } - break; - } - case GL_FLOAT: - { - switch (internalFormat) - { - case GL_RED: - case GL_R32F: - case GL_R16F: - return true; - default: - break; - } - break; - } - case GL_HALF_FLOAT_OES: - { - switch (internalFormat) - { - case GL_RED: - case GL_R16F: - return true; - default: - break; - } - break; - } - case GL_HALF_FLOAT: - { - switch (internalFormat) - { - case GL_RED: - case GL_R16F: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_RED: - case GL_R8: - return true; - default: - break; - } - break; - } - case GL_BYTE: - { - switch (internalFormat) - { - case GL_R8_SNORM: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_DEPTH_COMPONENT: - switch (type) - { - case GL_UNSIGNED_INT: - { - switch (internalFormat) - { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT16: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_INT_24_8: - { - switch (internalFormat) - { - case GL_DEPTH_COMPONENT32_OES: - return true; - default: - break; - } - break; - } - case GL_FLOAT: - { - switch (internalFormat) - { - case GL_DEPTH_COMPONENT32F: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_SHORT: - { - switch (internalFormat) - { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_DEPTH_STENCIL: - switch (type) - { - case GL_UNSIGNED_INT_24_8: - { - switch (internalFormat) - { - case GL_DEPTH_STENCIL: - case GL_DEPTH24_STENCIL8: - return true; - default: - break; - } - break; - } - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - { - switch (internalFormat) - { - case GL_DEPTH32F_STENCIL8: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_SRGB_EXT: - switch (type) - { - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_SRGB_EXT: - case GL_SRGB8: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_SRGB_ALPHA_EXT: - switch (type) - { - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_SRGB_ALPHA_EXT: - case GL_SRGB8_ALPHA8_EXT: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_RG: - switch (type) - { - case GL_UNSIGNED_SHORT: - { - switch (internalFormat) - { - case GL_RG16_EXT: - return true; - default: - break; - } - break; - } - case GL_SHORT: - { - switch (internalFormat) - { - case GL_RG16_SNORM_EXT: - return true; - default: - break; - } - break; - } - case GL_FLOAT: - { - switch (internalFormat) - { - case GL_RG: - case GL_RG32F: - case GL_RG16F: - return true; - default: - break; - } - break; - } - case GL_HALF_FLOAT_OES: - { - switch (internalFormat) - { - case GL_RG: - case GL_RG16F: - return true; - default: - break; - } - break; - } - case GL_HALF_FLOAT: - { - switch (internalFormat) - { - case GL_RG: - case GL_RG16F: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_RG: - case GL_RG8: - return true; - default: - break; - } - break; - } - case GL_BYTE: - { - switch (internalFormat) - { - case GL_RG8_SNORM: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - case GL_BGRA_EXT: - switch (type) - { - case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: - { - switch (internalFormat) - { - case GL_BGRA4_ANGLEX: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_BYTE: - { - switch (internalFormat) - { - case GL_BGRA8_EXT: - case GL_BGRA4_ANGLEX: - case GL_BGR5_A1_ANGLEX: - case GL_BGRA_EXT: - return true; - default: - break; - } - break; - } - case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: - { - switch (internalFormat) - { - case GL_BGR5_A1_ANGLEX: - return true; - default: - break; - } - break; - } - default: - break; - } - break; - - default: - UNREACHABLE(); - break; - } - - return false; -} - -} // namespace gl diff --git a/gfx/angle/src/libANGLE/format_map_data.json b/gfx/angle/src/libANGLE/format_map_data.json deleted file mode 100644 index 3d6ad6c3c..000000000 --- a/gfx/angle/src/libANGLE/format_map_data.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "GL_RGBA": { - "GL_UNSIGNED_BYTE": "GL_RGBA8", - "GL_UNSIGNED_SHORT": "GL_RGBA16_EXT", - "GL_BYTE": "GL_RGBA8_SNORM", - "GL_SHORT": "GL_RGBA16_SNORM_EXT", - "GL_UNSIGNED_SHORT_4_4_4_4": "GL_RGBA4", - "GL_UNSIGNED_SHORT_5_5_5_1": "GL_RGB5_A1", - "GL_UNSIGNED_INT_2_10_10_10_REV": "GL_RGB10_A2", - "GL_FLOAT": "GL_RGBA32F", - "GL_HALF_FLOAT": "GL_RGBA16F", - "GL_HALF_FLOAT_OES": "GL_RGBA16F" - }, - "GL_RGBA_INTEGER": { - "GL_UNSIGNED_BYTE": "GL_RGBA8UI", - "GL_BYTE": "GL_RGBA8I", - "GL_UNSIGNED_SHORT": "GL_RGBA16UI", - "GL_SHORT": "GL_RGBA16I", - "GL_UNSIGNED_INT": "GL_RGBA32UI", - "GL_INT": "GL_RGBA32I", - "GL_UNSIGNED_INT_2_10_10_10_REV": "GL_RGB10_A2UI" - }, - "GL_RGB": { - "GL_UNSIGNED_BYTE": "GL_RGB8", - "GL_UNSIGNED_SHORT": "GL_RGB16_EXT", - "GL_BYTE": "GL_RGB8_SNORM", - "GL_SHORT": "GL_RGB16_SNORM_EXT", - "GL_UNSIGNED_SHORT_5_6_5": "GL_RGB565", - "GL_UNSIGNED_INT_10F_11F_11F_REV": "GL_R11F_G11F_B10F", - "GL_UNSIGNED_INT_5_9_9_9_REV": "GL_RGB9_E5", - "GL_FLOAT": "GL_RGB32F", - "GL_HALF_FLOAT": "GL_RGB16F", - "GL_HALF_FLOAT_OES": "GL_RGB16F" - }, - "GL_RGB_INTEGER": { - "GL_UNSIGNED_BYTE": "GL_RGB8UI", - "GL_BYTE": "GL_RGB8I", "GL_UNSIGNED_SHORT": "GL_RGB16UI", - "GL_SHORT": "GL_RGB16I", - "GL_UNSIGNED_INT": "GL_RGB32UI", - "GL_INT": "GL_RGB32I" - }, - "GL_RG": { - "GL_UNSIGNED_BYTE": "GL_RG8", - "GL_UNSIGNED_SHORT": "GL_RG16_EXT", - "GL_BYTE": "GL_RG8_SNORM", - "GL_SHORT": "GL_RG16_SNORM_EXT", - "GL_FLOAT": "GL_RG32F", - "GL_HALF_FLOAT": "GL_RG16F", - "GL_HALF_FLOAT_OES": "GL_RG16F" - }, - "GL_RG_INTEGER": { - "GL_UNSIGNED_BYTE": "GL_RG8UI", - "GL_BYTE": "GL_RG8I", - "GL_UNSIGNED_SHORT": "GL_RG16UI", - "GL_SHORT": "GL_RG16I", - "GL_UNSIGNED_INT": "GL_RG32UI", - "GL_INT": "GL_RG32I" - }, - "GL_RED": { - "GL_UNSIGNED_BYTE": "GL_R8", - "GL_UNSIGNED_SHORT": "GL_R16_EXT", - "GL_BYTE": "GL_R8_SNORM", - "GL_SHORT": "GL_R16_SNORM_EXT", - "GL_FLOAT": "GL_R32F", - "GL_HALF_FLOAT": "GL_R16F", - "GL_HALF_FLOAT_OES": "GL_R16F" - }, - "GL_RED_INTEGER": { - "GL_UNSIGNED_BYTE": "GL_R8UI", - "GL_BYTE": "GL_R8I", - "GL_UNSIGNED_SHORT": "GL_R16UI", - "GL_SHORT": "GL_R16I", - "GL_UNSIGNED_INT": "GL_R32UI", - "GL_INT": "GL_R32I" - }, - "GL_LUMINANCE_ALPHA": { - "GL_UNSIGNED_BYTE": "GL_LUMINANCE8_ALPHA8_EXT", - "GL_FLOAT": "GL_LUMINANCE_ALPHA32F_EXT", - "GL_HALF_FLOAT": "GL_LUMINANCE_ALPHA16F_EXT", - "GL_HALF_FLOAT_OES": "GL_LUMINANCE_ALPHA16F_EXT" - }, - "GL_LUMINANCE": { - "GL_UNSIGNED_BYTE": "GL_LUMINANCE8_EXT", - "GL_FLOAT": "GL_LUMINANCE32F_EXT", - "GL_HALF_FLOAT": "GL_LUMINANCE16F_EXT", - "GL_HALF_FLOAT_OES": "GL_LUMINANCE16F_EXT" - }, - "GL_ALPHA": { - "GL_UNSIGNED_BYTE": "GL_ALPHA8_EXT", - "GL_FLOAT": "GL_ALPHA32F_EXT", - "GL_HALF_FLOAT": "GL_ALPHA16F_EXT", - "GL_HALF_FLOAT_OES": "GL_ALPHA16F_EXT" - }, - "GL_BGRA_EXT": { - "GL_UNSIGNED_BYTE": "GL_BGRA8_EXT", - "GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT": "GL_BGRA4_ANGLEX", - "GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT": "GL_BGR5_A1_ANGLEX", - "GL_UNSIGNED_SHORT_5_6_5": "GL_BGR565_ANGLEX" - }, - "GL_SRGB_EXT": { - "GL_UNSIGNED_BYTE": "GL_SRGB8" - }, - "GL_SRGB_ALPHA_EXT": { - "GL_UNSIGNED_BYTE": "GL_SRGB8_ALPHA8" - }, - "GL_COMPRESSED_RGB_S3TC_DXT1_EXT": { - "GL_UNSIGNED_BYTE": "GL_COMPRESSED_RGB_S3TC_DXT1_EXT" - }, - "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT": { - "GL_UNSIGNED_BYTE": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" - }, - "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE": { - "GL_UNSIGNED_BYTE": "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE" - }, - "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE": { - "GL_UNSIGNED_BYTE": "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE" - }, - "GL_DEPTH_COMPONENT": { - "GL_UNSIGNED_SHORT": "GL_DEPTH_COMPONENT16", - "GL_UNSIGNED_INT": "GL_DEPTH_COMPONENT32_OES", - "GL_FLOAT": "GL_DEPTH_COMPONENT32F" - }, - "GL_STENCIL": { - "GL_UNSIGNED_BYTE": "GL_STENCIL_INDEX8" - }, - "GL_DEPTH_STENCIL": { - "GL_UNSIGNED_INT_24_8": "GL_DEPTH24_STENCIL8", - "GL_FLOAT_32_UNSIGNED_INT_24_8_REV": "GL_DEPTH32F_STENCIL8" - } -} diff --git a/gfx/angle/src/libANGLE/formatutils.cpp b/gfx/angle/src/libANGLE/formatutils.cpp index 2aa2e75d4..9a8c1b790 100755 --- a/gfx/angle/src/libANGLE/formatutils.cpp +++ b/gfx/angle/src/libANGLE/formatutils.cpp @@ -16,13 +16,154 @@ using namespace angle; namespace gl { +namespace +{ // ES2 requires that format is equal to internal format at all glTex*Image2D entry points and the implementation // can decide the true, sized, internal format. The ES2FormatMap determines the internal format for all valid // format and type combinations. -GLenum GetSizedFormatInternal(GLenum format, GLenum type); -namespace +typedef std::pair<FormatType, GLenum> FormatPair; +typedef std::map<FormatType, GLenum> FormatMap; + +// A helper function to insert data into the format map with fewer characters. +void InsertFormatMapping(FormatMap *map, GLenum format, GLenum type, GLenum internalFormat) +{ + map->insert(FormatPair(FormatType(format, type), internalFormat)); +} + +FormatMap BuildFormatMap() +{ + FormatMap map; + + // clang-format off + // | Format | Type | Internal format | + InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA8); + InsertFormatMapping(&map, GL_RGBA, GL_BYTE, GL_RGBA8_SNORM); + InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_RGBA4); + InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_RGB5_A1); + InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2); + InsertFormatMapping(&map, GL_RGBA, GL_FLOAT, GL_RGBA32F); + InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT, GL_RGBA16F); + InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT_OES, GL_RGBA16F); + + InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_RGBA8UI); + InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_BYTE, GL_RGBA8I); + InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_RGBA16UI); + InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_SHORT, GL_RGBA16I); + InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_RGBA32UI); + InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_INT, GL_RGBA32I); + InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2UI); + + InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_BYTE, GL_RGB8); + InsertFormatMapping(&map, GL_RGB, GL_BYTE, GL_RGB8_SNORM); + InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB565); + InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_R11F_G11F_B10F); + InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_RGB9_E5); + InsertFormatMapping(&map, GL_RGB, GL_FLOAT, GL_RGB32F); + InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT, GL_RGB16F); + InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT_OES, GL_RGB16F); + + InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_RGB8UI); + InsertFormatMapping(&map, GL_RGB_INTEGER, GL_BYTE, GL_RGB8I); + InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_RGB16UI); + InsertFormatMapping(&map, GL_RGB_INTEGER, GL_SHORT, GL_RGB16I); + InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_RGB32UI); + InsertFormatMapping(&map, GL_RGB_INTEGER, GL_INT, GL_RGB32I); + + InsertFormatMapping(&map, GL_RG, GL_UNSIGNED_BYTE, GL_RG8); + InsertFormatMapping(&map, GL_RG, GL_BYTE, GL_RG8_SNORM); + InsertFormatMapping(&map, GL_RG, GL_FLOAT, GL_RG32F); + InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT, GL_RG16F); + InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT_OES, GL_RG16F); + + InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_RG8UI); + InsertFormatMapping(&map, GL_RG_INTEGER, GL_BYTE, GL_RG8I); + InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_RG16UI); + InsertFormatMapping(&map, GL_RG_INTEGER, GL_SHORT, GL_RG16I); + InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_RG32UI); + InsertFormatMapping(&map, GL_RG_INTEGER, GL_INT, GL_RG32I); + + InsertFormatMapping(&map, GL_RED, GL_UNSIGNED_BYTE, GL_R8); + InsertFormatMapping(&map, GL_RED, GL_BYTE, GL_R8_SNORM); + InsertFormatMapping(&map, GL_RED, GL_FLOAT, GL_R32F); + InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT, GL_R16F); + InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT_OES, GL_R16F); + + InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_R8UI); + InsertFormatMapping(&map, GL_RED_INTEGER, GL_BYTE, GL_R8I); + InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_R16UI); + InsertFormatMapping(&map, GL_RED_INTEGER, GL_SHORT, GL_R16I); + InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_R32UI); + InsertFormatMapping(&map, GL_RED_INTEGER, GL_INT, GL_R32I); + + InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_LUMINANCE8_ALPHA8_EXT); + InsertFormatMapping(&map, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE8_EXT); + InsertFormatMapping(&map, GL_ALPHA, GL_UNSIGNED_BYTE, GL_ALPHA8_EXT); + InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_LUMINANCE_ALPHA32F_EXT); + InsertFormatMapping(&map, GL_LUMINANCE, GL_FLOAT, GL_LUMINANCE32F_EXT); + InsertFormatMapping(&map, GL_ALPHA, GL_FLOAT, GL_ALPHA32F_EXT); + InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_LUMINANCE_ALPHA16F_EXT); + InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_LUMINANCE_ALPHA16F_EXT); + InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT, GL_LUMINANCE16F_EXT); + InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_LUMINANCE16F_EXT); + InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT, GL_ALPHA16F_EXT); + InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT_OES, GL_ALPHA16F_EXT); + + InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_BGRA8_EXT); + InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_BGRA4_ANGLEX); + InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_BGR5_A1_ANGLEX); + + InsertFormatMapping(&map, GL_SRGB_EXT, GL_UNSIGNED_BYTE, GL_SRGB8); + InsertFormatMapping(&map, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_SRGB8_ALPHA8); + + InsertFormatMapping(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGB_S3TC_DXT1_EXT); + InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); + InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE); + InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE); + + InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_DEPTH_COMPONENT16); + InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_DEPTH_COMPONENT32_OES); + InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F); + + InsertFormatMapping(&map, GL_STENCIL, GL_UNSIGNED_BYTE, GL_STENCIL_INDEX8); + + InsertFormatMapping(&map, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8); + InsertFormatMapping(&map, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_DEPTH32F_STENCIL8); + + // From GL_EXT_texture_norm16 + InsertFormatMapping(&map, GL_RED, GL_UNSIGNED_SHORT, GL_R16_EXT); + InsertFormatMapping(&map, GL_RED, GL_SHORT, GL_R16_SNORM_EXT); + InsertFormatMapping(&map, GL_RG, GL_UNSIGNED_SHORT, GL_RG16_EXT); + InsertFormatMapping(&map, GL_RG, GL_SHORT, GL_RG16_SNORM_EXT); + InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_SHORT, GL_RGB16_EXT); + InsertFormatMapping(&map, GL_RGB, GL_SHORT, GL_RGB16_SNORM_EXT); + InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT, GL_RGBA16_EXT); + InsertFormatMapping(&map, GL_RGBA, GL_SHORT, GL_RGBA16_SNORM_EXT); + // clang-format on + + return map; +} + +GLenum GetSizedFormatInternal(GLenum format, GLenum type) { + static const FormatMap formatMap = BuildFormatMap(); + auto iter = formatMap.find(FormatType(format, type)); + if (iter != formatMap.end()) + { + return iter->second; + } + + // TODO(jmadill): Fix this hack. + if (format == GL_BGRA_EXT && type == GL_UNSIGNED_SHORT_5_6_5) + return GL_BGR565_ANGLEX; + + if (format == GL_NONE) + return GL_NONE; + + UNREACHABLE(); + return GL_NONE; +} + typedef std::pair<GLenum, InternalFormat> InternalFormatInfoPair; typedef std::map<GLenum, InternalFormat> InternalFormatInfoMap; @@ -71,20 +212,20 @@ bool operator<(const Type& a, const Type& b) } // Information about internal formats -static bool AlwaysSupported(const Version &, const Extensions &) +static bool AlwaysSupported(GLuint, const Extensions &) { return true; } -static bool NeverSupported(const Version &, const Extensions &) +static bool NeverSupported(GLuint, const Extensions &) { return false; } -template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion> -static bool RequireES(const Version &clientVersion, const Extensions &) +template <GLuint minCoreGLVersion> +static bool RequireES(GLuint clientVersion, const Extensions &) { - return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion); + return clientVersion >= minCoreGLVersion; } // Pointer to a boolean memeber of the Extensions struct @@ -92,101 +233,92 @@ typedef bool(Extensions::*ExtensionBool); // Check support for a single extension template <ExtensionBool bool1> -static bool RequireExt(const Version &, const Extensions &extensions) +static bool RequireExt(GLuint, const Extensions & extensions) { return extensions.*bool1; } // Check for a minimum client version or a single extension -template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion, ExtensionBool bool1> -static bool RequireESOrExt(const Version &clientVersion, const Extensions &extensions) +template <GLuint minCoreGLVersion, ExtensionBool bool1> +static bool RequireESOrExt(GLuint clientVersion, const Extensions &extensions) { - return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) || - extensions.*bool1; + return clientVersion >= minCoreGLVersion || extensions.*bool1; } // Check for a minimum client version or two extensions -template <GLuint minCoreGLMajorVersion, - GLuint minCoreGLMinorVersion, - ExtensionBool bool1, - ExtensionBool bool2> -static bool RequireESOrExtAndExt(const Version &clientVersion, const Extensions &extensions) +template <GLuint minCoreGLVersion, ExtensionBool bool1, ExtensionBool bool2> +static bool RequireESOrExtAndExt(GLuint clientVersion, const Extensions &extensions) { - return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) || - (extensions.*bool1 && extensions.*bool2); + return clientVersion >= minCoreGLVersion || (extensions.*bool1 && extensions.*bool2); } // Check for a minimum client version or at least one of two extensions -template <GLuint minCoreGLMajorVersion, - GLuint minCoreGLMinorVersion, - ExtensionBool bool1, - ExtensionBool bool2> -static bool RequireESOrExtOrExt(const Version &clientVersion, const Extensions &extensions) +template <GLuint minCoreGLVersion, ExtensionBool bool1, ExtensionBool bool2> +static bool RequireESOrExtOrExt(GLuint clientVersion, const Extensions &extensions) { - return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) || - extensions.*bool1 || extensions.*bool2; + return clientVersion >= minCoreGLVersion || extensions.*bool1 || extensions.*bool2; } // Check support for two extensions template <ExtensionBool bool1, ExtensionBool bool2> -static bool RequireExtAndExt(const Version &, const Extensions &extensions) +static bool RequireExtAndExt(GLuint, const Extensions &extensions) { return extensions.*bool1 && extensions.*bool2; } // Check support for either of two extensions template <ExtensionBool bool1, ExtensionBool bool2> -static bool RequireExtOrExt(const Version &, const Extensions &extensions) +static bool RequireExtOrExt(GLuint, const Extensions &extensions) { return extensions.*bool1 || extensions.*bool2; } // Special function for half float formats with three or four channels. -static bool HalfFloatSupport(const Version &clientVersion, const Extensions &extensions) +static bool HalfFloatSupport(GLuint clientVersion, const Extensions &extensions) { - return clientVersion >= Version(3, 0) || extensions.textureHalfFloat; + return clientVersion >= 3 || extensions.textureHalfFloat; } -static bool HalfFloatRenderableSupport(const Version &clientVersion, const Extensions &extensions) +static bool HalfFloatRenderableSupport(GLuint clientVersion, const Extensions &extensions) { return HalfFloatSupport(clientVersion, extensions) && extensions.colorBufferHalfFloat; } // Special function for half float formats with one or two channels. -static bool HalfFloatSupportRG(const Version &clientVersion, const Extensions &extensions) +static bool HalfFloatSupportRG(GLuint clientVersion, const Extensions &extensions) { - return clientVersion >= Version(3, 0) || (extensions.textureHalfFloat && extensions.textureRG); + return clientVersion >= 3 || (extensions.textureHalfFloat && extensions.textureRG); } -static bool HalfFloatRenderableSupportRG(const Version &clientVersion, const Extensions &extensions) +static bool HalfFloatRenderableSupportRG(GLuint clientVersion, const Extensions &extensions) { return HalfFloatSupportRG(clientVersion, extensions) && extensions.colorBufferHalfFloat; } // Special function for float formats with three or four channels. -static bool FloatSupport(const Version &clientVersion, const Extensions &extensions) +static bool FloatSupport(GLuint clientVersion, const Extensions &extensions) { - return clientVersion >= Version(3, 0) || extensions.textureFloat; + return clientVersion >= 3 || extensions.textureFloat; } -static bool FloatRenderableSupport(const Version &clientVersion, const Extensions &extensions) +static bool FloatRenderableSupport(GLuint clientVersion, const Extensions &extensions) { // We don't expose colorBufferFloat in ES2, but we silently support rendering to float. return FloatSupport(clientVersion, extensions) && - (extensions.colorBufferFloat || clientVersion == Version(2, 0)); + (extensions.colorBufferFloat || clientVersion == 2); } // Special function for float formats with one or two channels. -static bool FloatSupportRG(const Version &clientVersion, const Extensions &extensions) +static bool FloatSupportRG(GLuint clientVersion, const Extensions &extensions) { - return clientVersion >= Version(3, 0) || (extensions.textureFloat && extensions.textureRG); + return clientVersion >= 3 || (extensions.textureFloat && extensions.textureRG); } -static bool FloatRenderableSupportRG(const Version &clientVersion, const Extensions &extensions) +static bool FloatRenderableSupportRG(GLuint clientVersion, const Extensions &extensions) { // We don't expose colorBufferFloat in ES2, but we silently support rendering to float. return FloatSupportRG(clientVersion, extensions) && - (extensions.colorBufferFloat || clientVersion == Version(2, 0)); + (extensions.colorBufferFloat || clientVersion == 2); } InternalFormat::InternalFormat() @@ -220,26 +352,6 @@ bool InternalFormat::isLUMA() const (luminanceBits + alphaBits) > 0); } -GLenum InternalFormat::getReadPixelsFormat() const -{ - return format; -} - -GLenum InternalFormat::getReadPixelsType() const -{ - switch (type) - { - case GL_HALF_FLOAT: - // The internal format may have a type of GL_HALF_FLOAT but when exposing this type as - // the IMPLEMENTATION_READ_TYPE, only HALF_FLOAT_OES is allowed by - // OES_texture_half_float - return GL_HALF_FLOAT_OES; - - default: - return type; - } -} - Format::Format(GLenum internalFormat) : Format(GetInternalFormatInfo(internalFormat)) { } @@ -434,48 +546,48 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() // clang-format off - // | Internal format | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable | - AddRGBAFormat(&map, GL_R8, 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureRG>, RequireESOrExt<3, 0, &Extensions::textureRG>, AlwaysSupported); - AddRGBAFormat(&map, GL_R8_SNORM, 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); - AddRGBAFormat(&map, GL_RG8, 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureRG>, RequireESOrExt<3, 0, &Extensions::textureRG>, AlwaysSupported); - AddRGBAFormat(&map, GL_RG8_SNORM, 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); - AddRGBAFormat(&map, GL_RGB8, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::rgb8rgba8>, RequireESOrExt<3, 0, &Extensions::rgb8rgba8>, AlwaysSupported); - AddRGBAFormat(&map, GL_RGB8_SNORM, 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); - AddRGBAFormat(&map, GL_RGB565, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); - AddRGBAFormat(&map, GL_RGBA4, 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); - AddRGBAFormat(&map, GL_RGB5_A1, 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); - AddRGBAFormat(&map, GL_RGBA8, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::rgb8rgba8>, RequireESOrExt<3, 0, &Extensions::rgb8rgba8>, AlwaysSupported); - AddRGBAFormat(&map, GL_RGBA8_SNORM, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); - AddRGBAFormat(&map, GL_RGB10_A2, 10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireES<3, 0>, RequireES<3, 0>, AlwaysSupported); - AddRGBAFormat(&map, GL_RGB10_A2UI, 10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_SRGB8, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, 0, &Extensions::sRGB>, NeverSupported, AlwaysSupported); - AddRGBAFormat(&map, GL_SRGB8_ALPHA8, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, 0, &Extensions::sRGB>, RequireESOrExt<3, 0, &Extensions::sRGB>, AlwaysSupported); - AddRGBAFormat(&map, GL_RGB9_E5, 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); - AddRGBAFormat(&map, GL_R8I, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_R8UI, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_R16I, 16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_R16UI, 16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_R32I, 32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_R32UI, 32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_RG8I, 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_RG8UI, 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_RG16I, 16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_RG16UI, 16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_RG32I, 32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_R11F_G11F_B10F, 11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, RequireES<3, 0>, RequireExt<&Extensions::colorBufferFloat>, AlwaysSupported); - AddRGBAFormat(&map, GL_RG32UI, 32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_RGB8I, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); - AddRGBAFormat(&map, GL_RGB8UI, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); - AddRGBAFormat(&map, GL_RGB16I, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); - AddRGBAFormat(&map, GL_RGB16UI, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); - AddRGBAFormat(&map, GL_RGB32I, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); - AddRGBAFormat(&map, GL_RGB32UI, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); - AddRGBAFormat(&map, GL_RGBA8I, 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_RGBA8UI, 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_RGBA16I, 16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_RGBA16UI, 16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_RGBA32I, 32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); - AddRGBAFormat(&map, GL_RGBA32UI, 32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); + // | Internal format | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable | + AddRGBAFormat(&map, GL_R8, 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::textureRG>, RequireESOrExt<3, &Extensions::textureRG>, AlwaysSupported); + AddRGBAFormat(&map, GL_R8_SNORM, 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported); + AddRGBAFormat(&map, GL_RG8, 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::textureRG>, RequireESOrExt<3, &Extensions::textureRG>, AlwaysSupported); + AddRGBAFormat(&map, GL_RG8_SNORM, 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported); + AddRGBAFormat(&map, GL_RGB8, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::rgb8rgba8>, RequireESOrExt<3, &Extensions::rgb8rgba8>, AlwaysSupported); + AddRGBAFormat(&map, GL_RGB8_SNORM, 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported); + AddRGBAFormat(&map, GL_RGB565, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireES<2>, RequireES<2>, AlwaysSupported); + AddRGBAFormat(&map, GL_RGBA4, 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireES<2>, RequireES<2>, AlwaysSupported); + AddRGBAFormat(&map, GL_RGB5_A1, 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireES<2>, RequireES<2>, AlwaysSupported); + AddRGBAFormat(&map, GL_RGBA8, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::rgb8rgba8>, RequireESOrExt<3, &Extensions::rgb8rgba8>, AlwaysSupported); + AddRGBAFormat(&map, GL_RGBA8_SNORM, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported); + AddRGBAFormat(&map, GL_RGB10_A2, 10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireES<3>, RequireES<3>, AlwaysSupported); + AddRGBAFormat(&map, GL_RGB10_A2UI, 10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_SRGB8, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, &Extensions::sRGB>, NeverSupported, AlwaysSupported); + AddRGBAFormat(&map, GL_SRGB8_ALPHA8, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, &Extensions::sRGB>, RequireESOrExt<3, &Extensions::sRGB>, AlwaysSupported); + AddRGBAFormat(&map, GL_RGB9_E5, 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, RequireES<3>, NeverSupported, AlwaysSupported); + AddRGBAFormat(&map, GL_R8I, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_R8UI, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_R16I, 16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_R16UI, 16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_R32I, 32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_R32UI, 32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_RG8I, 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_RG8UI, 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_RG16I, 16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_RG16UI, 16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_RG32I, 32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_R11F_G11F_B10F, 11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, RequireES<3>, RequireExt<&Extensions::colorBufferFloat>, AlwaysSupported); + AddRGBAFormat(&map, GL_RG32UI, 32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_RGB8I, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported); + AddRGBAFormat(&map, GL_RGB8UI, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported); + AddRGBAFormat(&map, GL_RGB16I, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported); + AddRGBAFormat(&map, GL_RGB16UI, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported); + AddRGBAFormat(&map, GL_RGB32I, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported); + AddRGBAFormat(&map, GL_RGB32UI, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported); + AddRGBAFormat(&map, GL_RGBA8I, 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_RGBA8UI, 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_RGBA16I, 16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_RGBA16UI, 16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_RGBA32I, 32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported); + AddRGBAFormat(&map, GL_RGBA32UI, 32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported); AddRGBAFormat(&map, GL_BGRA8_EXT, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported); AddRGBAFormat(&map, GL_BGRA4_ANGLEX, 4, 4, 4, 4, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported); @@ -497,13 +609,13 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() AddRGBAFormat(&map, GL_RGBA32F, 32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, FloatSupport, FloatRenderableSupport, RequireExt<&Extensions::textureFloatLinear> ); // Depth stencil formats - // | Internal format | D |S | X | Format | Type | Component type | Supported | Renderable | Filterable | - AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT16, 16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireES<2, 0>, RequireES<2, 0>, RequireESOrExt<3, 0, &Extensions::depthTextures>); - AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT24, 24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireES<3, 0>, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::depthTextures>); - AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32F, 32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireES<3, 0>, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::depthTextures>); - AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32_OES, 32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireExtOrExt<&Extensions::depthTextures, &Extensions::depth32>, RequireExtOrExt<&Extensions::depthTextures, &Extensions::depth32>, AlwaysSupported ); - AddDepthStencilFormat(&map, GL_DEPTH24_STENCIL8, 24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, 0, &Extensions::depthTextures>, RequireESOrExtOrExt<3, 0, &Extensions::depthTextures, &Extensions::packedDepthStencil>, AlwaysSupported ); - AddDepthStencilFormat(&map, GL_DEPTH32F_STENCIL8, 32, 8, 24, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, RequireES<3, 0>, RequireES<3, 0>, AlwaysSupported ); + // | Internal format | D |S | X | Format | Type | Component type | Supported | Renderable | Filterable | + AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT16, 16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireES<2>, RequireES<2>, RequireESOrExt<3, &Extensions::depthTextures>); + AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT24, 24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireES<3>, RequireES<3>, RequireESOrExt<3, &Extensions::depthTextures>); + AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32F, 32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireES<3>, RequireES<3>, RequireESOrExt<3, &Extensions::depthTextures>); + AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32_OES, 32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireExtOrExt<&Extensions::depthTextures, &Extensions::depth32>, RequireExtOrExt<&Extensions::depthTextures, &Extensions::depth32>, AlwaysSupported ); + AddDepthStencilFormat(&map, GL_DEPTH24_STENCIL8, 24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, &Extensions::depthTextures>, RequireESOrExtOrExt<3, &Extensions::depthTextures, &Extensions::packedDepthStencil>, AlwaysSupported ); + AddDepthStencilFormat(&map, GL_DEPTH32F_STENCIL8, 32, 8, 24, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, RequireES<3>, RequireES<3>, AlwaysSupported ); // STENCIL_INDEX8 is special-cased, see around the bottom of the list. // Luminance alpha formats @@ -519,36 +631,36 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA16F_EXT, LUMAFormat(16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported))); // Unsized formats - // | Internal format | Format | Supported | Renderable | Filterable | - AddUnsizedFormat(&map, GL_ALPHA, GL_ALPHA, RequireES<2, 0>, NeverSupported, AlwaysSupported); - AddUnsizedFormat(&map, GL_LUMINANCE, GL_LUMINANCE, RequireES<2, 0>, NeverSupported, AlwaysSupported); - AddUnsizedFormat(&map, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, RequireES<2, 0>, NeverSupported, AlwaysSupported); - AddUnsizedFormat(&map, GL_RED, GL_RED, RequireESOrExt<3, 0, &Extensions::textureRG>, NeverSupported, AlwaysSupported); - AddUnsizedFormat(&map, GL_RG, GL_RG, RequireESOrExt<3, 0, &Extensions::textureRG>, NeverSupported, AlwaysSupported); - AddUnsizedFormat(&map, GL_RGB, GL_RGB, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); - AddUnsizedFormat(&map, GL_RGBA, GL_RGBA, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); - AddUnsizedFormat(&map, GL_RED_INTEGER, GL_RED_INTEGER, RequireES<3, 0>, NeverSupported, NeverSupported ); - AddUnsizedFormat(&map, GL_RG_INTEGER, GL_RG_INTEGER, RequireES<3, 0>, NeverSupported, NeverSupported ); - AddUnsizedFormat(&map, GL_RGB_INTEGER, GL_RGB_INTEGER, RequireES<3, 0>, NeverSupported, NeverSupported ); - AddUnsizedFormat(&map, GL_RGBA_INTEGER, GL_RGBA_INTEGER, RequireES<3, 0>, NeverSupported, NeverSupported ); - AddUnsizedFormat(&map, GL_BGRA_EXT, GL_BGRA_EXT, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported); - AddUnsizedFormat(&map, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); - AddUnsizedFormat(&map, GL_DEPTH_STENCIL, GL_DEPTH_STENCIL, RequireESOrExt<3, 0, &Extensions::packedDepthStencil>, RequireESOrExt<3, 0, &Extensions::packedDepthStencil>, AlwaysSupported); - AddUnsizedFormat(&map, GL_SRGB_EXT, GL_RGB, RequireESOrExt<3, 0, &Extensions::sRGB>, NeverSupported, AlwaysSupported); - AddUnsizedFormat(&map, GL_SRGB_ALPHA_EXT, GL_RGBA, RequireESOrExt<3, 0, &Extensions::sRGB>, RequireESOrExt<3, 0, &Extensions::sRGB>, AlwaysSupported); + // | Internal format | Format | Supported | Renderable | Filterable | + AddUnsizedFormat(&map, GL_ALPHA, GL_ALPHA, RequireES<2>, NeverSupported, AlwaysSupported); + AddUnsizedFormat(&map, GL_LUMINANCE, GL_LUMINANCE, RequireES<2>, NeverSupported, AlwaysSupported); + AddUnsizedFormat(&map, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, RequireES<2>, NeverSupported, AlwaysSupported); + AddUnsizedFormat(&map, GL_RED, GL_RED, RequireESOrExt<3, &Extensions::textureRG>, NeverSupported, AlwaysSupported); + AddUnsizedFormat(&map, GL_RG, GL_RG, RequireESOrExt<3, &Extensions::textureRG>, NeverSupported, AlwaysSupported); + AddUnsizedFormat(&map, GL_RGB, GL_RGB, RequireES<2>, RequireES<2>, AlwaysSupported); + AddUnsizedFormat(&map, GL_RGBA, GL_RGBA, RequireES<2>, RequireES<2>, AlwaysSupported); + AddUnsizedFormat(&map, GL_RED_INTEGER, GL_RED_INTEGER, RequireES<3>, NeverSupported, NeverSupported ); + AddUnsizedFormat(&map, GL_RG_INTEGER, GL_RG_INTEGER, RequireES<3>, NeverSupported, NeverSupported ); + AddUnsizedFormat(&map, GL_RGB_INTEGER, GL_RGB_INTEGER, RequireES<3>, NeverSupported, NeverSupported ); + AddUnsizedFormat(&map, GL_RGBA_INTEGER, GL_RGBA_INTEGER, RequireES<3>, NeverSupported, NeverSupported ); + AddUnsizedFormat(&map, GL_BGRA_EXT, GL_BGRA_EXT, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported); + AddUnsizedFormat(&map, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, RequireES<2>, RequireES<2>, AlwaysSupported); + AddUnsizedFormat(&map, GL_DEPTH_STENCIL, GL_DEPTH_STENCIL, RequireESOrExt<3, &Extensions::packedDepthStencil>, RequireESOrExt<3, &Extensions::packedDepthStencil>, AlwaysSupported); + AddUnsizedFormat(&map, GL_SRGB_EXT, GL_RGB, RequireESOrExt<3, &Extensions::sRGB>, NeverSupported, AlwaysSupported); + AddUnsizedFormat(&map, GL_SRGB_ALPHA_EXT, GL_RGBA, RequireESOrExt<3, &Extensions::sRGB>, RequireESOrExt<3, &Extensions::sRGB>, AlwaysSupported); // Compressed formats, From ES 3.0.1 spec, table 3.16 - // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable | - map.insert(InternalFormatInfoPair(GL_COMPRESSED_R11_EAC, CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported))); - map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_R11_EAC, CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_SIGNED_R11_EAC, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported))); - map.insert(InternalFormatInfoPair(GL_COMPRESSED_RG11_EAC, CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_RG11_EAC, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported))); - map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_RG11_EAC, CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_SIGNED_RG11_EAC, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported))); - map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_ETC2, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported))); - map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_ETC2, GL_UNSIGNED_BYTE, true, RequireES<3, 0>, NeverSupported, AlwaysSupported))); - map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported))); - map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, true, RequireES<3, 0>, NeverSupported, AlwaysSupported))); - map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA8_ETC2_EAC, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported))); - map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE, true, RequireES<3, 0>, NeverSupported, AlwaysSupported))); + // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable | + map.insert(InternalFormatInfoPair(GL_COMPRESSED_R11_EAC, CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_R11_EAC, CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_SIGNED_R11_EAC, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_RG11_EAC, CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_RG11_EAC, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_RG11_EAC, CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_SIGNED_RG11_EAC, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_ETC2, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_ETC2, GL_UNSIGNED_BYTE, true, RequireES<3>, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, true, RequireES<3>, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA8_ETC2_EAC, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE, true, RequireES<3>, NeverSupported, AlwaysSupported))); // From GL_EXT_texture_compression_dxt1 // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable | @@ -600,11 +712,11 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() // - Multisampled buffer are disallowed for non-normalized integer component types and we want to support it for STENCIL_INDEX8 // - All other stencil formats (all depth-stencil) are either float or normalized // - It affects only validation of internalformat in RenderbufferStorageMultisample. - // | Internal format |D |S |X | Format | Type | Component type | Supported | Renderable | Filterable | - AddDepthStencilFormat(&map, GL_STENCIL_INDEX8, 0, 8, 0, GL_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireES<2, 0>, RequireES<2, 0>, NeverSupported); + // | Internal format |D |S |X | Format | Type | Component type | Supported | Renderable | Filterable | + AddDepthStencilFormat(&map, GL_STENCIL_INDEX8, 0, 8, 0, GL_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireES<2>, RequireES<2>, NeverSupported); // From GL_ANGLE_lossy_etc_decode - map.insert(InternalFormatInfoPair(GL_ETC1_RGB8_LOSSY_DECODE_ANGLE, CompressedFormat(4, 4, 64, 3, GL_ETC1_RGB8_LOSSY_DECODE_ANGLE, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::lossyETCDecode>, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_ETC1_RGB8_LOSSY_DECODE_ANGLE, CompressedFormat(4, 4, 64, 3, GL_ETC1_RGB8_OES, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::lossyETCDecode>, NeverSupported, AlwaysSupported))); // From GL_EXT_texture_norm16 // | Internal format | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable | @@ -714,23 +826,28 @@ const InternalFormat &GetInternalFormatInfo(GLenum internalFormat) else { static const InternalFormat defaultInternalFormat; + UNREACHABLE(); return defaultInternalFormat; } } -ErrorOrResult<GLuint> InternalFormat::computeRowPitch(GLsizei width, - GLint alignment, - GLint rowLength) const +gl::ErrorOrResult<GLuint> InternalFormat::computeRowPitch(GLenum formatType, + GLsizei width, + GLint alignment, + GLint rowLength) const { // Compressed images do not use pack/unpack parameters. if (compressed) { ASSERT(rowLength == 0); - return computeCompressedImageSize(Extents(width, 1, 1)); + return computeCompressedImageSize(formatType, gl::Extents(width, 1, 1)); } + const auto &typeInfo = GetTypeInfo(formatType); + CheckedNumeric<GLuint> checkedComponents(typeInfo.specialInterpretation ? 1u : componentCount); + CheckedNumeric<GLuint> checkedTypeBytes(typeInfo.bytes); CheckedNumeric<GLuint> checkedWidth(rowLength > 0 ? rowLength : width); - CheckedNumeric<GLuint> checkedRowBytes = checkedWidth * pixelBytes; + CheckedNumeric<GLuint> checkedRowBytes = checkedWidth * checkedComponents * checkedTypeBytes; ASSERT(alignment > 0 && isPow2(alignment)); CheckedNumeric<GLuint> checkedAlignment(alignment); @@ -739,31 +856,26 @@ ErrorOrResult<GLuint> InternalFormat::computeRowPitch(GLsizei width, return aligned.ValueOrDie(); } -ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLsizei height, - GLint imageHeight, - GLuint rowPitch) +gl::ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLenum formatType, + GLsizei width, + GLsizei height, + GLint alignment, + GLint rowLength, + GLint imageHeight) const { GLuint rows = (imageHeight > 0 ? static_cast<GLuint>(imageHeight) : static_cast<GLuint>(height)); - CheckedNumeric<GLuint> checkedRowPitch(rowPitch); + GLuint rowPitch = 0; + ANGLE_TRY_RESULT(computeRowPitch(formatType, width, alignment, rowLength), rowPitch); + CheckedNumeric<GLuint> checkedRowPitch(rowPitch); auto depthPitch = checkedRowPitch * rows; ANGLE_TRY_CHECKED_MATH(depthPitch); return depthPitch.ValueOrDie(); } -ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLsizei width, - GLsizei height, - GLint alignment, - GLint rowLength, - GLint imageHeight) const -{ - GLuint rowPitch = 0; - ANGLE_TRY_RESULT(computeRowPitch(width, alignment, rowLength), rowPitch); - return computeDepthPitch(height, imageHeight, rowPitch); -} - -ErrorOrResult<GLuint> InternalFormat::computeCompressedImageSize(const Extents &size) const +gl::ErrorOrResult<GLuint> InternalFormat::computeCompressedImageSize(GLenum formatType, + const gl::Extents &size) const { CheckedNumeric<GLuint> checkedWidth(size.width); CheckedNumeric<GLuint> checkedHeight(size.height); @@ -779,19 +891,21 @@ ErrorOrResult<GLuint> InternalFormat::computeCompressedImageSize(const Extents & return bytes.ValueOrDie(); } -ErrorOrResult<GLuint> InternalFormat::computeSkipBytes(GLuint rowPitch, - GLuint depthPitch, - const PixelStoreStateBase &state, - bool is3D) const +gl::ErrorOrResult<GLuint> InternalFormat::computeSkipBytes(GLuint rowPitch, + GLuint depthPitch, + GLint skipImages, + GLint skipRows, + GLint skipPixels, + bool applySkipImages) const { CheckedNumeric<GLuint> checkedRowPitch(rowPitch); CheckedNumeric<GLuint> checkedDepthPitch(depthPitch); - CheckedNumeric<GLuint> checkedSkipImages(static_cast<GLuint>(state.skipImages)); - CheckedNumeric<GLuint> checkedSkipRows(static_cast<GLuint>(state.skipRows)); - CheckedNumeric<GLuint> checkedSkipPixels(static_cast<GLuint>(state.skipPixels)); + CheckedNumeric<GLuint> checkedSkipImages(static_cast<GLuint>(skipImages)); + CheckedNumeric<GLuint> checkedSkipRows(static_cast<GLuint>(skipRows)); + CheckedNumeric<GLuint> checkedSkipPixels(static_cast<GLuint>(skipPixels)); CheckedNumeric<GLuint> checkedPixelBytes(pixelBytes); auto checkedSkipImagesBytes = checkedSkipImages * checkedDepthPitch; - if (!is3D) + if (!applySkipImages) { checkedSkipImagesBytes = 0; } @@ -801,48 +915,34 @@ ErrorOrResult<GLuint> InternalFormat::computeSkipBytes(GLuint rowPitch, return skipBytes.ValueOrDie(); } -ErrorOrResult<GLuint> InternalFormat::computePackUnpackEndByte(const Extents &size, - const PixelStoreStateBase &state, - bool is3D) const +gl::ErrorOrResult<GLuint> InternalFormat::computeUnpackSize( + GLenum formatType, + const gl::Extents &size, + const gl::PixelUnpackState &unpack) const { - GLuint rowPitch = 0; - ANGLE_TRY_RESULT(computeRowPitch(size.width, state.alignment, state.rowLength), - rowPitch); - - GLuint depthPitch = 0; - if (is3D) - { - ANGLE_TRY_RESULT(computeDepthPitch(size.height, state.imageHeight, rowPitch), depthPitch); - } - - CheckedNumeric<GLuint> checkedCopyBytes = 0; + // Compressed images do not use unpack parameters. if (compressed) { - ANGLE_TRY_RESULT(computeCompressedImageSize(size), checkedCopyBytes); + return computeCompressedImageSize(formatType, size); } - else if (size.height != 0 && (!is3D || size.depth != 0)) - { - CheckedNumeric<GLuint> bytes = pixelBytes; - checkedCopyBytes += size.width * bytes; - CheckedNumeric<GLuint> heightMinusOne = size.height - 1; - checkedCopyBytes += heightMinusOne * rowPitch; + base::CheckedNumeric<GLuint> checkedGroups(unpack.rowLength > 0 ? unpack.rowLength + : size.width); + base::CheckedNumeric<GLuint> checkedRows(unpack.imageHeight > 0 ? unpack.imageHeight + : size.height); - if (is3D) - { - CheckedNumeric<GLuint> depthMinusOne = size.depth - 1; - checkedCopyBytes += depthMinusOne * depthPitch; - } - } + // Compute the groups of all the layers in (0,depth-1) + auto layerGroups = checkedGroups * checkedRows * (size.depth - 1); + + // Compute the groups in the last layer (for non-3D textures, the only one) + auto lastLayerGroups = checkedGroups * (size.height - 1) + size.width; - CheckedNumeric<GLuint> checkedSkipBytes = 0; - ANGLE_TRY_RESULT(computeSkipBytes(rowPitch, depthPitch, state, is3D), - checkedSkipBytes); + // The total size is the sum times the bytes per pixel. + auto totalSize = (layerGroups + lastLayerGroups) * pixelBytes; - CheckedNumeric<GLuint> endByte = checkedCopyBytes + checkedSkipBytes; + ANGLE_TRY_CHECKED_MATH(totalSize); - ANGLE_TRY_CHECKED_MATH(endByte); - return endByte.ValueOrDie(); + return totalSize.ValueOrDie(); } GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type) diff --git a/gfx/angle/src/libANGLE/formatutils.h b/gfx/angle/src/libANGLE/formatutils.h index d6f9402d4..0ad5bd0ab 100755 --- a/gfx/angle/src/libANGLE/formatutils.h +++ b/gfx/angle/src/libANGLE/formatutils.h @@ -15,7 +15,6 @@ #include "angle_gl.h" #include "libANGLE/Caps.h" #include "libANGLE/Error.h" -#include "libANGLE/Version.h" #include "libANGLE/angletypes.h" namespace gl @@ -48,32 +47,29 @@ struct InternalFormat { InternalFormat(); - ErrorOrResult<GLuint> computeRowPitch(GLsizei width, - GLint alignment, - GLint rowLength) const; - static ErrorOrResult<GLuint> computeDepthPitch(GLsizei height, - GLint imageHeight, - GLuint rowPitch); - ErrorOrResult<GLuint> computeDepthPitch(GLsizei width, - GLsizei height, - GLint alignment, - GLint rowLength, - GLint imageHeight) const; - - ErrorOrResult<GLuint> computeCompressedImageSize(const Extents &size) const; - - ErrorOrResult<GLuint> computeSkipBytes(GLuint rowPitch, - GLuint depthPitch, - const PixelStoreStateBase &state, - bool is3D) const; - - ErrorOrResult<GLuint> computePackUnpackEndByte(const Extents &size, - const PixelStoreStateBase &state, - bool is3D) const; + gl::ErrorOrResult<GLuint> computeRowPitch(GLenum formatType, + GLsizei width, + GLint alignment, + GLint rowLength) const; + gl::ErrorOrResult<GLuint> computeDepthPitch(GLenum formatType, + GLsizei width, + GLsizei height, + GLint alignment, + GLint rowLength, + GLint imageHeight) const; + gl::ErrorOrResult<GLuint> computeCompressedImageSize(GLenum formatType, + const gl::Extents &size) const; + gl::ErrorOrResult<GLuint> computeSkipBytes(GLuint rowPitch, + GLuint depthPitch, + GLint skipImages, + GLint skipRows, + GLint skipPixels, + bool applySkipImages) const; + gl::ErrorOrResult<GLuint> computeUnpackSize(GLenum formatType, + const gl::Extents &size, + const gl::PixelUnpackState &unpack) const; bool isLUMA() const; - GLenum getReadPixelsFormat() const; - GLenum getReadPixelsType() const; bool operator==(const InternalFormat &other) const; bool operator!=(const InternalFormat &other) const; @@ -106,7 +102,7 @@ struct InternalFormat GLenum componentType; GLenum colorEncoding; - typedef bool (*SupportCheckFunction)(const Version &, const Extensions &); + typedef bool (*SupportCheckFunction)(GLuint, const Extensions &); SupportCheckFunction textureSupport; SupportCheckFunction renderSupport; SupportCheckFunction filterSupport; @@ -271,7 +267,7 @@ enum VertexFormatType VERTEX_FORMAT_UINT210_INT, }; -typedef std::vector<VertexFormatType> InputLayout; +typedef std::vector<gl::VertexFormatType> InputLayout; struct VertexFormat : angle::NonCopyable { @@ -288,14 +284,6 @@ VertexFormatType GetVertexFormatType(const VertexAttribute &attrib); VertexFormatType GetVertexFormatType(const VertexAttribute &attrib, GLenum currentValueType); const VertexFormat &GetVertexFormatFromType(VertexFormatType vertexFormatType); -// Implemented in format_map_autogen.cpp -bool ValidES3Format(GLenum format); -bool ValidES3Type(GLenum type); -bool ValidES3FormatCombination(GLenum format, GLenum type, GLenum internalFormat); - -// Implemented in es3_copy_conversion_table_autogen.cpp -bool ValidES3CopyConversion(GLenum textureFormat, GLenum framebufferFormat); - } // namespace gl #endif // LIBANGLE_FORMATUTILS_H_ diff --git a/gfx/angle/src/libANGLE/gen_copy_conversion_table.py b/gfx/angle/src/libANGLE/gen_copy_conversion_table.py deleted file mode 100644 index f2c9603d5..000000000 --- a/gfx/angle/src/libANGLE/gen_copy_conversion_table.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/python -# Copyright 2016 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. -# -# gen_copy_conversion_table.py: -# Code generation for ES3 valid copy conversions table format map. - -from datetime import date -import sys - -sys.path.append('renderer') -import angle_format - -template_cpp = """// GENERATED FILE - DO NOT EDIT. -// Generated by {script_name} using data from {data_source_name}. -// -// Copyright {copyright_year} 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. -// -// format_map: -// Determining the sized internal format from a (format,type) pair. -// Also check es3 format combinations for validity. - -#include "angle_gl.h" -#include "common/debug.h" - -namespace gl -{{ - -bool ValidES3CopyConversion(GLenum textureFormat, GLenum framebufferFormat) -{{ - switch (textureFormat) - {{ -{texture_format_cases} default: - break; - }} - - return false; -}} - -}} // namespace gl -""" - -template_format_case = """ case {texture_format}: - switch (framebufferFormat) - {{ -{framebuffer_format_cases} return true; - default: - break; - }} - break; - -""" - -template_simple_case = """ case {key}: -""" - -def parse_texture_format_case(texture_format, framebuffer_formats): - framebuffer_format_cases = "" - for framebuffer_format in sorted(framebuffer_formats): - framebuffer_format_cases += template_simple_case.format(key = framebuffer_format) - return template_format_case.format( - texture_format = texture_format, framebuffer_format_cases = framebuffer_format_cases) - -data_source_name = 'es3_copy_conversion_formats.json' - -json_data = angle_format.load_json(data_source_name) - -format_map = {} - -for description, data in json_data.iteritems(): - for texture_format, framebuffer_format in data: - if texture_format not in format_map: - format_map[texture_format] = [] - format_map[texture_format] += [ framebuffer_format ] - -texture_format_cases = "" - -for texture_format, framebuffer_formats in sorted(format_map.iteritems()): - texture_format_cases += parse_texture_format_case(texture_format, framebuffer_formats) - -with open('es3_copy_conversion_table_autogen.cpp', 'wt') as out_file: - output_cpp = template_cpp.format( - script_name = sys.argv[0], - data_source_name = data_source_name, - copyright_year = date.today().year, - texture_format_cases = texture_format_cases) - out_file.write(output_cpp) - out_file.close() diff --git a/gfx/angle/src/libANGLE/gen_format_map.py b/gfx/angle/src/libANGLE/gen_format_map.py deleted file mode 100644 index b67f42784..000000000 --- a/gfx/angle/src/libANGLE/gen_format_map.py +++ /dev/null @@ -1,187 +0,0 @@ -#!/usr/bin/python -# Copyright 2016 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. -# -# gen_format_map.py: -# Code generation for GL format map. The format map matches between -# {format,type} and internal format. - -from datetime import date -import sys - -sys.path.append('renderer') -import angle_format - -template_cpp = """// GENERATED FILE - DO NOT EDIT. -// Generated by {script_name} using data from {data_source_name}. -// ES3 format info from {es3_data_source_name}. -// -// Copyright {copyright_year} 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. -// -// format_map: -// Determining the sized internal format from a (format,type) pair. -// Also check es3 format combinations for validity. - -#include "angle_gl.h" -#include "common/debug.h" - -namespace gl -{{ - -GLenum GetSizedFormatInternal(GLenum format, GLenum type) -{{ - switch (format) - {{ -{format_cases} case GL_NONE: - return GL_NONE; - - default: - break; - }} - - return GL_NONE; -}} - -bool ValidES3Format(GLenum format) -{{ - switch (format) - {{ -{es3_format_cases} return true; - - default: - return false; - }} -}} - -bool ValidES3Type(GLenum type) -{{ - switch (type) - {{ -{es3_type_cases} return true; - - default: - return false; - }} -}} - -bool ValidES3FormatCombination(GLenum format, GLenum type, GLenum internalFormat) -{{ - ASSERT(ValidES3Format(format) && ValidES3Type(type)); - - switch (format) - {{ -{es3_combo_cases} default: - UNREACHABLE(); - break; - }} - - return false; -}} - -}} // namespace gl -""" - -template_format_case = """ case {format}: - switch (type) - {{ -{type_cases} default: - break; - }} - break; - -""" - -template_simple_case = """ case {key}: - return {result}; -""" - -template_es3_combo_type_case = """ case {type}: - {{ - switch (internalFormat) - {{ -{internal_format_cases} return true; - default: - break; - }} - break; - }} -""" - -def parse_type_case(type, result): - return template_simple_case.format( - key = type, result = result) - -def parse_format_case(format, type_map): - type_cases = "" - for type, internal_format in sorted(type_map.iteritems()): - type_cases += parse_type_case(type, internal_format) - return template_format_case.format( - format = format, type_cases = type_cases) - -input_script = 'format_map_data.json' - -format_map = angle_format.load_json(input_script) - -format_cases = "" - -for format, type_map in sorted(format_map.iteritems()): - format_cases += parse_format_case(format, type_map) - -combo_data_file = 'es3_format_type_combinations.json' -es3_combo_data = angle_format.load_json(combo_data_file) -combo_data = [combo for sublist in es3_combo_data.values() for combo in sublist] - -types = set() -formats = set() -combos = {} - -for internal_format, format, type in combo_data: - types.update([type]) - formats.update([format]) - if format not in combos: - combos[format] = {} - if type not in combos[format]: - combos[format][type] = [internal_format] - else: - combos[format][type] += [internal_format] - -es3_format_cases = "" - -for format in sorted(formats): - es3_format_cases += " case " + format + ":\n" - -es3_type_cases = "" - -for type in sorted(types): - es3_type_cases += " case " + type + ":\n" - -es3_combo_cases = "" - -for format, type_combos in combos.iteritems(): - this_type_cases = "" - for type, combos in type_combos.iteritems(): - internal_format_cases = "" - for internal_format in combos: - internal_format_cases += " case " + internal_format + ":\n" - - this_type_cases += template_es3_combo_type_case.format( - type = type, internal_format_cases = internal_format_cases) - - es3_combo_cases += template_format_case.format( - format = format, type_cases = this_type_cases) - -with open('format_map_autogen.cpp', 'wt') as out_file: - output_cpp = template_cpp.format( - script_name = sys.argv[0], - data_source_name = input_script, - es3_data_source_name = combo_data_file, - copyright_year = date.today().year, - format_cases = format_cases, - es3_format_cases = es3_format_cases, - es3_type_cases = es3_type_cases, - es3_combo_cases = es3_combo_cases) - out_file.write(output_cpp) - out_file.close() diff --git a/gfx/angle/src/libANGLE/moz.build b/gfx/angle/src/libANGLE/moz.build index e127ccce1..7d12a1ca6 100755 --- a/gfx/angle/src/libANGLE/moz.build +++ b/gfx/angle/src/libANGLE/moz.build @@ -29,13 +29,11 @@ UNIFIED_SOURCES += [ '../compiler/preprocessor/Preprocessor.cpp', '../compiler/preprocessor/Token.cpp', '../compiler/preprocessor/Tokenizer.cpp', - '../compiler/translator/AddAndTrueToLoopCondition.cpp', '../compiler/translator/AddDefaultReturnStatements.cpp', '../compiler/translator/ArrayReturnValueToOutParameter.cpp', '../compiler/translator/ASTMetadataHLSL.cpp', '../compiler/translator/blocklayout.cpp', '../compiler/translator/blocklayoutHLSL.cpp', - '../compiler/translator/BreakVariableAliasingInInnerLoops.cpp', '../compiler/translator/BuiltInFunctionEmulator.cpp', '../compiler/translator/BuiltInFunctionEmulatorGLSL.cpp', '../compiler/translator/BuiltInFunctionEmulatorHLSL.cpp', @@ -43,8 +41,11 @@ UNIFIED_SOURCES += [ '../compiler/translator/CallDAG.cpp', '../compiler/translator/CodeGen.cpp', '../compiler/translator/Compiler.cpp', - '../compiler/translator/ConstantUnion.cpp', '../compiler/translator/DeferGlobalInitializers.cpp', + '../compiler/translator/depgraph/DependencyGraph.cpp', + '../compiler/translator/depgraph/DependencyGraphBuilder.cpp', + '../compiler/translator/depgraph/DependencyGraphOutput.cpp', + '../compiler/translator/depgraph/DependencyGraphTraverse.cpp', '../compiler/translator/Diagnostics.cpp', '../compiler/translator/DirectiveHandler.cpp', '../compiler/translator/EmulatePrecision.cpp', @@ -71,27 +72,28 @@ UNIFIED_SOURCES += [ '../compiler/translator/ParseContext.cpp', '../compiler/translator/PoolAlloc.cpp', '../compiler/translator/PruneEmptyDeclarations.cpp', - '../compiler/translator/QualifierTypes.cpp', '../compiler/translator/RecordConstantPrecision.cpp', '../compiler/translator/RegenerateStructNames.cpp', '../compiler/translator/RemoveDynamicIndexing.cpp', - '../compiler/translator/RemoveInvariantDeclaration.cpp', '../compiler/translator/RemovePow.cpp', '../compiler/translator/RemoveSwitchFallThrough.cpp', '../compiler/translator/RewriteDoWhile.cpp', '../compiler/translator/RewriteElseBlocks.cpp', - '../compiler/translator/RewriteUnaryMinusOperatorInt.cpp', + '../compiler/translator/RewriteTexelFetchOffset.cpp', '../compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp', '../compiler/translator/SearchSymbol.cpp', '../compiler/translator/SeparateArrayInitialization.cpp', '../compiler/translator/SeparateDeclarations.cpp', '../compiler/translator/SeparateExpressionsReturningArrays.cpp', + '../compiler/translator/ShaderLang.cpp', '../compiler/translator/ShaderVars.cpp', '../compiler/translator/SimplifyLoopConditions.cpp', '../compiler/translator/SplitSequenceOperator.cpp', '../compiler/translator/StructureHLSL.cpp', '../compiler/translator/SymbolTable.cpp', '../compiler/translator/TextureFunctionHLSL.cpp', + '../compiler/translator/timing/RestrictFragmentShaderTiming.cpp', + '../compiler/translator/timing/RestrictVertexShaderTiming.cpp', '../compiler/translator/TranslatorESSL.cpp', '../compiler/translator/TranslatorGLSL.cpp', '../compiler/translator/TranslatorHLSL.cpp', @@ -99,7 +101,6 @@ UNIFIED_SOURCES += [ '../compiler/translator/UnfoldShortCircuitAST.cpp', '../compiler/translator/UnfoldShortCircuitToIf.cpp', '../compiler/translator/UniformHLSL.cpp', - '../compiler/translator/UseInterfaceBlockFields.cpp', '../compiler/translator/util.cpp', '../compiler/translator/UtilsHLSL.cpp', '../compiler/translator/ValidateGlobalInitializer.cpp', @@ -128,9 +129,7 @@ UNIFIED_SOURCES += [ 'Debug.cpp', 'Device.cpp', 'Error.cpp', - 'es3_copy_conversion_table_autogen.cpp', 'Fence.cpp', - 'format_map_autogen.cpp', 'formatutils.cpp', 'Framebuffer.cpp', 'FramebufferAttachment.cpp', @@ -144,7 +143,6 @@ UNIFIED_SOURCES += [ 'Program.cpp', 'Query.cpp', 'queryconversions.cpp', - 'queryutils.cpp', 'Renderbuffer.cpp', 'renderer/ContextImpl.cpp', 'renderer/d3d/BufferD3D.cpp', @@ -184,15 +182,14 @@ UNIFIED_SOURCES += [ 'renderer/d3d/ShaderD3D.cpp', 'renderer/d3d/ShaderExecutableD3D.cpp', 'renderer/d3d/SurfaceD3D.cpp', - 'renderer/d3d/SwapChainD3D.cpp', 'renderer/d3d/TextureD3D.cpp', 'renderer/d3d/VaryingPacking.cpp', 'renderer/d3d/VertexBuffer.cpp', 'renderer/d3d/VertexDataManager.cpp', 'renderer/DeviceImpl.cpp', 'renderer/DisplayImpl.cpp', - 'renderer/driver_utils.cpp', - 'renderer/Format_table_autogen.cpp', + 'renderer/Format.cpp', + 'renderer/Format_autogen.cpp', 'renderer/gl/BlitGL.cpp', 'renderer/gl/BufferGL.cpp', 'renderer/gl/CompilerGL.cpp', @@ -216,7 +213,6 @@ UNIFIED_SOURCES += [ 'renderer/gl/TextureGL.cpp', 'renderer/gl/TransformFeedbackGL.cpp', 'renderer/gl/VertexArrayGL.cpp', - 'renderer/gl/wgl/D3DTextureSurfaceWGL.cpp', 'renderer/gl/wgl/DisplayWGL.cpp', 'renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp', 'renderer/gl/wgl/FunctionsWGL.cpp', @@ -224,25 +220,6 @@ UNIFIED_SOURCES += [ 'renderer/gl/wgl/wgl_utils.cpp', 'renderer/gl/wgl/WindowSurfaceWGL.cpp', 'renderer/load_functions_table_autogen.cpp', - 'renderer/null/BufferNULL.cpp', - 'renderer/null/CompilerNULL.cpp', - 'renderer/null/ContextNULL.cpp', - 'renderer/null/DeviceNULL.cpp', - 'renderer/null/DisplayNULL.cpp', - 'renderer/null/FenceNVNULL.cpp', - 'renderer/null/FenceSyncNULL.cpp', - 'renderer/null/FramebufferNULL.cpp', - 'renderer/null/ImageNULL.cpp', - 'renderer/null/PathNULL.cpp', - 'renderer/null/ProgramNULL.cpp', - 'renderer/null/QueryNULL.cpp', - 'renderer/null/RenderbufferNULL.cpp', - 'renderer/null/SamplerNULL.cpp', - 'renderer/null/ShaderNULL.cpp', - 'renderer/null/SurfaceNULL.cpp', - 'renderer/null/TextureNULL.cpp', - 'renderer/null/TransformFeedbackNULL.cpp', - 'renderer/null/VertexArrayNULL.cpp', 'renderer/renderer_utils.cpp', 'renderer/SurfaceImpl.cpp', 'renderer/TextureImpl.cpp', @@ -273,7 +250,6 @@ UNIFIED_SOURCES += [ 'Stream.cpp', 'Surface.cpp', 'Texture.cpp', - 'Thread.cpp', 'TransformFeedback.cpp', 'Uniform.cpp', 'validationEGL.cpp', @@ -288,8 +264,6 @@ SOURCES += [ '../compiler/translator/EmulateGLFragColorBroadcast.cpp', '../compiler/translator/glslang_lex.cpp', '../compiler/translator/glslang_tab.cpp', - '../compiler/translator/RewriteTexelFetchOffset.cpp', - '../compiler/translator/ShaderLang.cpp', 'Display.cpp', 'renderer/d3d/DisplayD3D.cpp', 'renderer/d3d/HLSLCompiler.cpp', @@ -301,7 +275,6 @@ if CONFIG['MOZ_HAS_WINSDK_WITH_D3D']: 'renderer/d3d/d3d11/Clear11.cpp', 'renderer/d3d/d3d11/Context11.cpp', 'renderer/d3d/d3d11/DebugAnnotator11.cpp', - 'renderer/d3d/d3d11/dxgi_format_map_autogen.cpp', 'renderer/d3d/d3d11/dxgi_support_table.cpp', 'renderer/d3d/d3d11/Fence11.cpp', 'renderer/d3d/d3d11/formatutils11.cpp', @@ -332,7 +305,6 @@ if CONFIG['MOZ_HAS_WINSDK_WITH_D3D']: 'renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp', ] -CXXFLAGS += CONFIG['SSE2_FLAGS'] if CONFIG['GNU_CXX']: CXXFLAGS += [ @@ -353,6 +325,9 @@ if CONFIG['GNU_CXX']: '-Wno-shadow-local', ] +if CONFIG['MOZ_DIRECTX_SDK_PATH'] and not CONFIG['MOZ_HAS_WINSDK_WITH_D3D']: + LOCAL_INCLUDES += ['%' + '%s/include/' % CONFIG['MOZ_DIRECTX_SDK_PATH']] + DEFINES['_CRT_SECURE_NO_DEPRECATE'] = True DEFINES['_HAS_EXCEPTIONS'] = 0 @@ -385,6 +360,11 @@ DEFINES['ANGLE_DEFAULT_D3D11'] = "0" if CONFIG['MOZ_HAS_WINSDK_WITH_D3D']: OS_LIBS += [ 'd3d9', 'dxguid' ] +else: + EXTRA_DSO_LDOPTS += [ + '\'%s/lib/%s/d3d9.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']), + '\'%s/lib/%s/dxguid.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']), + ] Library('libANGLE') diff --git a/gfx/angle/src/libANGLE/queryconversions.cpp b/gfx/angle/src/libANGLE/queryconversions.cpp index 611fbc4ba..83ee35f93 100755 --- a/gfx/angle/src/libANGLE/queryconversions.cpp +++ b/gfx/angle/src/libANGLE/queryconversions.cpp @@ -86,6 +86,17 @@ QueryT CastStateValue(GLenum pname, NativeT value) } // anonymous namespace +template <> +GLenum GLTypeToGLenum<GLint>::value = GL_INT; +template <> +GLenum GLTypeToGLenum<GLuint>::value = GL_UNSIGNED_INT; +template <> +GLenum GLTypeToGLenum<GLboolean>::value = GL_BOOL; +template <> +GLenum GLTypeToGLenum<GLint64>::value = GL_INT_64_ANGLEX; +template <> +GLenum GLTypeToGLenum<GLfloat>::value = GL_FLOAT; + template <typename QueryT> void CastStateValues(Context *context, GLenum nativeType, GLenum pname, unsigned int numParams, QueryT *outParams) diff --git a/gfx/angle/src/libANGLE/queryconversions.h b/gfx/angle/src/libANGLE/queryconversions.h index 5b96a3e15..7b6be3592 100755 --- a/gfx/angle/src/libANGLE/queryconversions.h +++ b/gfx/angle/src/libANGLE/queryconversions.h @@ -23,33 +23,7 @@ class Context; template <typename GLType> struct GLTypeToGLenum { - // static constexpr GLenum value; -}; - -template <> -struct GLTypeToGLenum<GLint> -{ - static constexpr GLenum value = GL_INT; -}; -template <> -struct GLTypeToGLenum<GLuint> -{ - static constexpr GLenum value = GL_UNSIGNED_INT; -}; -template <> -struct GLTypeToGLenum<GLboolean> -{ - static constexpr GLenum value = GL_BOOL; -}; -template <> -struct GLTypeToGLenum<GLint64> -{ - static constexpr GLenum value = GL_INT_64_ANGLEX; -}; -template <> -struct GLTypeToGLenum<GLfloat> -{ - static constexpr GLenum value = GL_FLOAT; + static GLenum value; }; // The GL state query API types are: bool, int, uint, float, int64 diff --git a/gfx/angle/src/libANGLE/queryutils.cpp b/gfx/angle/src/libANGLE/queryutils.cpp deleted file mode 100644 index fdd2980e2..000000000 --- a/gfx/angle/src/libANGLE/queryutils.cpp +++ /dev/null @@ -1,772 +0,0 @@ -// -// Copyright (c) 2016 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. -// - -// queryutils.cpp: Utilities for querying values from GL objects - -#include "libANGLE/queryutils.h" - -#include "common/utilities.h" - -#include "libANGLE/Buffer.h" -#include "libANGLE/Framebuffer.h" -#include "libANGLE/Program.h" -#include "libANGLE/Renderbuffer.h" -#include "libANGLE/Sampler.h" -#include "libANGLE/Shader.h" -#include "libANGLE/Texture.h" -#include "libANGLE/Uniform.h" -#include "libANGLE/VertexAttribute.h" - -namespace gl -{ - -namespace -{ -template <typename ParamType> -void QueryTexParameterBase(const Texture *texture, GLenum pname, ParamType *params) -{ - ASSERT(texture != nullptr); - - switch (pname) - { - case GL_TEXTURE_MAG_FILTER: - *params = ConvertFromGLenum<ParamType>(texture->getMagFilter()); - break; - case GL_TEXTURE_MIN_FILTER: - *params = ConvertFromGLenum<ParamType>(texture->getMinFilter()); - break; - case GL_TEXTURE_WRAP_S: - *params = ConvertFromGLenum<ParamType>(texture->getWrapS()); - break; - case GL_TEXTURE_WRAP_T: - *params = ConvertFromGLenum<ParamType>(texture->getWrapT()); - break; - case GL_TEXTURE_WRAP_R: - *params = ConvertFromGLenum<ParamType>(texture->getWrapR()); - break; - case GL_TEXTURE_IMMUTABLE_FORMAT: - *params = ConvertFromGLboolean<ParamType>(texture->getImmutableFormat()); - break; - case GL_TEXTURE_IMMUTABLE_LEVELS: - *params = ConvertFromGLuint<ParamType>(texture->getImmutableLevels()); - break; - case GL_TEXTURE_USAGE_ANGLE: - *params = ConvertFromGLenum<ParamType>(texture->getUsage()); - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - *params = ConvertFromGLfloat<ParamType>(texture->getMaxAnisotropy()); - break; - case GL_TEXTURE_SWIZZLE_R: - *params = ConvertFromGLenum<ParamType>(texture->getSwizzleRed()); - break; - case GL_TEXTURE_SWIZZLE_G: - *params = ConvertFromGLenum<ParamType>(texture->getSwizzleGreen()); - break; - case GL_TEXTURE_SWIZZLE_B: - *params = ConvertFromGLenum<ParamType>(texture->getSwizzleBlue()); - break; - case GL_TEXTURE_SWIZZLE_A: - *params = ConvertFromGLenum<ParamType>(texture->getSwizzleAlpha()); - break; - case GL_TEXTURE_BASE_LEVEL: - *params = ConvertFromGLuint<ParamType>(texture->getBaseLevel()); - break; - case GL_TEXTURE_MAX_LEVEL: - *params = ConvertFromGLuint<ParamType>(texture->getMaxLevel()); - break; - case GL_TEXTURE_MIN_LOD: - *params = ConvertFromGLfloat<ParamType>(texture->getSamplerState().minLod); - break; - case GL_TEXTURE_MAX_LOD: - *params = ConvertFromGLfloat<ParamType>(texture->getSamplerState().maxLod); - break; - case GL_TEXTURE_COMPARE_MODE: - *params = ConvertFromGLenum<ParamType>(texture->getCompareMode()); - break; - case GL_TEXTURE_COMPARE_FUNC: - *params = ConvertFromGLenum<ParamType>(texture->getCompareFunc()); - break; - case GL_TEXTURE_SRGB_DECODE_EXT: - *params = ConvertFromGLenum<ParamType>(texture->getSRGBDecode()); - break; - default: - UNREACHABLE(); - break; - } -} - -template <typename ParamType> -void SetTexParameterBase(Texture *texture, GLenum pname, const ParamType *params) -{ - ASSERT(texture != nullptr); - - switch (pname) - { - case GL_TEXTURE_WRAP_S: - texture->setWrapS(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_WRAP_T: - texture->setWrapT(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_WRAP_R: - texture->setWrapR(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_MIN_FILTER: - texture->setMinFilter(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_MAG_FILTER: - texture->setMagFilter(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_USAGE_ANGLE: - texture->setUsage(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - texture->setMaxAnisotropy(ConvertToGLfloat(params[0])); - break; - case GL_TEXTURE_COMPARE_MODE: - texture->setCompareMode(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_COMPARE_FUNC: - texture->setCompareFunc(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_SWIZZLE_R: - texture->setSwizzleRed(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_SWIZZLE_G: - texture->setSwizzleGreen(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_SWIZZLE_B: - texture->setSwizzleBlue(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_SWIZZLE_A: - texture->setSwizzleAlpha(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_BASE_LEVEL: - texture->setBaseLevel(ConvertToGLuint(params[0])); - break; - case GL_TEXTURE_MAX_LEVEL: - texture->setMaxLevel(ConvertToGLuint(params[0])); - break; - case GL_TEXTURE_MIN_LOD: - texture->setMinLod(ConvertToGLfloat(params[0])); - break; - case GL_TEXTURE_MAX_LOD: - texture->setMaxLod(ConvertToGLfloat(params[0])); - break; - case GL_TEXTURE_SRGB_DECODE_EXT: - texture->setSRGBDecode(ConvertToGLenum(params[0])); - break; - default: - UNREACHABLE(); - break; - } -} - -template <typename ParamType> -void QuerySamplerParameterBase(const Sampler *sampler, GLenum pname, ParamType *params) -{ - switch (pname) - { - case GL_TEXTURE_MIN_FILTER: - *params = ConvertFromGLenum<ParamType>(sampler->getMinFilter()); - break; - case GL_TEXTURE_MAG_FILTER: - *params = ConvertFromGLenum<ParamType>(sampler->getMagFilter()); - break; - case GL_TEXTURE_WRAP_S: - *params = ConvertFromGLenum<ParamType>(sampler->getWrapS()); - break; - case GL_TEXTURE_WRAP_T: - *params = ConvertFromGLenum<ParamType>(sampler->getWrapT()); - break; - case GL_TEXTURE_WRAP_R: - *params = ConvertFromGLenum<ParamType>(sampler->getWrapR()); - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - *params = ConvertFromGLfloat<ParamType>(sampler->getMaxAnisotropy()); - break; - case GL_TEXTURE_MIN_LOD: - *params = ConvertFromGLfloat<ParamType>(sampler->getMinLod()); - break; - case GL_TEXTURE_MAX_LOD: - *params = ConvertFromGLfloat<ParamType>(sampler->getMaxLod()); - break; - case GL_TEXTURE_COMPARE_MODE: - *params = ConvertFromGLenum<ParamType>(sampler->getCompareMode()); - break; - case GL_TEXTURE_COMPARE_FUNC: - *params = ConvertFromGLenum<ParamType>(sampler->getCompareFunc()); - break; - case GL_TEXTURE_SRGB_DECODE_EXT: - *params = ConvertFromGLenum<ParamType>(sampler->getSRGBDecode()); - break; - default: - UNREACHABLE(); - break; - } -} - -template <typename ParamType> -void SetSamplerParameterBase(Sampler *sampler, GLenum pname, const ParamType *params) -{ - switch (pname) - { - case GL_TEXTURE_WRAP_S: - sampler->setWrapS(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_WRAP_T: - sampler->setWrapT(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_WRAP_R: - sampler->setWrapR(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_MIN_FILTER: - sampler->setMinFilter(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_MAG_FILTER: - sampler->setMagFilter(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - sampler->setMaxAnisotropy(ConvertToGLfloat(params[0])); - break; - case GL_TEXTURE_COMPARE_MODE: - sampler->setCompareMode(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_COMPARE_FUNC: - sampler->setCompareFunc(ConvertToGLenum(params[0])); - break; - case GL_TEXTURE_MIN_LOD: - sampler->setMinLod(ConvertToGLfloat(params[0])); - break; - case GL_TEXTURE_MAX_LOD: - sampler->setMaxLod(ConvertToGLfloat(params[0])); - break; - case GL_TEXTURE_SRGB_DECODE_EXT: - sampler->setSRGBDecode(ConvertToGLenum(params[0])); - break; - default: - UNREACHABLE(); - break; - } -} - -template <typename ParamType, typename CurrentDataType> -ParamType ConvertCurrentValue(CurrentDataType currentValue) -{ - return static_cast<ParamType>(currentValue); -} - -template <> -GLint ConvertCurrentValue(GLfloat currentValue) -{ - return iround<GLint>(currentValue); -} - -template <typename ParamType, typename CurrentDataType, size_t CurrentValueCount> -void QueryVertexAttribBase(const VertexAttribute &attrib, - const CurrentDataType (¤tValueData)[CurrentValueCount], - GLenum pname, - ParamType *params) -{ - switch (pname) - { - case GL_CURRENT_VERTEX_ATTRIB: - for (size_t i = 0; i < CurrentValueCount; ++i) - { - params[i] = ConvertCurrentValue<ParamType>(currentValueData[i]); - } - break; - case GL_VERTEX_ATTRIB_ARRAY_ENABLED: - *params = ConvertFromGLboolean<ParamType>(attrib.enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY_SIZE: - *params = ConvertFromGLuint<ParamType>(attrib.size); - break; - case GL_VERTEX_ATTRIB_ARRAY_STRIDE: - *params = ConvertFromGLuint<ParamType>(attrib.stride); - break; - case GL_VERTEX_ATTRIB_ARRAY_TYPE: - *params = ConvertFromGLenum<ParamType>(attrib.type); - break; - case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: - *params = ConvertFromGLboolean<ParamType>(attrib.normalized); - break; - case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: - *params = ConvertFromGLuint<ParamType>(attrib.buffer.id()); - break; - case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: - *params = ConvertFromGLuint<ParamType>(attrib.divisor); - break; - case GL_VERTEX_ATTRIB_ARRAY_INTEGER: - *params = ConvertFromGLboolean<ParamType>(attrib.pureInteger); - break; - default: - UNREACHABLE(); - break; - } -} - -template <typename ParamType> -void QueryBufferParameterBase(const Buffer *buffer, GLenum pname, ParamType *params) -{ - ASSERT(buffer != nullptr); - - switch (pname) - { - case GL_BUFFER_USAGE: - *params = ConvertFromGLenum<ParamType>(buffer->getUsage()); - break; - case GL_BUFFER_SIZE: - *params = ConvertFromGLint64<ParamType>(buffer->getSize()); - break; - case GL_BUFFER_ACCESS_FLAGS: - *params = ConvertFromGLuint<ParamType>(buffer->getAccessFlags()); - break; - case GL_BUFFER_ACCESS_OES: - *params = ConvertFromGLenum<ParamType>(buffer->getAccess()); - break; - case GL_BUFFER_MAPPED: - *params = ConvertFromGLboolean<ParamType>(buffer->isMapped()); - break; - case GL_BUFFER_MAP_OFFSET: - *params = ConvertFromGLint64<ParamType>(buffer->getMapOffset()); - break; - case GL_BUFFER_MAP_LENGTH: - *params = ConvertFromGLint64<ParamType>(buffer->getMapLength()); - break; - default: - UNREACHABLE(); - break; - } -} - -} // anonymous namespace - -void QueryFramebufferAttachmentParameteriv(const Framebuffer *framebuffer, - GLenum attachment, - GLenum pname, - GLint *params) -{ - ASSERT(framebuffer); - - const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment); - if (attachmentObject == nullptr) - { - // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE - // is NONE, then querying any other pname will generate INVALID_ENUM. - - // ES 3.0.2 spec pg 235 states that if the attachment type is none, - // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an - // INVALID_OPERATION for all other pnames - - switch (pname) - { - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: - *params = GL_NONE; - break; - - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: - *params = 0; - break; - - default: - UNREACHABLE(); - break; - } - - return; - } - - switch (pname) - { - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: - *params = attachmentObject->type(); - break; - - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: - *params = attachmentObject->id(); - break; - - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: - *params = attachmentObject->mipLevel(); - break; - - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: - *params = attachmentObject->cubeMapFace(); - break; - - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - *params = attachmentObject->getRedSize(); - break; - - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - *params = attachmentObject->getGreenSize(); - break; - - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - *params = attachmentObject->getBlueSize(); - break; - - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - *params = attachmentObject->getAlphaSize(); - break; - - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - *params = attachmentObject->getDepthSize(); - break; - - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - *params = attachmentObject->getStencilSize(); - break; - - case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: - *params = attachmentObject->getComponentType(); - break; - - case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: - *params = attachmentObject->getColorEncoding(); - break; - - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: - *params = attachmentObject->layer(); - break; - - default: - UNREACHABLE(); - break; - } -} - -void QueryBufferParameteriv(const Buffer *buffer, GLenum pname, GLint *params) -{ - QueryBufferParameterBase(buffer, pname, params); -} - -void QueryBufferParameteri64v(const Buffer *buffer, GLenum pname, GLint64 *params) -{ - QueryBufferParameterBase(buffer, pname, params); -} - -void QueryBufferPointerv(const Buffer *buffer, GLenum pname, void **params) -{ - switch (pname) - { - case GL_BUFFER_MAP_POINTER: - *params = buffer->getMapPointer(); - break; - - default: - UNREACHABLE(); - break; - } -} - -void QueryProgramiv(const Program *program, GLenum pname, GLint *params) -{ - ASSERT(program != nullptr); - - switch (pname) - { - case GL_DELETE_STATUS: - *params = program->isFlaggedForDeletion(); - return; - case GL_LINK_STATUS: - *params = program->isLinked(); - return; - case GL_VALIDATE_STATUS: - *params = program->isValidated(); - return; - case GL_INFO_LOG_LENGTH: - *params = program->getInfoLogLength(); - return; - case GL_ATTACHED_SHADERS: - *params = program->getAttachedShadersCount(); - return; - case GL_ACTIVE_ATTRIBUTES: - *params = program->getActiveAttributeCount(); - return; - case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: - *params = program->getActiveAttributeMaxLength(); - return; - case GL_ACTIVE_UNIFORMS: - *params = program->getActiveUniformCount(); - return; - case GL_ACTIVE_UNIFORM_MAX_LENGTH: - *params = program->getActiveUniformMaxLength(); - return; - case GL_PROGRAM_BINARY_LENGTH_OES: - *params = program->getBinaryLength(); - return; - case GL_ACTIVE_UNIFORM_BLOCKS: - *params = program->getActiveUniformBlockCount(); - return; - case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: - *params = program->getActiveUniformBlockMaxLength(); - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: - *params = program->getTransformFeedbackBufferMode(); - break; - case GL_TRANSFORM_FEEDBACK_VARYINGS: - *params = program->getTransformFeedbackVaryingCount(); - break; - case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: - *params = program->getTransformFeedbackVaryingMaxLength(); - break; - case GL_PROGRAM_BINARY_RETRIEVABLE_HINT: - *params = program->getBinaryRetrievableHint(); - break; - default: - UNREACHABLE(); - break; - } -} - -void QueryRenderbufferiv(const Renderbuffer *renderbuffer, GLenum pname, GLint *params) -{ - ASSERT(renderbuffer != nullptr); - - switch (pname) - { - case GL_RENDERBUFFER_WIDTH: - *params = renderbuffer->getWidth(); - break; - case GL_RENDERBUFFER_HEIGHT: - *params = renderbuffer->getHeight(); - break; - case GL_RENDERBUFFER_INTERNAL_FORMAT: - *params = renderbuffer->getFormat().info->internalFormat; - break; - case GL_RENDERBUFFER_RED_SIZE: - *params = renderbuffer->getRedSize(); - break; - case GL_RENDERBUFFER_GREEN_SIZE: - *params = renderbuffer->getGreenSize(); - break; - case GL_RENDERBUFFER_BLUE_SIZE: - *params = renderbuffer->getBlueSize(); - break; - case GL_RENDERBUFFER_ALPHA_SIZE: - *params = renderbuffer->getAlphaSize(); - break; - case GL_RENDERBUFFER_DEPTH_SIZE: - *params = renderbuffer->getDepthSize(); - break; - case GL_RENDERBUFFER_STENCIL_SIZE: - *params = renderbuffer->getStencilSize(); - break; - case GL_RENDERBUFFER_SAMPLES_ANGLE: - *params = renderbuffer->getSamples(); - break; - default: - UNREACHABLE(); - break; - } -} - -void QueryShaderiv(const Shader *shader, GLenum pname, GLint *params) -{ - ASSERT(shader != nullptr); - - switch (pname) - { - case GL_SHADER_TYPE: - *params = shader->getType(); - return; - case GL_DELETE_STATUS: - *params = shader->isFlaggedForDeletion(); - return; - case GL_COMPILE_STATUS: - *params = shader->isCompiled() ? GL_TRUE : GL_FALSE; - return; - case GL_INFO_LOG_LENGTH: - *params = shader->getInfoLogLength(); - return; - case GL_SHADER_SOURCE_LENGTH: - *params = shader->getSourceLength(); - return; - case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: - *params = shader->getTranslatedSourceWithDebugInfoLength(); - return; - default: - UNREACHABLE(); - break; - } -} - -void QueryTexParameterfv(const Texture *texture, GLenum pname, GLfloat *params) -{ - QueryTexParameterBase(texture, pname, params); -} - -void QueryTexParameteriv(const Texture *texture, GLenum pname, GLint *params) -{ - QueryTexParameterBase(texture, pname, params); -} - -void QuerySamplerParameterfv(const Sampler *sampler, GLenum pname, GLfloat *params) -{ - QuerySamplerParameterBase(sampler, pname, params); -} - -void QuerySamplerParameteriv(const Sampler *sampler, GLenum pname, GLint *params) -{ - QuerySamplerParameterBase(sampler, pname, params); -} - -void QueryVertexAttribfv(const VertexAttribute &attrib, - const VertexAttribCurrentValueData ¤tValueData, - GLenum pname, - GLfloat *params) -{ - QueryVertexAttribBase(attrib, currentValueData.FloatValues, pname, params); -} - -void QueryVertexAttribiv(const VertexAttribute &attrib, - const VertexAttribCurrentValueData ¤tValueData, - GLenum pname, - GLint *params) -{ - QueryVertexAttribBase(attrib, currentValueData.FloatValues, pname, params); -} - -void QueryVertexAttribPointerv(const VertexAttribute &attrib, GLenum pname, GLvoid **pointer) -{ - switch (pname) - { - case GL_VERTEX_ATTRIB_ARRAY_POINTER: - *pointer = const_cast<GLvoid *>(attrib.pointer); - break; - - default: - UNREACHABLE(); - break; - } -} - -void QueryVertexAttribIiv(const VertexAttribute &attrib, - const VertexAttribCurrentValueData ¤tValueData, - GLenum pname, - GLint *params) -{ - QueryVertexAttribBase(attrib, currentValueData.IntValues, pname, params); -} - -void QueryVertexAttribIuiv(const VertexAttribute &attrib, - const VertexAttribCurrentValueData ¤tValueData, - GLenum pname, - GLuint *params) -{ - QueryVertexAttribBase(attrib, currentValueData.UnsignedIntValues, pname, params); -} - -void QueryActiveUniformBlockiv(const Program *program, - GLuint uniformBlockIndex, - GLenum pname, - GLint *params) -{ - const UniformBlock &uniformBlock = program->getUniformBlockByIndex(uniformBlockIndex); - switch (pname) - { - case GL_UNIFORM_BLOCK_BINDING: - *params = ConvertToGLint(program->getUniformBlockBinding(uniformBlockIndex)); - break; - case GL_UNIFORM_BLOCK_DATA_SIZE: - *params = ConvertToGLint(uniformBlock.dataSize); - break; - case GL_UNIFORM_BLOCK_NAME_LENGTH: - *params = ConvertToGLint(uniformBlock.nameWithArrayIndex().size() + 1); - break; - case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: - *params = ConvertToGLint(uniformBlock.memberUniformIndexes.size()); - break; - case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: - for (size_t blockMemberIndex = 0; - blockMemberIndex < uniformBlock.memberUniformIndexes.size(); blockMemberIndex++) - { - params[blockMemberIndex] = - ConvertToGLint(uniformBlock.memberUniformIndexes[blockMemberIndex]); - } - break; - case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: - *params = ConvertToGLint(uniformBlock.vertexStaticUse); - break; - case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: - *params = ConvertToGLint(uniformBlock.fragmentStaticUse); - break; - default: - UNREACHABLE(); - break; - } -} - -void QueryInternalFormativ(const TextureCaps &format, GLenum pname, GLsizei bufSize, GLint *params) -{ - switch (pname) - { - case GL_NUM_SAMPLE_COUNTS: - if (bufSize != 0) - { - *params = static_cast<GLint>(format.sampleCounts.size()); - } - break; - - case GL_SAMPLES: - { - size_t returnCount = std::min<size_t>(bufSize, format.sampleCounts.size()); - auto sampleReverseIt = format.sampleCounts.rbegin(); - for (size_t sampleIndex = 0; sampleIndex < returnCount; ++sampleIndex) - { - params[sampleIndex] = *sampleReverseIt++; - } - } - break; - - default: - UNREACHABLE(); - break; - } -} - -void SetTexParameterf(Texture *texture, GLenum pname, GLfloat param) -{ - SetTexParameterBase(texture, pname, ¶m); -} - -void SetTexParameterfv(Texture *texture, GLenum pname, const GLfloat *params) -{ - SetTexParameterBase(texture, pname, params); -} - -void SetTexParameteri(Texture *texture, GLenum pname, GLint param) -{ - SetTexParameterBase(texture, pname, ¶m); -} - -void SetTexParameteriv(Texture *texture, GLenum pname, const GLint *params) -{ - SetTexParameterBase(texture, pname, params); -} - -void SetSamplerParameterf(Sampler *sampler, GLenum pname, GLfloat param) -{ - SetSamplerParameterBase(sampler, pname, ¶m); -} - -void SetSamplerParameterfv(Sampler *sampler, GLenum pname, const GLfloat *params) -{ - SetSamplerParameterBase(sampler, pname, params); -} - -void SetSamplerParameteri(Sampler *sampler, GLenum pname, GLint param) -{ - SetSamplerParameterBase(sampler, pname, ¶m); -} - -void SetSamplerParameteriv(Sampler *sampler, GLenum pname, const GLint *params) -{ - SetSamplerParameterBase(sampler, pname, params); -} -} diff --git a/gfx/angle/src/libANGLE/queryutils.h b/gfx/angle/src/libANGLE/queryutils.h deleted file mode 100644 index 28a84b3bd..000000000 --- a/gfx/angle/src/libANGLE/queryutils.h +++ /dev/null @@ -1,79 +0,0 @@ -// -// Copyright (c) 2016 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. -// - -// queryutils.h: Utilities for querying values from GL objects - -#ifndef LIBANGLE_QUERYUTILS_H_ -#define LIBANGLE_QUERYUTILS_H_ - -#include "angle_gl.h" -#include "common/angleutils.h" - -namespace gl -{ -class Buffer; -class Framebuffer; -class Program; -class Renderbuffer; -class Sampler; -class Shader; -class Texture; -struct TextureCaps; -struct UniformBlock; -struct VertexAttribute; -struct VertexAttribCurrentValueData; - -void QueryFramebufferAttachmentParameteriv(const Framebuffer *framebuffer, - GLenum attachment, - GLenum pname, - GLint *params); -void QueryBufferParameteriv(const Buffer *buffer, GLenum pname, GLint *params); -void QueryBufferParameteri64v(const Buffer *buffer, GLenum pname, GLint64 *params); -void QueryBufferPointerv(const Buffer *buffer, GLenum pname, void **params); -void QueryProgramiv(const Program *program, GLenum pname, GLint *params); -void QueryRenderbufferiv(const Renderbuffer *renderbuffer, GLenum pname, GLint *params); -void QueryShaderiv(const Shader *shader, GLenum pname, GLint *params); -void QueryTexParameterfv(const Texture *texture, GLenum pname, GLfloat *params); -void QueryTexParameteriv(const Texture *texture, GLenum pname, GLint *params); -void QuerySamplerParameterfv(const Sampler *sampler, GLenum pname, GLfloat *params); -void QuerySamplerParameteriv(const Sampler *sampler, GLenum pname, GLint *params); -void QueryVertexAttribfv(const VertexAttribute &attrib, - const VertexAttribCurrentValueData ¤tValueData, - GLenum pname, - GLfloat *params); -void QueryVertexAttribiv(const VertexAttribute &attrib, - const VertexAttribCurrentValueData ¤tValueData, - GLenum pname, - GLint *params); -void QueryVertexAttribPointerv(const VertexAttribute &attrib, GLenum pname, GLvoid **pointer); -void QueryVertexAttribIiv(const VertexAttribute &attrib, - const VertexAttribCurrentValueData ¤tValueData, - GLenum pname, - GLint *params); -void QueryVertexAttribIuiv(const VertexAttribute &attrib, - const VertexAttribCurrentValueData ¤tValueData, - GLenum pname, - GLuint *params); - -void QueryActiveUniformBlockiv(const Program *program, - GLuint uniformBlockIndex, - GLenum pname, - GLint *params); - -void QueryInternalFormativ(const TextureCaps &format, GLenum pname, GLsizei bufSize, GLint *params); - -void SetTexParameterf(Texture *texture, GLenum pname, GLfloat param); -void SetTexParameterfv(Texture *texture, GLenum pname, const GLfloat *params); -void SetTexParameteri(Texture *texture, GLenum pname, GLint param); -void SetTexParameteriv(Texture *texture, GLenum pname, const GLint *params); - -void SetSamplerParameterf(Sampler *sampler, GLenum pname, GLfloat param); -void SetSamplerParameterfv(Sampler *sampler, GLenum pname, const GLfloat *params); -void SetSamplerParameteri(Sampler *sampler, GLenum pname, GLint param); -void SetSamplerParameteriv(Sampler *sampler, GLenum pname, const GLint *params); -} - -#endif // LIBANGLE_QUERYUTILS_H_ diff --git a/gfx/angle/src/libANGLE/renderer/BufferImpl.h b/gfx/angle/src/libANGLE/renderer/BufferImpl.h index 10d371541..cdb3cfe88 100755 --- a/gfx/angle/src/libANGLE/renderer/BufferImpl.h +++ b/gfx/angle/src/libANGLE/renderer/BufferImpl.h @@ -15,22 +15,16 @@ #include <stdint.h> -namespace gl -{ -class BufferState; -} - namespace rx { class BufferImpl : angle::NonCopyable { public: - BufferImpl(const gl::BufferState &state) : mState(state) {} virtual ~BufferImpl() { } - virtual gl::Error setData(GLenum target, const void *data, size_t size, GLenum usage) = 0; - virtual gl::Error setSubData(GLenum target, const void *data, size_t size, size_t offset) = 0; + virtual gl::Error setData(const void *data, size_t size, GLenum usage) = 0; + virtual gl::Error setSubData(const void *data, size_t size, size_t offset) = 0; virtual gl::Error copySubData(BufferImpl *source, GLintptr sourceOffset, GLintptr destOffset, @@ -44,9 +38,6 @@ class BufferImpl : angle::NonCopyable size_t count, bool primitiveRestartEnabled, gl::IndexRange *outRange) = 0; - - protected: - const gl::BufferState &mState; }; } diff --git a/gfx/angle/src/libANGLE/renderer/BufferImpl_mock.h b/gfx/angle/src/libANGLE/renderer/BufferImpl_mock.h index 7e45c01b7..a6387661c 100755 --- a/gfx/angle/src/libANGLE/renderer/BufferImpl_mock.h +++ b/gfx/angle/src/libANGLE/renderer/BufferImpl_mock.h @@ -19,11 +19,10 @@ namespace rx class MockBufferImpl : public BufferImpl { public: - MockBufferImpl() : BufferImpl(mMockState) {} ~MockBufferImpl() { destructor(); } - MOCK_METHOD4(setData, gl::Error(GLenum, const void *, size_t, GLenum)); - MOCK_METHOD4(setSubData, gl::Error(GLenum, const void *, size_t, size_t)); + MOCK_METHOD3(setData, gl::Error(const void*, size_t, GLenum)); + MOCK_METHOD3(setSubData, gl::Error(const void*, size_t, size_t)); MOCK_METHOD4(copySubData, gl::Error(BufferImpl *, GLintptr, GLintptr, GLsizeiptr)); MOCK_METHOD2(map, gl::Error(GLenum, GLvoid **)); MOCK_METHOD4(mapRange, gl::Error(size_t, size_t, GLbitfield, GLvoid **)); @@ -32,9 +31,6 @@ class MockBufferImpl : public BufferImpl MOCK_METHOD5(getIndexRange, gl::Error(GLenum, size_t, size_t, bool, gl::IndexRange *)); MOCK_METHOD0(destructor, void()); - - protected: - gl::BufferState mMockState; }; } diff --git a/gfx/angle/src/libANGLE/renderer/DisplayImpl.cpp b/gfx/angle/src/libANGLE/renderer/DisplayImpl.cpp index fc2f2c5ce..8061189f0 100755 --- a/gfx/angle/src/libANGLE/renderer/DisplayImpl.cpp +++ b/gfx/angle/src/libANGLE/renderer/DisplayImpl.cpp @@ -41,15 +41,6 @@ const egl::DisplayExtensions &DisplayImpl::getExtensions() const return mExtensions; } -egl::Error DisplayImpl::validateClientBuffer(const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, - const egl::AttributeMap &attribs) const -{ - UNREACHABLE(); - return egl::Error(EGL_BAD_DISPLAY, "DisplayImpl::validateClientBuffer unimplemented."); -} - const egl::Caps &DisplayImpl::getCaps() const { if (!mCapsInitialized) diff --git a/gfx/angle/src/libANGLE/renderer/DisplayImpl.h b/gfx/angle/src/libANGLE/renderer/DisplayImpl.h index ec603e85b..652486edb 100755 --- a/gfx/angle/src/libANGLE/renderer/DisplayImpl.h +++ b/gfx/angle/src/libANGLE/renderer/DisplayImpl.h @@ -59,10 +59,6 @@ class DisplayImpl : public EGLImplFactory virtual egl::Error restoreLostDevice() = 0; virtual bool isValidNativeWindow(EGLNativeWindowType window) const = 0; - virtual egl::Error validateClientBuffer(const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, - const egl::AttributeMap &attribs) const; virtual std::string getVendorString() const = 0; diff --git a/gfx/angle/src/libANGLE/renderer/EGLImplFactory.h b/gfx/angle/src/libANGLE/renderer/EGLImplFactory.h index 2ddbb7625..b2c8771cc 100755 --- a/gfx/angle/src/libANGLE/renderer/EGLImplFactory.h +++ b/gfx/angle/src/libANGLE/renderer/EGLImplFactory.h @@ -47,8 +47,7 @@ class EGLImplFactory : angle::NonCopyable const egl::AttributeMap &attribs) = 0; virtual SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) = 0; virtual SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state, const egl::Config *configuration, diff --git a/gfx/angle/src/libANGLE/renderer/Format.cpp b/gfx/angle/src/libANGLE/renderer/Format.cpp new file mode 100644 index 000000000..e8883c6f3 --- /dev/null +++ b/gfx/angle/src/libANGLE/renderer/Format.cpp @@ -0,0 +1,60 @@ +// +// Copyright 2016 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. +// +// Format: +// A universal description of texture storage. Across multiple +// renderer back-ends, there are common formats and some distinct +// permutations, this enum encapsulates them all. + +#include "libANGLE/renderer/Format.h" + +#include "image_util/copyimage.h" + +using namespace rx; + +namespace angle +{ + +namespace +{ + +const FastCopyFunctionMap &GetFastCopyFunctionsMap(Format::ID formatID) +{ + switch (formatID) + { + case Format::ID::B8G8R8A8_UNORM: + { + static FastCopyFunctionMap fastCopyMap; + if (fastCopyMap.empty()) + { + fastCopyMap[gl::FormatType(GL_RGBA, GL_UNSIGNED_BYTE)] = CopyBGRA8ToRGBA8; + } + return fastCopyMap; + } + default: + { + static FastCopyFunctionMap emptyMap; + return emptyMap; + } + } +} + +} // anonymous namespace + +Format::Format(ID id, + GLenum glFormat, + GLenum fboFormat, + MipGenerationFunction mipGen, + ColorReadFunction colorRead) + : id(id), + glInternalFormat(glFormat), + fboImplementationInternalFormat(fboFormat), + mipGenerationFunction(mipGen), + colorReadFunction(colorRead), + fastCopyFunctions(GetFastCopyFunctionsMap(id)) +{ +} + +} // namespace angle diff --git a/gfx/angle/src/libANGLE/renderer/Format.h b/gfx/angle/src/libANGLE/renderer/Format.h index 5c6e7e1fe..65608a7a6 100755 --- a/gfx/angle/src/libANGLE/renderer/Format.h +++ b/gfx/angle/src/libANGLE/renderer/Format.h @@ -22,19 +22,11 @@ struct Format final : angle::NonCopyable { enum class ID; - constexpr Format(ID id, - GLenum glFormat, - GLenum fboFormat, - rx::MipGenerationFunction mipGen, - const rx::FastCopyFunctionMap &fastCopyFunctions, - rx::ColorReadFunction colorRead, - GLenum componentType, - GLuint redBits, - GLuint greenBits, - GLuint blueBits, - GLuint alphaBits, - GLuint depthBits, - GLuint stencilBits); + Format(ID id, + GLenum glFormat, + GLenum fboFormat, + rx::MipGenerationFunction mipGen, + rx::ColorReadFunction colorRead); static const Format &Get(ID id); @@ -53,47 +45,9 @@ struct Format final : angle::NonCopyable rx::ColorReadFunction colorReadFunction; // A map from a gl::FormatType to a fast pixel copy function for this format. - const rx::FastCopyFunctionMap &fastCopyFunctions; - - GLenum componentType; - - GLuint redBits; - GLuint greenBits; - GLuint blueBits; - GLuint alphaBits; - GLuint depthBits; - GLuint stencilBits; + rx::FastCopyFunctionMap fastCopyFunctions; }; -constexpr Format::Format(ID id, - GLenum glFormat, - GLenum fboFormat, - rx::MipGenerationFunction mipGen, - const rx::FastCopyFunctionMap &fastCopyFunctions, - rx::ColorReadFunction colorRead, - GLenum componentType, - GLuint redBits, - GLuint greenBits, - GLuint blueBits, - GLuint alphaBits, - GLuint depthBits, - GLuint stencilBits) - : id(id), - glInternalFormat(glFormat), - fboImplementationInternalFormat(fboFormat), - mipGenerationFunction(mipGen), - colorReadFunction(colorRead), - fastCopyFunctions(fastCopyFunctions), - componentType(componentType), - redBits(redBits), - greenBits(greenBits), - blueBits(blueBits), - alphaBits(alphaBits), - depthBits(depthBits), - stencilBits(stencilBits) -{ -} - } // namespace angle #include "libANGLE/renderer/Format_ID_autogen.inl" diff --git a/gfx/angle/src/libANGLE/renderer/Format_autogen.cpp b/gfx/angle/src/libANGLE/renderer/Format_autogen.cpp new file mode 100644 index 000000000..d6b6762e7 --- /dev/null +++ b/gfx/angle/src/libANGLE/renderer/Format_autogen.cpp @@ -0,0 +1,1126 @@ +// GENERATED FILE - DO NOT EDIT. +// Generated by gen_angle_format_table.py using data from angle_format_data.json +// +// Copyright 2016 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. +// +// ANGLE Format table: +// Queries for typed format information from the ANGLE format enum. + +#include "libANGLE/renderer/Format.h" + +#include "image_util/copyimage.h" +#include "image_util/generatemip.h" +#include "image_util/loadimage.h" + +namespace angle +{ + +// static +const Format &Format::Get(ID id) +{ + // clang-format off + switch (id) + { + case ID::A16_FLOAT: + { + static const Format info(ID::A16_FLOAT, + GL_ALPHA16F_EXT, + GL_ALPHA16F_EXT, + GenerateMip<A16F>, + ReadColor<A16F, GLfloat>); + return info; + } + case ID::A32_FLOAT: + { + static const Format info(ID::A32_FLOAT, + GL_ALPHA32F_EXT, + GL_ALPHA32F_EXT, + GenerateMip<A32F>, + ReadColor<A32F, GLfloat>); + return info; + } + case ID::A8_UNORM: + { + static const Format info(ID::A8_UNORM, + GL_ALPHA8_EXT, + GL_ALPHA8_EXT, + GenerateMip<A8>, + ReadColor<A8, GLfloat>); + return info; + } + case ID::ASTC_10x10_SRGB_BLOCK: + { + static const Format info(ID::ASTC_10x10_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_10x10_UNORM_BLOCK: + { + static const Format info(ID::ASTC_10x10_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_10x10_KHR, + GL_COMPRESSED_RGBA_ASTC_10x10_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_10x5_SRGB_BLOCK: + { + static const Format info(ID::ASTC_10x5_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_10x5_UNORM_BLOCK: + { + static const Format info(ID::ASTC_10x5_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_10x5_KHR, + GL_COMPRESSED_RGBA_ASTC_10x5_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_10x6_SRGB_BLOCK: + { + static const Format info(ID::ASTC_10x6_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_10x6_UNORM_BLOCK: + { + static const Format info(ID::ASTC_10x6_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_10x6_KHR, + GL_COMPRESSED_RGBA_ASTC_10x6_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_10x8_SRGB_BLOCK: + { + static const Format info(ID::ASTC_10x8_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_10x8_UNORM_BLOCK: + { + static const Format info(ID::ASTC_10x8_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_10x8_KHR, + GL_COMPRESSED_RGBA_ASTC_10x8_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_12x10_SRGB_BLOCK: + { + static const Format info(ID::ASTC_12x10_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_12x10_UNORM_BLOCK: + { + static const Format info(ID::ASTC_12x10_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_12x10_KHR, + GL_COMPRESSED_RGBA_ASTC_12x10_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_12x12_SRGB_BLOCK: + { + static const Format info(ID::ASTC_12x12_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_12x12_UNORM_BLOCK: + { + static const Format info(ID::ASTC_12x12_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_12x12_KHR, + GL_COMPRESSED_RGBA_ASTC_12x12_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_4x4_SRGB_BLOCK: + { + static const Format info(ID::ASTC_4x4_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_4x4_UNORM_BLOCK: + { + static const Format info(ID::ASTC_4x4_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_4x4_KHR, + GL_COMPRESSED_RGBA_ASTC_4x4_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_5x4_SRGB_BLOCK: + { + static const Format info(ID::ASTC_5x4_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_5x4_UNORM_BLOCK: + { + static const Format info(ID::ASTC_5x4_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_5x4_KHR, + GL_COMPRESSED_RGBA_ASTC_5x4_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_5x5_SRGB_BLOCK: + { + static const Format info(ID::ASTC_5x5_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_5x5_UNORM_BLOCK: + { + static const Format info(ID::ASTC_5x5_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_5x5_KHR, + GL_COMPRESSED_RGBA_ASTC_5x5_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_6x5_SRGB_BLOCK: + { + static const Format info(ID::ASTC_6x5_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_6x5_UNORM_BLOCK: + { + static const Format info(ID::ASTC_6x5_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_6x5_KHR, + GL_COMPRESSED_RGBA_ASTC_6x5_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_6x6_SRGB_BLOCK: + { + static const Format info(ID::ASTC_6x6_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_6x6_UNORM_BLOCK: + { + static const Format info(ID::ASTC_6x6_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_6x6_KHR, + GL_COMPRESSED_RGBA_ASTC_6x6_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_8x5_SRGB_BLOCK: + { + static const Format info(ID::ASTC_8x5_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_8x5_UNORM_BLOCK: + { + static const Format info(ID::ASTC_8x5_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_8x5_KHR, + GL_COMPRESSED_RGBA_ASTC_8x5_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_8x6_SRGB_BLOCK: + { + static const Format info(ID::ASTC_8x6_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_8x6_UNORM_BLOCK: + { + static const Format info(ID::ASTC_8x6_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_8x6_KHR, + GL_COMPRESSED_RGBA_ASTC_8x6_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_8x8_SRGB_BLOCK: + { + static const Format info(ID::ASTC_8x8_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, + GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, + nullptr, + nullptr); + return info; + } + case ID::ASTC_8x8_UNORM_BLOCK: + { + static const Format info(ID::ASTC_8x8_UNORM_BLOCK, + GL_COMPRESSED_RGBA_ASTC_8x8_KHR, + GL_COMPRESSED_RGBA_ASTC_8x8_KHR, + nullptr, + nullptr); + return info; + } + case ID::B4G4R4A4_UNORM: + { + static const Format info(ID::B4G4R4A4_UNORM, + GL_BGRA4_ANGLEX, + GL_RGBA4, + GenerateMip<A4R4G4B4>, + ReadColor<A4R4G4B4, GLfloat>); + return info; + } + case ID::B5G5R5A1_UNORM: + { + static const Format info(ID::B5G5R5A1_UNORM, + GL_BGR5_A1_ANGLEX, + GL_RGB5_A1, + GenerateMip<A1R5G5B5>, + ReadColor<A1R5G5B5, GLfloat>); + return info; + } + case ID::B5G6R5_UNORM: + { + static const Format info(ID::B5G6R5_UNORM, + GL_BGR565_ANGLEX, + GL_RGB565, + GenerateMip<B5G6R5>, + ReadColor<B5G6R5, GLfloat>); + return info; + } + case ID::B8G8R8A8_UNORM: + { + static const Format info(ID::B8G8R8A8_UNORM, + GL_BGRA8_EXT, + GL_BGRA8_EXT, + GenerateMip<B8G8R8A8>, + ReadColor<B8G8R8A8, GLfloat>); + return info; + } + case ID::B8G8R8X8_UNORM: + { + static const Format info(ID::B8G8R8X8_UNORM, + GL_BGRA8_EXT, + GL_BGRA8_EXT, + GenerateMip<B8G8R8X8>, + ReadColor<B8G8R8X8, GLfloat>); + return info; + } + case ID::BC1_RGBA_UNORM_BLOCK: + { + static const Format info(ID::BC1_RGBA_UNORM_BLOCK, + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + nullptr, + nullptr); + return info; + } + case ID::BC1_RGB_UNORM_BLOCK: + { + static const Format info(ID::BC1_RGB_UNORM_BLOCK, + GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + nullptr, + nullptr); + return info; + } + case ID::BC2_RGBA_UNORM_BLOCK: + { + static const Format info(ID::BC2_RGBA_UNORM_BLOCK, + GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, + GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, + nullptr, + nullptr); + return info; + } + case ID::BC3_RGBA_UNORM_BLOCK: + { + static const Format info(ID::BC3_RGBA_UNORM_BLOCK, + GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, + GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, + nullptr, + nullptr); + return info; + } + case ID::D16_UNORM: + { + static const Format info(ID::D16_UNORM, + GL_DEPTH_COMPONENT16, + GL_DEPTH_COMPONENT16, + nullptr, + nullptr); + return info; + } + case ID::D24_UNORM: + { + static const Format info(ID::D24_UNORM, + GL_DEPTH_COMPONENT24, + GL_DEPTH_COMPONENT24, + nullptr, + nullptr); + return info; + } + case ID::D24_UNORM_S8_UINT: + { + static const Format info(ID::D24_UNORM_S8_UINT, + GL_DEPTH24_STENCIL8, + GL_DEPTH24_STENCIL8, + nullptr, + nullptr); + return info; + } + case ID::D32_FLOAT: + { + static const Format info(ID::D32_FLOAT, + GL_DEPTH_COMPONENT32F, + GL_DEPTH_COMPONENT32F, + nullptr, + nullptr); + return info; + } + case ID::D32_FLOAT_S8X24_UINT: + { + static const Format info(ID::D32_FLOAT_S8X24_UINT, + GL_DEPTH32F_STENCIL8, + GL_DEPTH32F_STENCIL8, + nullptr, + nullptr); + return info; + } + case ID::D32_UNORM: + { + static const Format info(ID::D32_UNORM, + GL_DEPTH_COMPONENT32_OES, + GL_DEPTH_COMPONENT32_OES, + nullptr, + nullptr); + return info; + } + case ID::EAC_R11G11_SNORM_BLOCK: + { + static const Format info(ID::EAC_R11G11_SNORM_BLOCK, + GL_COMPRESSED_SIGNED_RG11_EAC, + GL_COMPRESSED_SIGNED_RG11_EAC, + nullptr, + nullptr); + return info; + } + case ID::EAC_R11G11_UNORM_BLOCK: + { + static const Format info(ID::EAC_R11G11_UNORM_BLOCK, + GL_COMPRESSED_RG11_EAC, + GL_COMPRESSED_RG11_EAC, + nullptr, + nullptr); + return info; + } + case ID::EAC_R11_SNORM_BLOCK: + { + static const Format info(ID::EAC_R11_SNORM_BLOCK, + GL_COMPRESSED_SIGNED_R11_EAC, + GL_COMPRESSED_SIGNED_R11_EAC, + nullptr, + nullptr); + return info; + } + case ID::EAC_R11_UNORM_BLOCK: + { + static const Format info(ID::EAC_R11_UNORM_BLOCK, + GL_COMPRESSED_R11_EAC, + GL_COMPRESSED_R11_EAC, + nullptr, + nullptr); + return info; + } + case ID::ETC2_R8G8B8A1_SRGB_BLOCK: + { + static const Format info(ID::ETC2_R8G8B8A1_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, + GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, + nullptr, + nullptr); + return info; + } + case ID::ETC2_R8G8B8A1_UNORM_BLOCK: + { + static const Format info(ID::ETC2_R8G8B8A1_UNORM_BLOCK, + GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, + GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, + nullptr, + nullptr); + return info; + } + case ID::ETC2_R8G8B8A8_SRGB_BLOCK: + { + static const Format info(ID::ETC2_R8G8B8A8_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, + GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, + nullptr, + nullptr); + return info; + } + case ID::ETC2_R8G8B8A8_UNORM_BLOCK: + { + static const Format info(ID::ETC2_R8G8B8A8_UNORM_BLOCK, + GL_COMPRESSED_RGBA8_ETC2_EAC, + GL_COMPRESSED_RGBA8_ETC2_EAC, + nullptr, + nullptr); + return info; + } + case ID::ETC2_R8G8B8_SRGB_BLOCK: + { + static const Format info(ID::ETC2_R8G8B8_SRGB_BLOCK, + GL_COMPRESSED_SRGB8_ETC2, + GL_COMPRESSED_SRGB8_ETC2, + nullptr, + nullptr); + return info; + } + case ID::ETC2_R8G8B8_UNORM_BLOCK: + { + static const Format info(ID::ETC2_R8G8B8_UNORM_BLOCK, + GL_COMPRESSED_RGB8_ETC2, + GL_COMPRESSED_RGB8_ETC2, + nullptr, + nullptr); + return info; + } + case ID::L16A16_FLOAT: + { + static const Format info(ID::L16A16_FLOAT, + GL_LUMINANCE_ALPHA16F_EXT, + GL_LUMINANCE_ALPHA16F_EXT, + GenerateMip<L16A16F>, + ReadColor<L16A16F, GLfloat>); + return info; + } + case ID::L16_FLOAT: + { + static const Format info(ID::L16_FLOAT, + GL_LUMINANCE16F_EXT, + GL_LUMINANCE16F_EXT, + GenerateMip<L16F>, + ReadColor<L16F, GLfloat>); + return info; + } + case ID::L32A32_FLOAT: + { + static const Format info(ID::L32A32_FLOAT, + GL_LUMINANCE_ALPHA32F_EXT, + GL_LUMINANCE_ALPHA32F_EXT, + GenerateMip<L32A32F>, + ReadColor<L32A32F, GLfloat>); + return info; + } + case ID::L32_FLOAT: + { + static const Format info(ID::L32_FLOAT, + GL_LUMINANCE32F_EXT, + GL_LUMINANCE32F_EXT, + GenerateMip<L32F>, + ReadColor<L32F, GLfloat>); + return info; + } + case ID::L8A8_UNORM: + { + static const Format info(ID::L8A8_UNORM, + GL_LUMINANCE8_ALPHA8_EXT, + GL_LUMINANCE8_ALPHA8_EXT, + GenerateMip<L8A8>, + ReadColor<L8A8, GLfloat>); + return info; + } + case ID::L8_UNORM: + { + static const Format info(ID::L8_UNORM, + GL_LUMINANCE8_EXT, + GL_LUMINANCE8_EXT, + GenerateMip<L8>, + ReadColor<L8, GLfloat>); + return info; + } + case ID::NONE: + { + static const Format info(ID::NONE, + GL_NONE, + GL_NONE, + nullptr, + nullptr); + return info; + } + case ID::R10G10B10A2_UINT: + { + static const Format info(ID::R10G10B10A2_UINT, + GL_RGB10_A2UI, + GL_RGB10_A2UI, + GenerateMip<R10G10B10A2>, + ReadColor<R10G10B10A2, GLuint>); + return info; + } + case ID::R10G10B10A2_UNORM: + { + static const Format info(ID::R10G10B10A2_UNORM, + GL_RGB10_A2, + GL_RGB10_A2, + GenerateMip<R10G10B10A2>, + ReadColor<R10G10B10A2, GLfloat>); + return info; + } + case ID::R11G11B10_FLOAT: + { + static const Format info(ID::R11G11B10_FLOAT, + GL_R11F_G11F_B10F, + GL_R11F_G11F_B10F, + GenerateMip<R11G11B10F>, + ReadColor<R11G11B10F, GLfloat>); + return info; + } + case ID::R16G16B16A16_FLOAT: + { + static const Format info(ID::R16G16B16A16_FLOAT, + GL_RGBA16F, + GL_RGBA16F, + GenerateMip<R16G16B16A16F>, + ReadColor<R16G16B16A16F, GLfloat>); + return info; + } + case ID::R16G16B16A16_SINT: + { + static const Format info(ID::R16G16B16A16_SINT, + GL_RGBA16I, + GL_RGBA16I, + GenerateMip<R16G16B16A16S>, + ReadColor<R16G16B16A16S, GLint>); + return info; + } + case ID::R16G16B16A16_SNORM: + { + static const Format info(ID::R16G16B16A16_SNORM, + GL_RGBA16_SNORM_EXT, + GL_RGBA16_SNORM_EXT, + GenerateMip<R16G16B16A16S>, + ReadColor<R16G16B16A16S, GLfloat>); + return info; + } + case ID::R16G16B16A16_UINT: + { + static const Format info(ID::R16G16B16A16_UINT, + GL_RGBA16UI, + GL_RGBA16UI, + GenerateMip<R16G16B16A16>, + ReadColor<R16G16B16A16, GLuint>); + return info; + } + case ID::R16G16B16A16_UNORM: + { + static const Format info(ID::R16G16B16A16_UNORM, + GL_RGBA16_EXT, + GL_RGBA16_EXT, + GenerateMip<R16G16B16A16>, + ReadColor<R16G16B16A16, GLfloat>); + return info; + } + case ID::R16G16B16_FLOAT: + { + static const Format info(ID::R16G16B16_FLOAT, + GL_RGB16F, + GL_RGB16F, + GenerateMip<R16G16B16F>, + ReadColor<R16G16B16F, GLfloat>); + return info; + } + case ID::R16G16B16_SINT: + { + static const Format info(ID::R16G16B16_SINT, + GL_RGB16I, + GL_RGB16I, + GenerateMip<R16G16B16S>, + ReadColor<R16G16B16S, GLint>); + return info; + } + case ID::R16G16B16_SNORM: + { + static const Format info(ID::R16G16B16_SNORM, + GL_RGB16_SNORM_EXT, + GL_RGB16_SNORM_EXT, + GenerateMip<R16G16B16S>, + ReadColor<R16G16B16S, GLfloat>); + return info; + } + case ID::R16G16B16_UINT: + { + static const Format info(ID::R16G16B16_UINT, + GL_RGB16UI, + GL_RGB16UI, + GenerateMip<R16G16B16>, + ReadColor<R16G16B16, GLuint>); + return info; + } + case ID::R16G16B16_UNORM: + { + static const Format info(ID::R16G16B16_UNORM, + GL_RGB16_EXT, + GL_RGB16_EXT, + GenerateMip<R16G16B16>, + ReadColor<R16G16B16, GLfloat>); + return info; + } + case ID::R16G16_FLOAT: + { + static const Format info(ID::R16G16_FLOAT, + GL_RG16F, + GL_RG16F, + GenerateMip<R16G16F>, + ReadColor<R16G16F, GLfloat>); + return info; + } + case ID::R16G16_SINT: + { + static const Format info(ID::R16G16_SINT, + GL_RG16I, + GL_RG16I, + GenerateMip<R16G16S>, + ReadColor<R16G16S, GLint>); + return info; + } + case ID::R16G16_SNORM: + { + static const Format info(ID::R16G16_SNORM, + GL_RG16_SNORM_EXT, + GL_RG16_SNORM_EXT, + GenerateMip<R16G16S>, + ReadColor<R16G16S, GLfloat>); + return info; + } + case ID::R16G16_UINT: + { + static const Format info(ID::R16G16_UINT, + GL_RG16UI, + GL_RG16UI, + GenerateMip<R16G16>, + ReadColor<R16G16, GLuint>); + return info; + } + case ID::R16G16_UNORM: + { + static const Format info(ID::R16G16_UNORM, + GL_RG16_EXT, + GL_RG16_EXT, + GenerateMip<R16G16>, + ReadColor<R16G16, GLfloat>); + return info; + } + case ID::R16_FLOAT: + { + static const Format info(ID::R16_FLOAT, + GL_R16F, + GL_R16F, + GenerateMip<R16F>, + ReadColor<R16F, GLfloat>); + return info; + } + case ID::R16_SINT: + { + static const Format info(ID::R16_SINT, + GL_R16I, + GL_R16I, + GenerateMip<R16S>, + ReadColor<R16S, GLint>); + return info; + } + case ID::R16_SNORM: + { + static const Format info(ID::R16_SNORM, + GL_R16_SNORM_EXT, + GL_R16_SNORM_EXT, + GenerateMip<R16S>, + ReadColor<R16S, GLfloat>); + return info; + } + case ID::R16_UINT: + { + static const Format info(ID::R16_UINT, + GL_R16UI, + GL_R16UI, + GenerateMip<R16>, + ReadColor<R16, GLuint>); + return info; + } + case ID::R16_UNORM: + { + static const Format info(ID::R16_UNORM, + GL_R16_EXT, + GL_R16_EXT, + GenerateMip<R16>, + ReadColor<R16, GLfloat>); + return info; + } + case ID::R32G32B32A32_FLOAT: + { + static const Format info(ID::R32G32B32A32_FLOAT, + GL_RGBA32F, + GL_RGBA32F, + GenerateMip<R32G32B32A32F>, + ReadColor<R32G32B32A32F, GLfloat>); + return info; + } + case ID::R32G32B32A32_SINT: + { + static const Format info(ID::R32G32B32A32_SINT, + GL_RGBA32I, + GL_RGBA32I, + GenerateMip<R32G32B32A32S>, + ReadColor<R32G32B32A32S, GLint>); + return info; + } + case ID::R32G32B32A32_UINT: + { + static const Format info(ID::R32G32B32A32_UINT, + GL_RGBA32UI, + GL_RGBA32UI, + GenerateMip<R32G32B32A32>, + ReadColor<R32G32B32A32, GLuint>); + return info; + } + case ID::R32G32B32_FLOAT: + { + static const Format info(ID::R32G32B32_FLOAT, + GL_RGB32F, + GL_RGB32F, + GenerateMip<R32G32B32F>, + ReadColor<R32G32B32F, GLfloat>); + return info; + } + case ID::R32G32B32_SINT: + { + static const Format info(ID::R32G32B32_SINT, + GL_RGB32I, + GL_RGB32I, + GenerateMip<R32G32B32S>, + ReadColor<R32G32B32S, GLint>); + return info; + } + case ID::R32G32B32_UINT: + { + static const Format info(ID::R32G32B32_UINT, + GL_RGB32UI, + GL_RGB32UI, + GenerateMip<R32G32B32>, + ReadColor<R32G32B32, GLuint>); + return info; + } + case ID::R32G32_FLOAT: + { + static const Format info(ID::R32G32_FLOAT, + GL_RG32F, + GL_RG32F, + GenerateMip<R32G32F>, + ReadColor<R32G32F, GLfloat>); + return info; + } + case ID::R32G32_SINT: + { + static const Format info(ID::R32G32_SINT, + GL_RG32I, + GL_RG32I, + GenerateMip<R32G32S>, + ReadColor<R32G32S, GLint>); + return info; + } + case ID::R32G32_UINT: + { + static const Format info(ID::R32G32_UINT, + GL_RG32UI, + GL_RG32UI, + GenerateMip<R32G32>, + ReadColor<R32G32, GLuint>); + return info; + } + case ID::R32_FLOAT: + { + static const Format info(ID::R32_FLOAT, + GL_R32F, + GL_R32F, + GenerateMip<R32F>, + ReadColor<R32F, GLfloat>); + return info; + } + case ID::R32_SINT: + { + static const Format info(ID::R32_SINT, + GL_R32I, + GL_R32I, + GenerateMip<R32S>, + ReadColor<R32S, GLint>); + return info; + } + case ID::R32_UINT: + { + static const Format info(ID::R32_UINT, + GL_R32UI, + GL_R32UI, + GenerateMip<R32>, + ReadColor<R32, GLuint>); + return info; + } + case ID::R4G4B4A4_UNORM: + { + static const Format info(ID::R4G4B4A4_UNORM, + GL_RGBA4, + GL_RGBA4, + GenerateMip<R4G4B4A4>, + ReadColor<R4G4B4A4, GLfloat>); + return info; + } + case ID::R5G5B5A1_UNORM: + { + static const Format info(ID::R5G5B5A1_UNORM, + GL_RGB5_A1, + GL_RGB5_A1, + GenerateMip<R5G5B5A1>, + ReadColor<R5G5B5A1, GLfloat>); + return info; + } + case ID::R5G6B5_UNORM: + { + static const Format info(ID::R5G6B5_UNORM, + GL_RGB565, + GL_RGB565, + GenerateMip<R5G6B5>, + ReadColor<R5G6B5, GLfloat>); + return info; + } + case ID::R8G8B8A8_SINT: + { + static const Format info(ID::R8G8B8A8_SINT, + GL_RGBA8I, + GL_RGBA8I, + GenerateMip<R8G8B8A8S>, + ReadColor<R8G8B8A8S, GLint>); + return info; + } + case ID::R8G8B8A8_SNORM: + { + static const Format info(ID::R8G8B8A8_SNORM, + GL_RGBA8_SNORM, + GL_RGBA8_SNORM, + GenerateMip<R8G8B8A8S>, + ReadColor<R8G8B8A8S, GLfloat>); + return info; + } + case ID::R8G8B8A8_UINT: + { + static const Format info(ID::R8G8B8A8_UINT, + GL_RGBA8UI, + GL_RGBA8UI, + GenerateMip<R8G8B8A8>, + ReadColor<R8G8B8A8, GLuint>); + return info; + } + case ID::R8G8B8A8_UNORM: + { + static const Format info(ID::R8G8B8A8_UNORM, + GL_RGBA8, + GL_RGBA8, + GenerateMip<R8G8B8A8>, + ReadColor<R8G8B8A8, GLfloat>); + return info; + } + case ID::R8G8B8A8_UNORM_SRGB: + { + static const Format info(ID::R8G8B8A8_UNORM_SRGB, + GL_SRGB8_ALPHA8, + GL_SRGB8_ALPHA8, + GenerateMip<R8G8B8A8>, + ReadColor<R8G8B8A8, GLfloat>); + return info; + } + case ID::R8G8B8_SINT: + { + static const Format info(ID::R8G8B8_SINT, + GL_RGB8I, + GL_RGB8I, + GenerateMip<R8G8B8S>, + ReadColor<R8G8B8S, GLint>); + return info; + } + case ID::R8G8B8_SNORM: + { + static const Format info(ID::R8G8B8_SNORM, + GL_RGB8_SNORM, + GL_RGB8_SNORM, + GenerateMip<R8G8B8S>, + ReadColor<R8G8B8S, GLfloat>); + return info; + } + case ID::R8G8B8_UINT: + { + static const Format info(ID::R8G8B8_UINT, + GL_RGB8UI, + GL_RGB8UI, + GenerateMip<R8G8B8>, + ReadColor<R8G8B8, GLuint>); + return info; + } + case ID::R8G8B8_UNORM: + { + static const Format info(ID::R8G8B8_UNORM, + GL_RGB8, + GL_RGB8, + GenerateMip<R8G8B8>, + ReadColor<R8G8B8, GLfloat>); + return info; + } + case ID::R8G8B8_UNORM_SRGB: + { + static const Format info(ID::R8G8B8_UNORM_SRGB, + GL_SRGB8, + GL_SRGB8, + GenerateMip<R8G8B8>, + ReadColor<R8G8B8, GLfloat>); + return info; + } + case ID::R8G8_SINT: + { + static const Format info(ID::R8G8_SINT, + GL_RG8I, + GL_RG8I, + GenerateMip<R8G8S>, + ReadColor<R8G8S, GLint>); + return info; + } + case ID::R8G8_SNORM: + { + static const Format info(ID::R8G8_SNORM, + GL_RG8_SNORM, + GL_RG8_SNORM, + GenerateMip<R8G8S>, + ReadColor<R8G8S, GLfloat>); + return info; + } + case ID::R8G8_UINT: + { + static const Format info(ID::R8G8_UINT, + GL_RG8UI, + GL_RG8UI, + GenerateMip<R8G8>, + ReadColor<R8G8, GLuint>); + return info; + } + case ID::R8G8_UNORM: + { + static const Format info(ID::R8G8_UNORM, + GL_RG8, + GL_RG8, + GenerateMip<R8G8>, + ReadColor<R8G8, GLfloat>); + return info; + } + case ID::R8_SINT: + { + static const Format info(ID::R8_SINT, + GL_R8I, + GL_R8I, + GenerateMip<R8S>, + ReadColor<R8S, GLint>); + return info; + } + case ID::R8_SNORM: + { + static const Format info(ID::R8_SNORM, + GL_R8_SNORM, + GL_R8_SNORM, + GenerateMip<R8S>, + ReadColor<R8S, GLfloat>); + return info; + } + case ID::R8_UINT: + { + static const Format info(ID::R8_UINT, + GL_R8UI, + GL_R8UI, + GenerateMip<R8>, + ReadColor<R8, GLuint>); + return info; + } + case ID::R8_UNORM: + { + static const Format info(ID::R8_UNORM, + GL_R8, + GL_R8, + GenerateMip<R8>, + ReadColor<R8, GLfloat>); + return info; + } + case ID::R9G9B9E5_SHAREDEXP: + { + static const Format info(ID::R9G9B9E5_SHAREDEXP, + GL_RGB9_E5, + GL_RGB9_E5, + GenerateMip<R9G9B9E5>, + ReadColor<R9G9B9E5, GLfloat>); + return info; + } + case ID::S8_UINT: + { + static const Format info(ID::S8_UINT, + GL_STENCIL_INDEX8, + GL_STENCIL_INDEX8, + nullptr, + nullptr); + return info; + } + + default: + UNREACHABLE(); + break; + } + // clang-format on + + static const Format noneInfo(ID::NONE, GL_NONE, GL_NONE, nullptr, nullptr); + return noneInfo; +} + +} // namespace angle diff --git a/gfx/angle/src/libANGLE/renderer/Format_table_autogen.cpp b/gfx/angle/src/libANGLE/renderer/Format_table_autogen.cpp deleted file mode 100644 index 507827ff1..000000000 --- a/gfx/angle/src/libANGLE/renderer/Format_table_autogen.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// GENERATED FILE - DO NOT EDIT. -// Generated by gen_angle_format_table.py using data from angle_format_data.json -// -// Copyright 2016 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. -// -// ANGLE Format table: -// Queries for typed format information from the ANGLE format enum. - -#include "libANGLE/renderer/Format.h" - -#include "image_util/copyimage.h" -#include "image_util/generatemip.h" -#include "image_util/loadimage.h" - -namespace angle -{ - -static constexpr rx::FastCopyFunctionMap::Entry BGRAEntry = {GL_RGBA, GL_UNSIGNED_BYTE, - CopyBGRA8ToRGBA8}; -static constexpr rx::FastCopyFunctionMap BGRACopyFunctions = {&BGRAEntry, 1}; -static constexpr rx::FastCopyFunctionMap NoCopyFunctions; - -constexpr Format g_formatInfoTable[] = { - // clang-format off - { Format::ID::NONE, GL_NONE, GL_NONE, nullptr, NoCopyFunctions, nullptr, GL_NONE, 0, 0, 0, 0, 0, 0 }, - { Format::ID::A16_FLOAT, GL_ALPHA16F_EXT, GL_ALPHA16F_EXT, GenerateMip<A16F>, NoCopyFunctions, ReadColor<A16F, GLfloat>, GL_FLOAT, 0, 0, 0, 16, 0, 0 }, - { Format::ID::A32_FLOAT, GL_ALPHA32F_EXT, GL_ALPHA32F_EXT, GenerateMip<A32F>, NoCopyFunctions, ReadColor<A32F, GLfloat>, GL_FLOAT, 0, 0, 0, 32, 0, 0 }, - { Format::ID::A8_UNORM, GL_ALPHA8_EXT, GL_ALPHA8_EXT, GenerateMip<A8>, NoCopyFunctions, ReadColor<A8, GLfloat>, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 8, 0, 0 }, - { Format::ID::ASTC_10x10_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_10x10_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_10x10_KHR, GL_COMPRESSED_RGBA_ASTC_10x10_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_10x5_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_10x5_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_COMPRESSED_RGBA_ASTC_10x5_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_10x6_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_10x6_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_10x6_KHR, GL_COMPRESSED_RGBA_ASTC_10x6_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_10x8_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_10x8_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_10x8_KHR, GL_COMPRESSED_RGBA_ASTC_10x8_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_12x10_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_12x10_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_12x10_KHR, GL_COMPRESSED_RGBA_ASTC_12x10_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_12x12_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_12x12_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_12x12_KHR, GL_COMPRESSED_RGBA_ASTC_12x12_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_4x4_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_4x4_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_COMPRESSED_RGBA_ASTC_4x4_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_5x4_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_5x4_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_5x4_KHR, GL_COMPRESSED_RGBA_ASTC_5x4_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_5x5_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_5x5_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_COMPRESSED_RGBA_ASTC_5x5_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_6x5_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_6x5_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_6x5_KHR, GL_COMPRESSED_RGBA_ASTC_6x5_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_6x6_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_6x6_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_COMPRESSED_RGBA_ASTC_6x6_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_8x5_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_8x5_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_8x5_KHR, GL_COMPRESSED_RGBA_ASTC_8x5_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_8x6_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_8x6_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_COMPRESSED_RGBA_ASTC_8x6_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_8x8_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::ASTC_8x8_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_8x8_KHR, GL_COMPRESSED_RGBA_ASTC_8x8_KHR, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::B4G4R4A4_UNORM, GL_BGRA4_ANGLEX, GL_RGBA4, GenerateMip<A4R4G4B4>, NoCopyFunctions, ReadColor<A4R4G4B4, GLfloat>, GL_UNSIGNED_NORMALIZED, 4, 4, 4, 4, 0, 0 }, - { Format::ID::B5G5R5A1_UNORM, GL_BGR5_A1_ANGLEX, GL_RGB5_A1, GenerateMip<A1R5G5B5>, NoCopyFunctions, ReadColor<A1R5G5B5, GLfloat>, GL_UNSIGNED_NORMALIZED, 5, 5, 5, 1, 0, 0 }, - { Format::ID::B5G6R5_UNORM, GL_BGR565_ANGLEX, GL_RGB565, GenerateMip<B5G6R5>, NoCopyFunctions, ReadColor<B5G6R5, GLfloat>, GL_UNSIGNED_NORMALIZED, 5, 6, 5, 0, 0, 0 }, - { Format::ID::B8G8R8A8_UNORM, GL_BGRA8_EXT, GL_BGRA8_EXT, GenerateMip<B8G8R8A8>, BGRACopyFunctions, ReadColor<B8G8R8A8, GLfloat>, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 8, 0, 0 }, - { Format::ID::B8G8R8X8_UNORM, GL_BGRA8_EXT, GL_BGRA8_EXT, GenerateMip<B8G8R8X8>, NoCopyFunctions, ReadColor<B8G8R8X8, GLfloat>, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 0, 0, 0 }, - { Format::ID::BC1_RGBA_UNORM_BLOCK, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::BC1_RGB_UNORM_BLOCK, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::BC2_RGBA_UNORM_BLOCK, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::BC3_RGBA_UNORM_BLOCK, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::D16_UNORM, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 16, 0 }, - { Format::ID::D24_UNORM, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 24, 0 }, - { Format::ID::D24_UNORM_S8_UINT, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 24, 8 }, - { Format::ID::D32_FLOAT, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, nullptr, NoCopyFunctions, nullptr, GL_FLOAT, 0, 0, 0, 0, 32, 0 }, - { Format::ID::D32_FLOAT_S8X24_UINT, GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, nullptr, NoCopyFunctions, nullptr, GL_FLOAT, 0, 0, 0, 0, 32, 8 }, - { Format::ID::D32_UNORM, GL_DEPTH_COMPONENT32_OES, GL_DEPTH_COMPONENT32_OES, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 32, 0 }, - { Format::ID::EAC_R11G11_SNORM_BLOCK, GL_COMPRESSED_SIGNED_RG11_EAC, GL_COMPRESSED_SIGNED_RG11_EAC, nullptr, NoCopyFunctions, nullptr, GL_SIGNED_NORMALIZED, 11, 11, 0, 0, 0, 0 }, - { Format::ID::EAC_R11G11_UNORM_BLOCK, GL_COMPRESSED_RG11_EAC, GL_COMPRESSED_RG11_EAC, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 11, 11, 0, 0, 0, 0 }, - { Format::ID::EAC_R11_SNORM_BLOCK, GL_COMPRESSED_SIGNED_R11_EAC, GL_COMPRESSED_SIGNED_R11_EAC, nullptr, NoCopyFunctions, nullptr, GL_SIGNED_NORMALIZED, 11, 0, 0, 0, 0, 0 }, - { Format::ID::EAC_R11_UNORM_BLOCK, GL_COMPRESSED_R11_EAC, GL_COMPRESSED_R11_EAC, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 11, 0, 0, 0, 0, 0 }, - { Format::ID::ETC2_R8G8B8A1_SRGB_BLOCK, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 1, 0, 0 }, - { Format::ID::ETC2_R8G8B8A1_UNORM_BLOCK, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 1, 0, 0 }, - { Format::ID::ETC2_R8G8B8A8_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 8, 0, 0 }, - { Format::ID::ETC2_R8G8B8A8_UNORM_BLOCK, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_COMPRESSED_RGBA8_ETC2_EAC, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 8, 0, 0 }, - { Format::ID::ETC2_R8G8B8_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ETC2, GL_COMPRESSED_SRGB8_ETC2, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 0, 0, 0 }, - { Format::ID::ETC2_R8G8B8_UNORM_BLOCK, GL_COMPRESSED_RGB8_ETC2, GL_COMPRESSED_RGB8_ETC2, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 0, 0, 0 }, - { Format::ID::L16A16_FLOAT, GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE_ALPHA16F_EXT, GenerateMip<L16A16F>, NoCopyFunctions, ReadColor<L16A16F, GLfloat>, GL_FLOAT, 0, 0, 0, 16, 0, 0 }, - { Format::ID::L16_FLOAT, GL_LUMINANCE16F_EXT, GL_LUMINANCE16F_EXT, GenerateMip<L16F>, NoCopyFunctions, ReadColor<L16F, GLfloat>, GL_FLOAT, 0, 0, 0, 0, 0, 0 }, - { Format::ID::L32A32_FLOAT, GL_LUMINANCE_ALPHA32F_EXT, GL_LUMINANCE_ALPHA32F_EXT, GenerateMip<L32A32F>, NoCopyFunctions, ReadColor<L32A32F, GLfloat>, GL_FLOAT, 0, 0, 0, 32, 0, 0 }, - { Format::ID::L32_FLOAT, GL_LUMINANCE32F_EXT, GL_LUMINANCE32F_EXT, GenerateMip<L32F>, NoCopyFunctions, ReadColor<L32F, GLfloat>, GL_FLOAT, 0, 0, 0, 0, 0, 0 }, - { Format::ID::L8A8_UNORM, GL_LUMINANCE8_ALPHA8_EXT, GL_LUMINANCE8_ALPHA8_EXT, GenerateMip<L8A8>, NoCopyFunctions, ReadColor<L8A8, GLfloat>, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 8, 0, 0 }, - { Format::ID::L8_UNORM, GL_LUMINANCE8_EXT, GL_LUMINANCE8_EXT, GenerateMip<L8>, NoCopyFunctions, ReadColor<L8, GLfloat>, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 }, - { Format::ID::R10G10B10A2_UINT, GL_RGB10_A2UI, GL_RGB10_A2UI, GenerateMip<R10G10B10A2>, NoCopyFunctions, ReadColor<R10G10B10A2, GLuint>, GL_UNSIGNED_INT, 10, 10, 10, 2, 0, 0 }, - { Format::ID::R10G10B10A2_UNORM, GL_RGB10_A2, GL_RGB10_A2, GenerateMip<R10G10B10A2>, NoCopyFunctions, ReadColor<R10G10B10A2, GLfloat>, GL_UNSIGNED_NORMALIZED, 10, 10, 10, 2, 0, 0 }, - { Format::ID::R11G11B10_FLOAT, GL_R11F_G11F_B10F, GL_R11F_G11F_B10F, GenerateMip<R11G11B10F>, NoCopyFunctions, ReadColor<R11G11B10F, GLfloat>, GL_FLOAT, 11, 11, 10, 0, 0, 0 }, - { Format::ID::R16G16B16A16_FLOAT, GL_RGBA16F, GL_RGBA16F, GenerateMip<R16G16B16A16F>, NoCopyFunctions, ReadColor<R16G16B16A16F, GLfloat>, GL_FLOAT, 16, 16, 16, 16, 0, 0 }, - { Format::ID::R16G16B16A16_SINT, GL_RGBA16I, GL_RGBA16I, GenerateMip<R16G16B16A16S>, NoCopyFunctions, ReadColor<R16G16B16A16S, GLint>, GL_INT, 16, 16, 16, 16, 0, 0 }, - { Format::ID::R16G16B16A16_SNORM, GL_RGBA16_SNORM_EXT, GL_RGBA16_SNORM_EXT, GenerateMip<R16G16B16A16S>, NoCopyFunctions, ReadColor<R16G16B16A16S, GLfloat>, GL_SIGNED_NORMALIZED, 16, 16, 16, 16, 0, 0 }, - { Format::ID::R16G16B16A16_UINT, GL_RGBA16UI, GL_RGBA16UI, GenerateMip<R16G16B16A16>, NoCopyFunctions, ReadColor<R16G16B16A16, GLuint>, GL_UNSIGNED_INT, 16, 16, 16, 16, 0, 0 }, - { Format::ID::R16G16B16A16_UNORM, GL_RGBA16_EXT, GL_RGBA16_EXT, GenerateMip<R16G16B16A16>, NoCopyFunctions, ReadColor<R16G16B16A16, GLfloat>, GL_UNSIGNED_NORMALIZED, 16, 16, 16, 16, 0, 0 }, - { Format::ID::R16G16B16_FLOAT, GL_RGB16F, GL_RGB16F, GenerateMip<R16G16B16F>, NoCopyFunctions, ReadColor<R16G16B16F, GLfloat>, GL_FLOAT, 16, 16, 16, 0, 0, 0 }, - { Format::ID::R16G16B16_SINT, GL_RGB16I, GL_RGB16I, GenerateMip<R16G16B16S>, NoCopyFunctions, ReadColor<R16G16B16S, GLint>, GL_INT, 16, 16, 16, 0, 0, 0 }, - { Format::ID::R16G16B16_SNORM, GL_RGB16_SNORM_EXT, GL_RGB16_SNORM_EXT, GenerateMip<R16G16B16S>, NoCopyFunctions, ReadColor<R16G16B16S, GLfloat>, GL_SIGNED_NORMALIZED, 16, 16, 16, 0, 0, 0 }, - { Format::ID::R16G16B16_UINT, GL_RGB16UI, GL_RGB16UI, GenerateMip<R16G16B16>, NoCopyFunctions, ReadColor<R16G16B16, GLuint>, GL_UNSIGNED_INT, 16, 16, 16, 0, 0, 0 }, - { Format::ID::R16G16B16_UNORM, GL_RGB16_EXT, GL_RGB16_EXT, GenerateMip<R16G16B16>, NoCopyFunctions, ReadColor<R16G16B16, GLfloat>, GL_UNSIGNED_NORMALIZED, 16, 16, 16, 0, 0, 0 }, - { Format::ID::R16G16_FLOAT, GL_RG16F, GL_RG16F, GenerateMip<R16G16F>, NoCopyFunctions, ReadColor<R16G16F, GLfloat>, GL_FLOAT, 16, 16, 0, 0, 0, 0 }, - { Format::ID::R16G16_SINT, GL_RG16I, GL_RG16I, GenerateMip<R16G16S>, NoCopyFunctions, ReadColor<R16G16S, GLint>, GL_INT, 16, 16, 0, 0, 0, 0 }, - { Format::ID::R16G16_SNORM, GL_RG16_SNORM_EXT, GL_RG16_SNORM_EXT, GenerateMip<R16G16S>, NoCopyFunctions, ReadColor<R16G16S, GLfloat>, GL_SIGNED_NORMALIZED, 16, 16, 0, 0, 0, 0 }, - { Format::ID::R16G16_UINT, GL_RG16UI, GL_RG16UI, GenerateMip<R16G16>, NoCopyFunctions, ReadColor<R16G16, GLuint>, GL_UNSIGNED_INT, 16, 16, 0, 0, 0, 0 }, - { Format::ID::R16G16_UNORM, GL_RG16_EXT, GL_RG16_EXT, GenerateMip<R16G16>, NoCopyFunctions, ReadColor<R16G16, GLfloat>, GL_UNSIGNED_NORMALIZED, 16, 16, 0, 0, 0, 0 }, - { Format::ID::R16_FLOAT, GL_R16F, GL_R16F, GenerateMip<R16F>, NoCopyFunctions, ReadColor<R16F, GLfloat>, GL_FLOAT, 16, 0, 0, 0, 0, 0 }, - { Format::ID::R16_SINT, GL_R16I, GL_R16I, GenerateMip<R16S>, NoCopyFunctions, ReadColor<R16S, GLint>, GL_INT, 16, 0, 0, 0, 0, 0 }, - { Format::ID::R16_SNORM, GL_R16_SNORM_EXT, GL_R16_SNORM_EXT, GenerateMip<R16S>, NoCopyFunctions, ReadColor<R16S, GLfloat>, GL_SIGNED_NORMALIZED, 16, 0, 0, 0, 0, 0 }, - { Format::ID::R16_UINT, GL_R16UI, GL_R16UI, GenerateMip<R16>, NoCopyFunctions, ReadColor<R16, GLuint>, GL_UNSIGNED_INT, 16, 0, 0, 0, 0, 0 }, - { Format::ID::R16_UNORM, GL_R16_EXT, GL_R16_EXT, GenerateMip<R16>, NoCopyFunctions, ReadColor<R16, GLfloat>, GL_UNSIGNED_NORMALIZED, 16, 0, 0, 0, 0, 0 }, - { Format::ID::R32G32B32A32_FLOAT, GL_RGBA32F, GL_RGBA32F, GenerateMip<R32G32B32A32F>, NoCopyFunctions, ReadColor<R32G32B32A32F, GLfloat>, GL_FLOAT, 32, 32, 32, 32, 0, 0 }, - { Format::ID::R32G32B32A32_SINT, GL_RGBA32I, GL_RGBA32I, GenerateMip<R32G32B32A32S>, NoCopyFunctions, ReadColor<R32G32B32A32S, GLint>, GL_INT, 32, 32, 32, 32, 0, 0 }, - { Format::ID::R32G32B32A32_UINT, GL_RGBA32UI, GL_RGBA32UI, GenerateMip<R32G32B32A32>, NoCopyFunctions, ReadColor<R32G32B32A32, GLuint>, GL_UNSIGNED_INT, 32, 32, 32, 32, 0, 0 }, - { Format::ID::R32G32B32_FLOAT, GL_RGB32F, GL_RGB32F, GenerateMip<R32G32B32F>, NoCopyFunctions, ReadColor<R32G32B32F, GLfloat>, GL_FLOAT, 32, 32, 32, 0, 0, 0 }, - { Format::ID::R32G32B32_SINT, GL_RGB32I, GL_RGB32I, GenerateMip<R32G32B32S>, NoCopyFunctions, ReadColor<R32G32B32S, GLint>, GL_INT, 32, 32, 32, 0, 0, 0 }, - { Format::ID::R32G32B32_UINT, GL_RGB32UI, GL_RGB32UI, GenerateMip<R32G32B32>, NoCopyFunctions, ReadColor<R32G32B32, GLuint>, GL_UNSIGNED_INT, 32, 32, 32, 0, 0, 0 }, - { Format::ID::R32G32_FLOAT, GL_RG32F, GL_RG32F, GenerateMip<R32G32F>, NoCopyFunctions, ReadColor<R32G32F, GLfloat>, GL_FLOAT, 32, 32, 0, 0, 0, 0 }, - { Format::ID::R32G32_SINT, GL_RG32I, GL_RG32I, GenerateMip<R32G32S>, NoCopyFunctions, ReadColor<R32G32S, GLint>, GL_INT, 32, 32, 0, 0, 0, 0 }, - { Format::ID::R32G32_UINT, GL_RG32UI, GL_RG32UI, GenerateMip<R32G32>, NoCopyFunctions, ReadColor<R32G32, GLuint>, GL_UNSIGNED_INT, 32, 32, 0, 0, 0, 0 }, - { Format::ID::R32_FLOAT, GL_R32F, GL_R32F, GenerateMip<R32F>, NoCopyFunctions, ReadColor<R32F, GLfloat>, GL_FLOAT, 32, 0, 0, 0, 0, 0 }, - { Format::ID::R32_SINT, GL_R32I, GL_R32I, GenerateMip<R32S>, NoCopyFunctions, ReadColor<R32S, GLint>, GL_INT, 32, 0, 0, 0, 0, 0 }, - { Format::ID::R32_UINT, GL_R32UI, GL_R32UI, GenerateMip<R32>, NoCopyFunctions, ReadColor<R32, GLuint>, GL_UNSIGNED_INT, 32, 0, 0, 0, 0, 0 }, - { Format::ID::R4G4B4A4_UNORM, GL_RGBA4, GL_RGBA4, GenerateMip<R4G4B4A4>, NoCopyFunctions, ReadColor<R4G4B4A4, GLfloat>, GL_UNSIGNED_NORMALIZED, 4, 4, 4, 4, 0, 0 }, - { Format::ID::R5G5B5A1_UNORM, GL_RGB5_A1, GL_RGB5_A1, GenerateMip<R5G5B5A1>, NoCopyFunctions, ReadColor<R5G5B5A1, GLfloat>, GL_UNSIGNED_NORMALIZED, 5, 5, 5, 1, 0, 0 }, - { Format::ID::R5G6B5_UNORM, GL_RGB565, GL_RGB565, GenerateMip<R5G6B5>, NoCopyFunctions, ReadColor<R5G6B5, GLfloat>, GL_UNSIGNED_NORMALIZED, 5, 6, 5, 0, 0, 0 }, - { Format::ID::R8G8B8A8_SINT, GL_RGBA8I, GL_RGBA8I, GenerateMip<R8G8B8A8S>, NoCopyFunctions, ReadColor<R8G8B8A8S, GLint>, GL_INT, 8, 8, 8, 8, 0, 0 }, - { Format::ID::R8G8B8A8_SNORM, GL_RGBA8_SNORM, GL_RGBA8_SNORM, GenerateMip<R8G8B8A8S>, NoCopyFunctions, ReadColor<R8G8B8A8S, GLfloat>, GL_SIGNED_NORMALIZED, 8, 8, 8, 8, 0, 0 }, - { Format::ID::R8G8B8A8_UINT, GL_RGBA8UI, GL_RGBA8UI, GenerateMip<R8G8B8A8>, NoCopyFunctions, ReadColor<R8G8B8A8, GLuint>, GL_UNSIGNED_INT, 8, 8, 8, 8, 0, 0 }, - { Format::ID::R8G8B8A8_UNORM, GL_RGBA8, GL_RGBA8, GenerateMip<R8G8B8A8>, NoCopyFunctions, ReadColor<R8G8B8A8, GLfloat>, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 8, 0, 0 }, - { Format::ID::R8G8B8A8_UNORM_SRGB, GL_SRGB8_ALPHA8, GL_SRGB8_ALPHA8, GenerateMip<R8G8B8A8>, NoCopyFunctions, ReadColor<R8G8B8A8, GLfloat>, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 8, 0, 0 }, - { Format::ID::R8G8B8_SINT, GL_RGB8I, GL_RGB8I, GenerateMip<R8G8B8S>, NoCopyFunctions, ReadColor<R8G8B8S, GLint>, GL_INT, 8, 8, 8, 0, 0, 0 }, - { Format::ID::R8G8B8_SNORM, GL_RGB8_SNORM, GL_RGB8_SNORM, GenerateMip<R8G8B8S>, NoCopyFunctions, ReadColor<R8G8B8S, GLfloat>, GL_SIGNED_NORMALIZED, 8, 8, 8, 0, 0, 0 }, - { Format::ID::R8G8B8_UINT, GL_RGB8UI, GL_RGB8UI, GenerateMip<R8G8B8>, NoCopyFunctions, ReadColor<R8G8B8, GLuint>, GL_UNSIGNED_INT, 8, 8, 8, 0, 0, 0 }, - { Format::ID::R8G8B8_UNORM, GL_RGB8, GL_RGB8, GenerateMip<R8G8B8>, NoCopyFunctions, ReadColor<R8G8B8, GLfloat>, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 0, 0, 0 }, - { Format::ID::R8G8B8_UNORM_SRGB, GL_SRGB8, GL_SRGB8, GenerateMip<R8G8B8>, NoCopyFunctions, ReadColor<R8G8B8, GLfloat>, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 0, 0, 0 }, - { Format::ID::R8G8_SINT, GL_RG8I, GL_RG8I, GenerateMip<R8G8S>, NoCopyFunctions, ReadColor<R8G8S, GLint>, GL_INT, 8, 8, 0, 0, 0, 0 }, - { Format::ID::R8G8_SNORM, GL_RG8_SNORM, GL_RG8_SNORM, GenerateMip<R8G8S>, NoCopyFunctions, ReadColor<R8G8S, GLfloat>, GL_SIGNED_NORMALIZED, 8, 8, 0, 0, 0, 0 }, - { Format::ID::R8G8_UINT, GL_RG8UI, GL_RG8UI, GenerateMip<R8G8>, NoCopyFunctions, ReadColor<R8G8, GLuint>, GL_UNSIGNED_INT, 8, 8, 0, 0, 0, 0 }, - { Format::ID::R8G8_UNORM, GL_RG8, GL_RG8, GenerateMip<R8G8>, NoCopyFunctions, ReadColor<R8G8, GLfloat>, GL_UNSIGNED_NORMALIZED, 8, 8, 0, 0, 0, 0 }, - { Format::ID::R8_SINT, GL_R8I, GL_R8I, GenerateMip<R8S>, NoCopyFunctions, ReadColor<R8S, GLint>, GL_INT, 8, 0, 0, 0, 0, 0 }, - { Format::ID::R8_SNORM, GL_R8_SNORM, GL_R8_SNORM, GenerateMip<R8S>, NoCopyFunctions, ReadColor<R8S, GLfloat>, GL_SIGNED_NORMALIZED, 8, 0, 0, 0, 0, 0 }, - { Format::ID::R8_UINT, GL_R8UI, GL_R8UI, GenerateMip<R8>, NoCopyFunctions, ReadColor<R8, GLuint>, GL_UNSIGNED_INT, 8, 0, 0, 0, 0, 0 }, - { Format::ID::R8_UNORM, GL_R8, GL_R8, GenerateMip<R8>, NoCopyFunctions, ReadColor<R8, GLfloat>, GL_UNSIGNED_NORMALIZED, 8, 0, 0, 0, 0, 0 }, - { Format::ID::R9G9B9E5_SHAREDEXP, GL_RGB9_E5, GL_RGB9_E5, GenerateMip<R9G9B9E5>, NoCopyFunctions, ReadColor<R9G9B9E5, GLfloat>, GL_FLOAT, 9, 9, 9, 0, 0, 0 }, - { Format::ID::S8_UINT, GL_STENCIL_INDEX8, GL_STENCIL_INDEX8, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_INT, 0, 0, 0, 0, 0, 8 }, - // clang-format on -}; - -// static -const Format &Format::Get(ID id) -{ - return g_formatInfoTable[static_cast<size_t>(id)]; -} - -} // namespace angle diff --git a/gfx/angle/src/libANGLE/renderer/FramebufferAttachmentObjectImpl.h b/gfx/angle/src/libANGLE/renderer/FramebufferAttachmentObjectImpl.h index 5139ee5fd..a5aa65e55 100755 --- a/gfx/angle/src/libANGLE/renderer/FramebufferAttachmentObjectImpl.h +++ b/gfx/angle/src/libANGLE/renderer/FramebufferAttachmentObjectImpl.h @@ -23,11 +23,7 @@ class FramebufferAttachmentObjectImpl : angle::NonCopyable virtual ~FramebufferAttachmentObjectImpl() {} virtual gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target, - FramebufferAttachmentRenderTarget **rtOut) - { - UNIMPLEMENTED(); - return gl::Error(GL_OUT_OF_MEMORY, "getAttachmentRenderTarget not supported."); - } + FramebufferAttachmentRenderTarget **rtOut) = 0; }; } // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/GLImplFactory.h b/gfx/angle/src/libANGLE/renderer/GLImplFactory.h index 20a48fc72..09f14d727 100755 --- a/gfx/angle/src/libANGLE/renderer/GLImplFactory.h +++ b/gfx/angle/src/libANGLE/renderer/GLImplFactory.h @@ -63,7 +63,7 @@ class GLImplFactory : angle::NonCopyable virtual RenderbufferImpl *createRenderbuffer() = 0; // Buffer creation - virtual BufferImpl *createBuffer(const gl::BufferState &state) = 0; + virtual BufferImpl *createBuffer() = 0; // Vertex Array creation virtual VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) = 0; diff --git a/gfx/angle/src/libANGLE/renderer/ProgramImpl.h b/gfx/angle/src/libANGLE/renderer/ProgramImpl.h index 065f6a338..45ff0a05a 100755 --- a/gfx/angle/src/libANGLE/renderer/ProgramImpl.h +++ b/gfx/angle/src/libANGLE/renderer/ProgramImpl.h @@ -24,7 +24,14 @@ struct BlockMemberInfo; namespace rx { -using LinkResult = gl::ErrorOrResult<bool>; + +struct LinkResult +{ + LinkResult(bool linkSuccess, const gl::Error &error) : linkSuccess(linkSuccess), error(error) {} + + bool linkSuccess; + gl::Error error; +}; class ProgramImpl : angle::NonCopyable { diff --git a/gfx/angle/src/libANGLE/renderer/ShaderImpl.h b/gfx/angle/src/libANGLE/renderer/ShaderImpl.h index 77e02d023..2ade19a06 100755 --- a/gfx/angle/src/libANGLE/renderer/ShaderImpl.h +++ b/gfx/angle/src/libANGLE/renderer/ShaderImpl.h @@ -21,9 +21,9 @@ class ShaderImpl : angle::NonCopyable ShaderImpl(const gl::ShaderState &data) : mData(data) {} virtual ~ShaderImpl() { } - // Returns additional sh::Compile options. - virtual ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream, - std::string *sourcePath) = 0; + // Returns additional ShCompile options. + virtual int prepareSourceAndReturnOptions(std::stringstream *sourceStream, + std::string *sourcePath) = 0; // Returns success for compiling on the driver. Returns success. virtual bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) = 0; diff --git a/gfx/angle/src/libANGLE/renderer/SurfaceImpl.cpp b/gfx/angle/src/libANGLE/renderer/SurfaceImpl.cpp index e4b3d7c8b..517214b36 100755 --- a/gfx/angle/src/libANGLE/renderer/SurfaceImpl.cpp +++ b/gfx/angle/src/libANGLE/renderer/SurfaceImpl.cpp @@ -19,10 +19,4 @@ SurfaceImpl::~SurfaceImpl() { } -egl::Error SurfaceImpl::swapWithDamage(EGLint *rects, EGLint n_rects) -{ - UNREACHABLE(); - return egl::Error(EGL_BAD_SURFACE, "swapWithDamage implementation missing."); -} - } // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/SurfaceImpl.h b/gfx/angle/src/libANGLE/renderer/SurfaceImpl.h index 177e788d8..5efe2fc87 100755 --- a/gfx/angle/src/libANGLE/renderer/SurfaceImpl.h +++ b/gfx/angle/src/libANGLE/renderer/SurfaceImpl.h @@ -39,7 +39,6 @@ class SurfaceImpl : public FramebufferAttachmentObjectImpl virtual egl::Error initialize() = 0; virtual FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &state) = 0; virtual egl::Error swap() = 0; - virtual egl::Error swapWithDamage(EGLint *rects, EGLint n_rects); virtual egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) = 0; virtual egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) = 0; virtual egl::Error bindTexImage(gl::Texture *texture, EGLint buffer) = 0; diff --git a/gfx/angle/src/libANGLE/renderer/TextureImpl.cpp b/gfx/angle/src/libANGLE/renderer/TextureImpl.cpp index af4796371..465d4e3e7 100755 --- a/gfx/angle/src/libANGLE/renderer/TextureImpl.cpp +++ b/gfx/angle/src/libANGLE/renderer/TextureImpl.cpp @@ -40,11 +40,4 @@ gl::Error TextureImpl::copySubTexture(const gl::Offset &destOffset, UNREACHABLE(); return gl::Error(GL_INVALID_OPERATION, "CHROMIUM_copy_texture exposed but not implemented."); } - -gl::Error TextureImpl::copyCompressedTexture(const gl::Texture *source) -{ - UNREACHABLE(); - return gl::Error(GL_INVALID_OPERATION, - "CHROMIUM_copy_compressed_texture exposed but not implemented."); -} } diff --git a/gfx/angle/src/libANGLE/renderer/TextureImpl.h b/gfx/angle/src/libANGLE/renderer/TextureImpl.h index 7d0ebe2f1..45c230729 100755 --- a/gfx/angle/src/libANGLE/renderer/TextureImpl.h +++ b/gfx/angle/src/libANGLE/renderer/TextureImpl.h @@ -16,7 +16,6 @@ #include "libANGLE/Error.h" #include "libANGLE/ImageIndex.h" #include "libANGLE/Stream.h" -#include "libANGLE/Texture.h" #include "libANGLE/renderer/FramebufferAttachmentObjectImpl.h" namespace egl @@ -73,8 +72,6 @@ class TextureImpl : public FramebufferAttachmentObjectImpl bool unpackUnmultiplyAlpha, const gl::Texture *source); - virtual gl::Error copyCompressedTexture(const gl::Texture *source); - virtual gl::Error setStorage(GLenum target, size_t levels, GLenum internalFormat, const gl::Extents &size) = 0; virtual gl::Error setEGLImageTarget(GLenum target, egl::Image *image) = 0; @@ -90,8 +87,6 @@ class TextureImpl : public FramebufferAttachmentObjectImpl virtual void bindTexImage(egl::Surface *surface) = 0; virtual void releaseTexImage() = 0; - virtual void syncState(const gl::Texture::DirtyBits &dirtyBits) = 0; - protected: const gl::TextureState &mState; }; diff --git a/gfx/angle/src/libANGLE/renderer/TextureImpl_mock.h b/gfx/angle/src/libANGLE/renderer/TextureImpl_mock.h index c8d05d202..8b8f397ac 100755 --- a/gfx/angle/src/libANGLE/renderer/TextureImpl_mock.h +++ b/gfx/angle/src/libANGLE/renderer/TextureImpl_mock.h @@ -19,7 +19,7 @@ namespace rx class MockTextureImpl : public TextureImpl { public: - MockTextureImpl() : TextureImpl(mMockState), mMockState(GL_TEXTURE_2D) {} + MockTextureImpl() : TextureImpl(gl::TextureState(GL_TEXTURE_2D)) {} virtual ~MockTextureImpl() { destructor(); } MOCK_METHOD8(setImage, gl::Error(GLenum, size_t, GLenum, const gl::Extents &, GLenum, GLenum, const gl::PixelUnpackState &, const uint8_t *)); MOCK_METHOD7(setSubImage, gl::Error(GLenum, size_t, const gl::Box &, GLenum, GLenum, const gl::PixelUnpackState &, const uint8_t *)); @@ -35,7 +35,6 @@ class MockTextureImpl : public TextureImpl bool, bool, const gl::Texture *)); - MOCK_METHOD1(copyCompressedTexture, gl::Error(const gl::Texture *source)); MOCK_METHOD4(setStorage, gl::Error(GLenum, size_t, GLenum, const gl::Extents &)); MOCK_METHOD3(setImageExternal, gl::Error(GLenum, egl::Stream *, const egl::Stream::GLTextureDescription &)); @@ -48,12 +47,7 @@ class MockTextureImpl : public TextureImpl MOCK_METHOD1(setBaseLevel, void(GLuint)); - MOCK_METHOD1(syncState, void(const gl::Texture::DirtyBits &)); - MOCK_METHOD0(destructor, void()); - - protected: - gl::TextureState mMockState; }; } diff --git a/gfx/angle/src/libANGLE/renderer/d3d/BufferD3D.cpp b/gfx/angle/src/libANGLE/renderer/d3d/BufferD3D.cpp index 250162726..5e89c5bf4 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/BufferD3D.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/BufferD3D.cpp @@ -19,8 +19,8 @@ namespace rx unsigned int BufferD3D::mNextSerial = 1; -BufferD3D::BufferD3D(const gl::BufferState &state, BufferFactoryD3D *factory) - : BufferImpl(state), +BufferD3D::BufferD3D(BufferFactoryD3D *factory) + : BufferImpl(), mFactory(factory), mStaticIndexBuffer(nullptr), mStaticBufferCacheTotalSize(0), @@ -179,7 +179,11 @@ gl::Error BufferD3D::getIndexRange(GLenum type, gl::IndexRange *outRange) { const uint8_t *data = nullptr; - ANGLE_TRY(getData(&data)); + gl::Error error = getData(&data); + if (error.isError()) + { + return error; + } *outRange = gl::ComputeIndexRange(type, data + offset, count, primitiveRestartEnabled); return gl::Error(GL_NO_ERROR); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/BufferD3D.h b/gfx/angle/src/libANGLE/renderer/d3d/BufferD3D.h index fdabe7b7e..3c43c0164 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/BufferD3D.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/BufferD3D.h @@ -30,7 +30,7 @@ enum class D3DBufferUsage class BufferD3D : public BufferImpl { public: - BufferD3D(const gl::BufferState &state, BufferFactoryD3D *factory); + BufferD3D(BufferFactoryD3D *factory); virtual ~BufferD3D(); unsigned int getSerial() const { return mSerial; } diff --git a/gfx/angle/src/libANGLE/renderer/d3d/DisplayD3D.cpp b/gfx/angle/src/libANGLE/renderer/d3d/DisplayD3D.cpp index 474a08c65..f5cc97e95 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/DisplayD3D.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/DisplayD3D.cpp @@ -29,6 +29,10 @@ # include "libANGLE/renderer/d3d/d3d11/Renderer11.h" #endif // ANGLE_ENABLE_D3D11 +#if defined (ANGLE_TEST_CONFIG) +# define ANGLE_DEFAULT_D3D11 1 +#endif + #if !defined(ANGLE_DEFAULT_D3D11) // Enables use of the Direct3D 11 API for a default display, when available # define ANGLE_DEFAULT_D3D11 1 @@ -172,18 +176,16 @@ SurfaceImpl *DisplayD3D::createPbufferSurface(const egl::SurfaceState &state, const egl::AttributeMap &attribs) { ASSERT(mRenderer != nullptr); - return new PbufferSurfaceD3D(state, mRenderer, mDisplay, configuration, 0, nullptr, attribs); + return new PbufferSurfaceD3D(state, mRenderer, mDisplay, configuration, nullptr, attribs); } SurfaceImpl *DisplayD3D::createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) { ASSERT(mRenderer != nullptr); - return new PbufferSurfaceD3D(state, mRenderer, mDisplay, configuration, buftype, clientBuffer, - attribs); + return new PbufferSurfaceD3D(state, mRenderer, mDisplay, configuration, shareHandle, attribs); } SurfaceImpl *DisplayD3D::createPixmapSurface(const egl::SurfaceState &state, @@ -289,26 +291,6 @@ bool DisplayD3D::isValidNativeWindow(EGLNativeWindowType window) const return mRenderer->isValidNativeWindow(window); } -egl::Error DisplayD3D::validateClientBuffer(const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, - const egl::AttributeMap &attribs) const -{ - switch (buftype) - { - case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE: - return mRenderer->validateShareHandle(configuration, static_cast<HANDLE>(clientBuffer), - attribs); - - case EGL_D3D_TEXTURE_ANGLE: - return mRenderer->getD3DTextureInfo(static_cast<IUnknown *>(clientBuffer), nullptr, - nullptr, nullptr); - - default: - return DisplayImpl::validateClientBuffer(configuration, buftype, clientBuffer, attribs); - } -} - void DisplayD3D::generateExtensions(egl::DisplayExtensions *outExtensions) const { mRenderer->generateDisplayExtensions(outExtensions); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/DisplayD3D.h b/gfx/angle/src/libANGLE/renderer/d3d/DisplayD3D.h index 3801a8eb1..1bd6f1160 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/DisplayD3D.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/DisplayD3D.h @@ -34,8 +34,7 @@ class DisplayD3D : public DisplayImpl const egl::AttributeMap &attribs) override; SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) override; SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state, const egl::Config *configuration, @@ -60,10 +59,6 @@ class DisplayD3D : public DisplayImpl egl::Error restoreLostDevice() override; bool isValidNativeWindow(EGLNativeWindowType window) const override; - egl::Error validateClientBuffer(const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, - const egl::AttributeMap &attribs) const override; egl::Error getDevice(DeviceImpl **device) override; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/DynamicHLSL.cpp b/gfx/angle/src/libANGLE/renderer/d3d/DynamicHLSL.cpp index 1946585c1..cb3e582d1 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/DynamicHLSL.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/DynamicHLSL.cpp @@ -117,8 +117,8 @@ void WriteArrayString(std::stringstream &strstr, unsigned int i) strstr << "]"; } -constexpr const char *VERTEX_ATTRIBUTE_STUB_STRING = "@@ VERTEX ATTRIBUTES @@"; -constexpr const char *PIXEL_OUTPUT_STUB_STRING = "@@ PIXEL OUTPUT @@"; +const std::string VERTEX_ATTRIBUTE_STUB_STRING = "@@ VERTEX ATTRIBUTES @@"; +const std::string PIXEL_OUTPUT_STUB_STRING = "@@ PIXEL OUTPUT @@"; } // anonymous namespace std::string GetVaryingSemantic(int majorShaderModel, bool programUsesPointSize) @@ -295,7 +295,7 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout( std::string vertexHLSL(sourceShader); size_t copyInsertionPos = vertexHLSL.find(VERTEX_ATTRIBUTE_STUB_STRING); - vertexHLSL.replace(copyInsertionPos, strlen(VERTEX_ATTRIBUTE_STUB_STRING), structStream.str()); + vertexHLSL.replace(copyInsertionPos, VERTEX_ATTRIBUTE_STUB_STRING.length(), structStream.str()); return vertexHLSL; } @@ -360,7 +360,7 @@ std::string DynamicHLSL::generatePixelShaderForOutputSignature( std::string pixelHLSL(sourceShader); size_t outputInsertionPos = pixelHLSL.find(PIXEL_OUTPUT_STUB_STRING); - pixelHLSL.replace(outputInsertionPos, strlen(PIXEL_OUTPUT_STUB_STRING), + pixelHLSL.replace(outputInsertionPos, PIXEL_OUTPUT_STUB_STRING.length(), declarationStream.str()); return pixelHLSL; @@ -440,7 +440,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::ContextState &data, } // Add stub string to be replaced when shader is dynamically defined by its layout - vertexStream << "\n" << std::string(VERTEX_ATTRIBUTE_STUB_STRING) << "\n"; + vertexStream << "\n" << VERTEX_ATTRIBUTE_STUB_STRING + "\n"; // Write the HLSL input/output declarations vertexStream << "struct VS_OUTPUT\n"; @@ -597,7 +597,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::ContextState &data, generateVaryingLinkHLSL(SHADER_PIXEL, varyingPacking, pixelStream); pixelStream << "\n"; - pixelStream << std::string(PIXEL_OUTPUT_STUB_STRING) << "\n"; + pixelStream << PIXEL_OUTPUT_STUB_STRING + "\n"; if (fragmentShader->usesFrontFacing()) { diff --git a/gfx/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp b/gfx/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp index cc8bb0ea7..a45c94538 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp @@ -207,7 +207,7 @@ GLenum FramebufferD3D::getImplementationColorReadFormat() const GLenum implementationFormat = getRenderTargetImplementationFormat(attachmentRenderTarget); const gl::InternalFormat &implementationFormatInfo = gl::GetInternalFormatInfo(implementationFormat); - return implementationFormatInfo.getReadPixelsFormat(); + return implementationFormatInfo.format; } GLenum FramebufferD3D::getImplementationColorReadType() const @@ -229,7 +229,7 @@ GLenum FramebufferD3D::getImplementationColorReadType() const GLenum implementationFormat = getRenderTargetImplementationFormat(attachmentRenderTarget); const gl::InternalFormat &implementationFormatInfo = gl::GetInternalFormatInfo(implementationFormat); - return implementationFormatInfo.getReadPixelsType(); + return implementationFormatInfo.type; } gl::Error FramebufferD3D::readPixels(ContextImpl *context, @@ -240,13 +240,15 @@ gl::Error FramebufferD3D::readPixels(ContextImpl *context, { const gl::PixelPackState &packState = context->getGLState().getPackState(); - const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type)); - - GLuint outputPitch = 0; - ANGLE_TRY_RESULT(formatInfo.computeRowPitch(area.width, packState.alignment, packState.rowLength), - outputPitch); + GLenum sizedInternalFormat = gl::GetSizedInternalFormat(format, type); + const gl::InternalFormat &sizedFormatInfo = gl::GetInternalFormatInfo(sizedInternalFormat); + GLuint outputPitch = 0; + ANGLE_TRY_RESULT( + sizedFormatInfo.computeRowPitch(type, area.width, packState.alignment, packState.rowLength), + outputPitch); GLuint outputSkipBytes = 0; - ANGLE_TRY_RESULT(formatInfo.computeSkipBytes(outputPitch, 0, packState, false), + ANGLE_TRY_RESULT(sizedFormatInfo.computeSkipBytes(outputPitch, 0, 0, packState.skipRows, + packState.skipPixels, false), outputSkipBytes); return readPixelsImpl(area, format, type, outputPitch, packState, diff --git a/gfx/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp b/gfx/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp index 305b6c4e4..e8b1af312 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp @@ -136,8 +136,7 @@ gl::Error HLSLCompiler::initialize() if (!mD3DCompilerModule) { - ERR("D3D compiler module not found."); - return gl::Error(GL_OUT_OF_MEMORY, "D3D compiler module not found."); + return gl::Error(GL_INVALID_OPERATION, "No D3D compiler module found - aborting!\n"); } mD3DCompileFunc = reinterpret_cast<pD3DCompile>(GetProcAddress(mD3DCompilerModule, "D3DCompile")); @@ -156,7 +155,7 @@ gl::Error HLSLCompiler::initialize() if (mD3DCompileFunc == nullptr) { - return gl::Error(GL_OUT_OF_MEMORY, "Error finding D3DCompile entry point."); + return gl::Error(GL_INVALID_OPERATION, "Error finding D3DCompile entry point"); } mInitialized = true; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.cpp b/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.cpp index c9581ccaa..ead5db645 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.cpp @@ -10,7 +10,6 @@ #include "libANGLE/renderer/d3d/ImageD3D.h" -#include "libANGLE/formatutils.h" #include "libANGLE/Framebuffer.h" #include "libANGLE/FramebufferAttachment.h" #include "libANGLE/renderer/d3d/FramebufferD3D.h" @@ -30,13 +29,4 @@ ImageD3D::ImageD3D() { } -GLenum -ImageD3D::getSizedInputFormat(GLenum inputType) const -{ - const auto &internalFormat = gl::GetInternalFormatInfo(mInternalFormat); - const auto &unsizedInternalFormat = internalFormat.format; - const auto &sizedInputFormat = gl::GetSizedInternalFormat(unsizedInternalFormat, inputType); - return sizedInputFormat; -} - } // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.h b/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.h index 79840c15b..947a8328f 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.h @@ -51,8 +51,6 @@ class ImageD3D : angle::NonCopyable virtual bool redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease) = 0; - GLenum getSizedInputFormat(GLenum inputType) const; - virtual gl::Error loadData(const gl::Box &area, const gl::PixelUnpackState &unpack, GLenum type, diff --git a/gfx/angle/src/libANGLE/renderer/d3d/ProgramD3D.cpp b/gfx/angle/src/libANGLE/renderer/d3d/ProgramD3D.cpp index d00a8738e..3ac82d941 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/ProgramD3D.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/ProgramD3D.cpp @@ -739,14 +739,14 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) if (memcmp(&identifier, &binaryDeviceIdentifier, sizeof(DeviceIdentifier)) != 0) { infoLog << "Invalid program binary, device configuration has changed."; - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } int compileFlags = stream->readInt<int>(); if (compileFlags != ANGLE_COMPILE_OPTIMIZATION_LEVEL) { infoLog << "Mismatched compilation flags."; - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } for (int &index : mAttribLocationToD3DSemantic) @@ -780,7 +780,7 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) if (stream->error()) { infoLog << "Invalid program binary."; - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } const auto &linkedUniforms = mState.getUniforms(); @@ -804,7 +804,7 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) if (stream->error()) { infoLog << "Invalid program binary."; - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } ASSERT(mD3DUniformBlocks.empty()); @@ -853,8 +853,6 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) const unsigned char *binary = reinterpret_cast<const unsigned char *>(stream->data()); - bool separateAttribs = (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS); - const unsigned int vertexShaderCount = stream->readInt<unsigned int>(); for (unsigned int vertexShaderIndex = 0; vertexShaderIndex < vertexShaderCount; vertexShaderIndex++) @@ -872,14 +870,18 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) ShaderExecutableD3D *shaderExecutable = nullptr; - ANGLE_TRY(mRenderer->loadExecutable(vertexShaderFunction, vertexShaderSize, SHADER_VERTEX, - mStreamOutVaryings, separateAttribs, - &shaderExecutable)); + gl::Error error = mRenderer->loadExecutable( + vertexShaderFunction, vertexShaderSize, SHADER_VERTEX, mStreamOutVaryings, + (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS), &shaderExecutable); + if (error.isError()) + { + return LinkResult(false, error); + } if (!shaderExecutable) { infoLog << "Could not create vertex shader."; - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } // generated converted input layout @@ -907,14 +909,18 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) const unsigned char *pixelShaderFunction = binary + stream->offset(); ShaderExecutableD3D *shaderExecutable = nullptr; - ANGLE_TRY(mRenderer->loadExecutable(pixelShaderFunction, pixelShaderSize, SHADER_PIXEL, - mStreamOutVaryings, separateAttribs, - &shaderExecutable)); + gl::Error error = mRenderer->loadExecutable( + pixelShaderFunction, pixelShaderSize, SHADER_PIXEL, mStreamOutVaryings, + (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS), &shaderExecutable); + if (error.isError()) + { + return LinkResult(false, error); + } if (!shaderExecutable) { infoLog << "Could not create pixel shader."; - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } // add new binary @@ -934,22 +940,27 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) } const unsigned char *geometryShaderFunction = binary + stream->offset(); + bool splitAttribs = (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS); - ANGLE_TRY(mRenderer->loadExecutable(geometryShaderFunction, geometryShaderSize, - SHADER_GEOMETRY, mStreamOutVaryings, separateAttribs, - &mGeometryExecutables[geometryExeIndex])); + gl::Error error = mRenderer->loadExecutable( + geometryShaderFunction, geometryShaderSize, SHADER_GEOMETRY, mStreamOutVaryings, + splitAttribs, &mGeometryExecutables[geometryExeIndex]); + if (error.isError()) + { + return LinkResult(false, error); + } if (!mGeometryExecutables[geometryExeIndex]) { infoLog << "Could not create geometry shader."; - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } stream->skip(geometryShaderSize); } initializeUniformStorage(); - return true; + return LinkResult(true, gl::Error(GL_NO_ERROR)); } gl::Error ProgramD3D::save(gl::BinaryOutputStream *stream) @@ -1278,14 +1289,22 @@ LinkResult ProgramD3D::compileProgramExecutables(const gl::ContextState &data, g { const gl::InputLayout &defaultInputLayout = GetDefaultInputLayoutFromShader(mState.getAttachedVertexShader()); - ShaderExecutableD3D *defaultVertexExecutable = nullptr; - ANGLE_TRY( - getVertexExecutableForInputLayout(defaultInputLayout, &defaultVertexExecutable, &infoLog)); + ShaderExecutableD3D *defaultVertexExecutable = NULL; + gl::Error error = + getVertexExecutableForInputLayout(defaultInputLayout, &defaultVertexExecutable, &infoLog); + if (error.isError()) + { + return LinkResult(false, error); + } std::vector<GLenum> defaultPixelOutput = GetDefaultOutputLayoutFromShader(getPixelShaderKey()); - ShaderExecutableD3D *defaultPixelExecutable = nullptr; - ANGLE_TRY( - getPixelExecutableForOutputLayout(defaultPixelOutput, &defaultPixelExecutable, &infoLog)); + ShaderExecutableD3D *defaultPixelExecutable = NULL; + error = + getPixelExecutableForOutputLayout(defaultPixelOutput, &defaultPixelExecutable, &infoLog); + if (error.isError()) + { + return LinkResult(false, error); + } // Auto-generate the geometry shader here, if we expect to be using point rendering in D3D11. ShaderExecutableD3D *pointGS = nullptr; @@ -1318,8 +1337,9 @@ LinkResult ProgramD3D::compileProgramExecutables(const gl::ContextState &data, g fragmentShaderD3D->appendDebugInfo(defaultPixelExecutable->getDebugInfo()); } - return (defaultVertexExecutable && defaultPixelExecutable && - (!usesGeometryShader(GL_POINTS) || pointGS)); + bool linkSuccess = (defaultVertexExecutable && defaultPixelExecutable && + (!usesGeometryShader(GL_POINTS) || pointGS)); + return LinkResult(linkSuccess, gl::Error(GL_NO_ERROR)); } LinkResult ProgramD3D::link(const gl::ContextState &data, gl::InfoLog &infoLog) @@ -1343,7 +1363,7 @@ LinkResult ProgramD3D::link(const gl::ContextState &data, gl::InfoLog &infoLog) if (fragmentShaderD3D->usesFrontFacing()) { infoLog << "The current renderer doesn't support gl_FrontFacing"; - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } } @@ -1355,7 +1375,7 @@ LinkResult ProgramD3D::link(const gl::ContextState &data, gl::InfoLog &infoLog) if (!varyingPacking.packVaryings(infoLog, packedVaryings, mState.getTransformFeedbackVaryingNames())) { - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } ProgramD3DMetadata metadata(mRenderer, vertexShaderD3D, fragmentShaderD3D); @@ -1366,7 +1386,7 @@ LinkResult ProgramD3D::link(const gl::ContextState &data, gl::InfoLog &infoLog) if (static_cast<GLuint>(varyingPacking.getRegisterCount()) > data.getCaps().maxVaryingVectors) { infoLog << "No varying registers left to support gl_FragCoord/gl_PointCoord"; - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } // TODO(jmadill): Implement more sophisticated component packing in D3D9. @@ -1376,13 +1396,13 @@ LinkResult ProgramD3D::link(const gl::ContextState &data, gl::InfoLog &infoLog) varyingPacking.getMaxSemanticIndex() > data.getCaps().maxVaryingVectors) { infoLog << "Cannot pack these varyings on D3D9."; - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } if (!mDynamicHLSL->generateShaderLinkHLSL(data, mState, metadata, varyingPacking, &mPixelHLSL, &mVertexHLSL)) { - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } mUsesPointSize = vertexShaderD3D->usesPointSize(); @@ -1413,12 +1433,7 @@ LinkResult ProgramD3D::link(const gl::ContextState &data, gl::InfoLog &infoLog) gatherTransformFeedbackVaryings(varyingPacking); LinkResult result = compileProgramExecutables(data, infoLog); - if (result.isError()) - { - infoLog << result.getError().getMessage(); - return result; - } - else if (!result.getResult()) + if (result.error.isError() || !result.linkSuccess) { infoLog << "Failed to create D3D shaders."; return result; @@ -1426,7 +1441,7 @@ LinkResult ProgramD3D::link(const gl::ContextState &data, gl::InfoLog &infoLog) initUniformBlockInfo(); - return true; + return LinkResult(true, gl::Error(GL_NO_ERROR)); } GLboolean ProgramD3D::validate(const gl::Caps & /*caps*/, gl::InfoLog * /*infoLog*/) diff --git a/gfx/angle/src/libANGLE/renderer/d3d/RendererD3D.h b/gfx/angle/src/libANGLE/renderer/d3d/RendererD3D.h index b63aba8a9..9378b68b3 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/RendererD3D.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/RendererD3D.h @@ -127,17 +127,9 @@ class RendererD3D : public BufferFactoryD3D virtual SwapChainD3D *createSwapChain(NativeWindowD3D *nativeWindow, HANDLE shareHandle, - IUnknown *d3dTexture, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) = 0; - virtual egl::Error getD3DTextureInfo(IUnknown *d3dTexture, - EGLint *width, - EGLint *height, - GLenum *fboFormat) const = 0; - virtual egl::Error validateShareHandle(const egl::Config *config, - HANDLE shareHandle, - const egl::AttributeMap &attribs) const = 0; virtual gl::Error setSamplerState(gl::SamplerType type, int index, gl::Texture *texture, const gl::SamplerState &sampler) = 0; virtual gl::Error setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0; @@ -177,10 +169,6 @@ class RendererD3D : public BufferFactoryD3D bool unpackFlipY, bool unpackPremultiplyAlpha, bool unpackUnmultiplyAlpha) = 0; - virtual gl::Error copyCompressedTexture(const gl::Texture *source, - GLint sourceLevel, - TextureStorage *storage, - GLint destLevel) = 0; // RenderTarget creation virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT) = 0; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/ShaderD3D.cpp b/gfx/angle/src/libANGLE/renderer/d3d/ShaderD3D.cpp index fd7b13abb..326c198d7 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/ShaderD3D.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/ShaderD3D.cpp @@ -59,14 +59,6 @@ ShaderD3D::ShaderD3D(const gl::ShaderState &data, const WorkaroundsD3D &workarou { mAdditionalOptions |= SH_REWRITE_TEXELFETCHOFFSET_TO_TEXELFETCH; } - if (workarounds.rewriteUnaryMinusOperator) - { - mAdditionalOptions |= SH_REWRITE_INTEGER_UNARY_MINUS_OPERATOR; - } - if (workarounds.emulateIsnanFloat) - { - mAdditionalOptions |= SH_EMULATE_ISNAN_FLOAT_FUNCTION; - } } ShaderD3D::~ShaderD3D() @@ -141,12 +133,12 @@ ShShaderOutput ShaderD3D::getCompilerOutputType() const return mCompilerOutputType; } -ShCompileOptions ShaderD3D::prepareSourceAndReturnOptions(std::stringstream *shaderSourceStream, - std::string *sourcePath) +int ShaderD3D::prepareSourceAndReturnOptions(std::stringstream *shaderSourceStream, + std::string *sourcePath) { uncompile(); - ShCompileOptions additionalOptions = 0; + int additionalOptions = 0; const std::string &source = mData.getSource(); @@ -201,7 +193,7 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo ShHandle compilerHandle = compiler->getCompilerHandle(mData.getShaderType()); - mUniformRegisterMap = GetUniformRegisterMap(sh::GetUniformRegisterMap(compilerHandle)); + mUniformRegisterMap = GetUniformRegisterMap(ShGetUniformRegisterMap(compilerHandle)); for (const sh::InterfaceBlock &interfaceBlock : mData.getInterfaceBlocks()) { @@ -209,7 +201,8 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo { unsigned int index = static_cast<unsigned int>(-1); bool blockRegisterResult = - sh::GetInterfaceBlockRegister(compilerHandle, interfaceBlock.name, &index); + ShGetInterfaceBlockRegister(compilerHandle, interfaceBlock.name, &index); + UNUSED_ASSERTION_VARIABLE(blockRegisterResult); ASSERT(blockRegisterResult); mInterfaceBlockRegisterMap[interfaceBlock.name] = index; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/ShaderD3D.h b/gfx/angle/src/libANGLE/renderer/d3d/ShaderD3D.h index 587c12173..bf6215872 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/ShaderD3D.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/ShaderD3D.h @@ -28,8 +28,8 @@ class ShaderD3D : public ShaderImpl virtual ~ShaderD3D(); // ShaderImpl implementation - ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream, - std::string *sourcePath) override; + int prepareSourceAndReturnOptions(std::stringstream *sourceStream, + std::string *sourcePath) override; bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override; std::string getDebugInfo() const override; @@ -77,7 +77,7 @@ class ShaderD3D : public ShaderImpl mutable std::string mDebugInfo; std::map<std::string, unsigned int> mUniformRegisterMap; std::map<std::string, unsigned int> mInterfaceBlockRegisterMap; - ShCompileOptions mAdditionalOptions; + int mAdditionalOptions; }; } // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp b/gfx/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp index 8696ab0d7..3c02c4a68 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp @@ -26,8 +26,7 @@ SurfaceD3D::SurfaceD3D(const egl::SurfaceState &state, egl::Display *display, const egl::Config *config, EGLNativeWindowType window, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) : SurfaceImpl(state), mRenderer(renderer), @@ -42,39 +41,19 @@ SurfaceD3D::SurfaceD3D(const egl::SurfaceState &state, mWidth(static_cast<EGLint>(attribs.get(EGL_WIDTH, 0))), mHeight(static_cast<EGLint>(attribs.get(EGL_HEIGHT, 0))), mSwapInterval(1), - mShareHandle(0), - mD3DTexture(nullptr) + mShareHandle(reinterpret_cast<HANDLE *>(shareHandle)) { if (window != nullptr && !mFixedSize) { mWidth = -1; mHeight = -1; } - - switch (buftype) - { - case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE: - mShareHandle = static_cast<HANDLE>(clientBuffer); - break; - - case EGL_D3D_TEXTURE_ANGLE: - mD3DTexture = static_cast<IUnknown *>(clientBuffer); - ASSERT(mD3DTexture != nullptr); - mD3DTexture->AddRef(); - mRenderer->getD3DTextureInfo(mD3DTexture, &mWidth, &mHeight, &mRenderTargetFormat); - mDepthStencilFormat = GL_NONE; - break; - - default: - break; - } } SurfaceD3D::~SurfaceD3D() { releaseSwapChain(); SafeDelete(mNativeWindow); - SafeRelease(mD3DTexture); } void SurfaceD3D::releaseSwapChain() @@ -143,8 +122,8 @@ egl::Error SurfaceD3D::resetSwapChain() height = mHeight; } - mSwapChain = mRenderer->createSwapChain(mNativeWindow, mShareHandle, mD3DTexture, - mRenderTargetFormat, mDepthStencilFormat, mOrientation); + mSwapChain = mRenderer->createSwapChain(mNativeWindow, mShareHandle, mRenderTargetFormat, + mDepthStencilFormat, mOrientation); if (!mSwapChain) { return egl::Error(EGL_BAD_ALLOC); @@ -362,14 +341,7 @@ WindowSurfaceD3D::WindowSurfaceD3D(const egl::SurfaceState &state, const egl::Config *config, EGLNativeWindowType window, const egl::AttributeMap &attribs) - : SurfaceD3D(state, - renderer, - display, - config, - window, - 0, - static_cast<EGLClientBuffer>(0), - attribs) + : SurfaceD3D(state, renderer, display, config, window, static_cast<EGLClientBuffer>(0), attribs) { } @@ -381,16 +353,14 @@ PbufferSurfaceD3D::PbufferSurfaceD3D(const egl::SurfaceState &state, RendererD3D *renderer, egl::Display *display, const egl::Config *config, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) : SurfaceD3D(state, renderer, display, config, static_cast<EGLNativeWindowType>(0), - buftype, - clientBuffer, + shareHandle, attribs) { } diff --git a/gfx/angle/src/libANGLE/renderer/d3d/SurfaceD3D.h b/gfx/angle/src/libANGLE/renderer/d3d/SurfaceD3D.h index 768c60bd0..614b8f979 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/SurfaceD3D.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/SurfaceD3D.h @@ -61,8 +61,7 @@ class SurfaceD3D : public SurfaceImpl egl::Display *display, const egl::Config *config, EGLNativeWindowType window, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs); egl::Error swapRect(EGLint x, EGLint y, EGLint width, EGLint height); @@ -88,7 +87,6 @@ class SurfaceD3D : public SurfaceImpl EGLint mSwapInterval; HANDLE mShareHandle; - IUnknown *mD3DTexture; }; class WindowSurfaceD3D : public SurfaceD3D @@ -110,8 +108,7 @@ class PbufferSurfaceD3D : public SurfaceD3D RendererD3D *renderer, egl::Display *display, const egl::Config *config, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs); ~PbufferSurfaceD3D() override; }; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/SwapChainD3D.cpp b/gfx/angle/src/libANGLE/renderer/d3d/SwapChainD3D.cpp deleted file mode 100644 index de8534c3d..000000000 --- a/gfx/angle/src/libANGLE/renderer/d3d/SwapChainD3D.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2016 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. -// - -// SwapChainD3D.cpp: Defines a back-end specific class that hides the details of the -// implementation-specific swapchain. - -#include "libANGLE/renderer/d3d/SwapChainD3D.h" - -namespace rx -{ - -SwapChainD3D::SwapChainD3D(HANDLE shareHandle, - IUnknown *d3dTexture, - GLenum backBufferFormat, - GLenum depthBufferFormat) - : mOffscreenRenderTargetFormat(backBufferFormat), - mDepthBufferFormat(depthBufferFormat), - mShareHandle(shareHandle), - mD3DTexture(d3dTexture) -{ - if (mD3DTexture) - { - mD3DTexture->AddRef(); - } -} - -SwapChainD3D::~SwapChainD3D() -{ - SafeRelease(mD3DTexture); -} -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/d3d/SwapChainD3D.h b/gfx/angle/src/libANGLE/renderer/d3d/SwapChainD3D.h index f49204527..992c68bc5 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/SwapChainD3D.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/SwapChainD3D.h @@ -27,11 +27,14 @@ class RenderTargetD3D; class SwapChainD3D : angle::NonCopyable { public: - SwapChainD3D(HANDLE shareHandle, - IUnknown *d3dTexture, - GLenum backBufferFormat, - GLenum depthBufferFormat); - virtual ~SwapChainD3D(); + SwapChainD3D(HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) + : mOffscreenRenderTargetFormat(backBufferFormat), + mDepthBufferFormat(depthBufferFormat), + mShareHandle(shareHandle) + { + } + + virtual ~SwapChainD3D() {}; virtual EGLint resize(EGLint backbufferWidth, EGLint backbufferSize) = 0; virtual EGLint reset(EGLint backbufferWidth, EGLint backbufferHeight, EGLint swapInterval) = 0; @@ -52,8 +55,7 @@ class SwapChainD3D : angle::NonCopyable const GLenum mDepthBufferFormat; HANDLE mShareHandle; - IUnknown *mD3DTexture; }; -} // namespace rx +} #endif // LIBANGLE_RENDERER_D3D_SWAPCHAIND3D_H_ diff --git a/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp b/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp index 287700264..96e8e20ff 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp @@ -46,7 +46,12 @@ gl::Error GetUnpackPointer(const gl::PixelUnpackState &unpack, const uint8_t *pi BufferD3D *bufferD3D = GetImplAs<BufferD3D>(pixelBuffer); ASSERT(bufferD3D); const uint8_t *bufferData = NULL; - ANGLE_TRY(bufferD3D->getData(&bufferData)); + gl::Error error = bufferD3D->getData(&bufferData); + if (error.isError()) + { + return error; + } + *pointerOut = bufferData + offset; } else @@ -87,17 +92,25 @@ TextureD3D::~TextureD3D() gl::Error TextureD3D::getNativeTexture(TextureStorage **outStorage) { // ensure the underlying texture is created - ANGLE_TRY(initializeStorage(false)); + gl::Error error = initializeStorage(false); + if (error.isError()) + { + return error; + } if (mTexStorage) { - ANGLE_TRY(updateStorage()); + error = updateStorage(); + if (error.isError()) + { + return error; + } } ASSERT(outStorage); *outStorage = mTexStorage; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } GLint TextureD3D::getLevelZeroWidth() const @@ -182,24 +195,33 @@ gl::Error TextureD3D::setImageImpl(const gl::ImageIndex &index, // We no longer need the "GLenum format" parameter to TexImage to determine what data format "pixels" contains. // From our image internal format we know how many channels to expect, and "type" gives the format of pixel's components. const uint8_t *pixelData = NULL; - ANGLE_TRY(GetUnpackPointer(unpack, pixels, layerOffset, &pixelData)); + gl::Error error = GetUnpackPointer(unpack, pixels, layerOffset, &pixelData); + if (error.isError()) + { + return error; + } if (pixelData != nullptr) { if (shouldUseSetData(image)) { - ANGLE_TRY(mTexStorage->setData(index, image, NULL, type, unpack, pixelData)); + error = mTexStorage->setData(index, image, NULL, type, unpack, pixelData); } else { gl::Box fullImageArea(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth()); - ANGLE_TRY(image->loadData(fullImageArea, unpack, type, pixelData, index.is3D())); + error = image->loadData(fullImageArea, unpack, type, pixelData, index.is3D()); + } + + if (error.isError()) + { + return error; } mDirtyImages = true; } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D::subImage(const gl::ImageIndex &index, const gl::Box &area, GLenum format, GLenum type, @@ -207,7 +229,11 @@ gl::Error TextureD3D::subImage(const gl::ImageIndex &index, const gl::Box &area, { // CPU readback & copy where direct GPU copy is not supported const uint8_t *pixelData = NULL; - ANGLE_TRY(GetUnpackPointer(unpack, pixels, layerOffset, &pixelData)); + gl::Error error = GetUnpackPointer(unpack, pixels, layerOffset, &pixelData); + if (error.isError()) + { + return error; + } if (pixelData != NULL) { @@ -219,8 +245,18 @@ gl::Error TextureD3D::subImage(const gl::ImageIndex &index, const gl::Box &area, return mTexStorage->setData(index, image, &area, type, unpack, pixelData); } - ANGLE_TRY(image->loadData(area, unpack, type, pixelData, index.is3D())); - ANGLE_TRY(commitRegion(index, area)); + error = image->loadData(area, unpack, type, pixelData, index.is3D()); + if (error.isError()) + { + return error; + } + + error = commitRegion(index, area); + if (error.isError()) + { + return error; + } + mDirtyImages = true; } @@ -243,12 +279,20 @@ gl::Error TextureD3D::setCompressedImageImpl(const gl::ImageIndex &index, // We no longer need the "GLenum format" parameter to TexImage to determine what data format "pixels" contains. // From our image internal format we know how many channels to expect, and "type" gives the format of pixel's components. const uint8_t *pixelData = NULL; - ANGLE_TRY(GetUnpackPointer(unpack, pixels, layerOffset, &pixelData)); + gl::Error error = GetUnpackPointer(unpack, pixels, layerOffset, &pixelData); + if (error.isError()) + { + return error; + } if (pixelData != NULL) { gl::Box fullImageArea(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth()); - ANGLE_TRY(image->loadCompressedData(fullImageArea, pixelData)); + error = image->loadCompressedData(fullImageArea, pixelData); + if (error.isError()) + { + return error; + } mDirtyImages = true; } @@ -261,14 +305,22 @@ gl::Error TextureD3D::subImageCompressed(const gl::ImageIndex &index, const gl:: ptrdiff_t layerOffset) { const uint8_t *pixelData = NULL; - ANGLE_TRY(GetUnpackPointer(unpack, pixels, layerOffset, &pixelData)); + gl::Error error = GetUnpackPointer(unpack, pixels, layerOffset, &pixelData); + if (error.isError()) + { + return error; + } if (pixelData != NULL) { ImageD3D *image = getImage(index); ASSERT(image); - ANGLE_TRY(image->loadCompressedData(area, pixelData)); + error = image->loadCompressedData(area, pixelData); + if (error.isError()) + { + return error; + } mDirtyImages = true; } @@ -305,11 +357,13 @@ gl::Error TextureD3D::fastUnpackPixels(const gl::PixelUnpackState &unpack, const uintptr_t offset = reinterpret_cast<uintptr_t>(pixels); - ANGLE_TRY(mRenderer->fastCopyBufferToTexture(unpack, static_cast<unsigned int>(offset), - destRenderTarget, sizedInternalFormat, type, - destArea)); + gl::Error error = mRenderer->fastCopyBufferToTexture(unpack, static_cast<unsigned int>(offset), destRenderTarget, sizedInternalFormat, type, destArea); + if (error.isError()) + { + return error; + } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } GLint TextureD3D::creationLevels(GLsizei width, GLsizei height, GLsizei depth) const @@ -356,13 +410,23 @@ gl::Error TextureD3D::generateMipmap() const GLuint baseLevel = mState.getEffectiveBaseLevel(); const GLuint maxLevel = mState.getMipmapMaxLevel(); ASSERT(maxLevel > baseLevel); // Should be checked before calling this. + UNUSED_ASSERTION_VARIABLE(baseLevel); if (mTexStorage && mRenderer->getWorkarounds().zeroMaxLodWorkaround) { // Switch to using the mipmapped texture. TextureStorage *textureStorage = NULL; - ANGLE_TRY(getNativeTexture(&textureStorage)); - ANGLE_TRY(textureStorage->useLevelZeroWorkaroundTexture(false)); + gl::Error error = getNativeTexture(&textureStorage); + if (error.isError()) + { + return error; + } + + error = textureStorage->useLevelZeroWorkaroundTexture(false); + if (error.isError()) + { + return error; + } } // Set up proper mipmap chain in our Image array. @@ -370,15 +434,27 @@ gl::Error TextureD3D::generateMipmap() if (mTexStorage && mTexStorage->supportsNativeMipmapFunction()) { - ANGLE_TRY(updateStorage()); + gl::Error error = updateStorage(); + if (error.isError()) + { + return error; + } // Generate the mipmap chain using the ad-hoc DirectX function. - ANGLE_TRY(mRenderer->generateMipmapUsingD3D(mTexStorage, mState)); + error = mRenderer->generateMipmapUsingD3D(mTexStorage, mState); + if (error.isError()) + { + return error; + } } else { // Generate the mipmap chain, one level at a time. - ANGLE_TRY(generateMipmapUsingImages(maxLevel)); + gl::Error error = generateMipmapUsingImages(maxLevel); + if (error.isError()) + { + return error; + } } return gl::Error(GL_NO_ERROR); @@ -402,12 +478,20 @@ gl::Error TextureD3D::generateMipmapUsingImages(const GLuint maxLevel) gl::ImageIndex srcIndex = getImageIndex(mBaseLevel, layer); ImageD3D *image = getImage(srcIndex); - ANGLE_TRY(image->copyFromTexStorage(srcIndex, mTexStorage)); + gl::Error error = image->copyFromTexStorage(srcIndex, mTexStorage); + if (error.isError()) + { + return error; + } } } else { - ANGLE_TRY(updateStorage()); + gl::Error error = updateStorage(); + if (error.isError()) + { + return error; + } } } @@ -430,12 +514,20 @@ gl::Error TextureD3D::generateMipmapUsingImages(const GLuint maxLevel) if (renderableStorage) { // GPU-side mipmapping - ANGLE_TRY(mTexStorage->generateMipmap(sourceIndex, destIndex)); + gl::Error error = mTexStorage->generateMipmap(sourceIndex, destIndex); + if (error.isError()) + { + return error; + } } else { // CPU-side mipmapping - ANGLE_TRY(mRenderer->generateMipmap(getImage(destIndex), getImage(sourceIndex))); + gl::Error error = mRenderer->generateMipmap(getImage(destIndex), getImage(sourceIndex)); + if (error.isError()) + { + return error; + } } } } @@ -445,7 +537,7 @@ gl::Error TextureD3D::generateMipmapUsingImages(const GLuint maxLevel) updateStorage(); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } bool TextureD3D::isBaseImageZeroSize() const @@ -477,7 +569,11 @@ bool TextureD3D::isBaseImageZeroSize() const gl::Error TextureD3D::ensureRenderTarget() { - ANGLE_TRY(initializeStorage(true)); + gl::Error error = initializeStorage(true); + if (error.isError()) + { + return error; + } if (!isBaseImageZeroSize()) { @@ -485,9 +581,13 @@ gl::Error TextureD3D::ensureRenderTarget() if (!mTexStorage->isRenderTarget()) { TextureStorage *newRenderTargetStorage = NULL; - ANGLE_TRY(createCompleteStorage(true, &newRenderTargetStorage)); + error = createCompleteStorage(true, &newRenderTargetStorage); + if (error.isError()) + { + return error; + } - gl::Error error = mTexStorage->copyToStorage(newRenderTargetStorage); + error = mTexStorage->copyToStorage(newRenderTargetStorage); if (error.isError()) { SafeDelete(newRenderTargetStorage); @@ -503,7 +603,7 @@ gl::Error TextureD3D::ensureRenderTarget() } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } bool TextureD3D::canCreateRenderTargetForImage(const gl::ImageIndex &index) const @@ -519,11 +619,16 @@ gl::Error TextureD3D::commitRegion(const gl::ImageIndex &index, const gl::Box &r { ASSERT(isValidIndex(index)); ImageD3D *image = getImage(index); - ANGLE_TRY(image->copyToStorage(mTexStorage, index, region)); + gl::Error error = image->copyToStorage(mTexStorage, index, region); + if (error.isError()) + { + return error; + } + image->markClean(); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D::getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target, @@ -558,11 +663,6 @@ void TextureD3D::setBaseLevel(GLuint baseLevel) } } -void TextureD3D::syncState(const gl::Texture::DirtyBits &dirtyBits) -{ - // TODO(geofflang): Use dirty bits -} - TextureD3D_2D::TextureD3D_2D(const gl::TextureState &state, RendererD3D *renderer) : TextureD3D(state, renderer) { @@ -679,7 +779,7 @@ gl::Error TextureD3D_2D::setImage(GLenum target, ANGLE_TRY(setImageImpl(index, type, unpack, pixels, 0)); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D_2D::setSubImage(GLenum target, @@ -868,26 +968,6 @@ gl::Error TextureD3D_2D::copySubTexture(const gl::Offset &destOffset, return gl::NoError(); } -gl::Error TextureD3D_2D::copyCompressedTexture(const gl::Texture *source) -{ - GLenum sourceTarget = source->getTarget(); - GLint sourceLevel = 0; - - GLint destLevel = 0; - - GLenum sizedInternalFormat = source->getFormat(sourceTarget, sourceLevel).asSized(); - gl::Extents size(static_cast<int>(source->getWidth(sourceTarget, sourceLevel)), - static_cast<int>(source->getHeight(sourceTarget, sourceLevel)), 1); - redefineImage(destLevel, sizedInternalFormat, size, false); - - ANGLE_TRY(initializeStorage(false)); - ASSERT(mTexStorage); - - ANGLE_TRY(mRenderer->copyCompressedTexture(source, sourceLevel, mTexStorage, destLevel)); - - return gl::NoError(); -} - gl::Error TextureD3D_2D::setStorage(GLenum target, size_t levels, GLenum internalFormat, const gl::Extents &size) { ASSERT(GL_TEXTURE_2D && size.depth == 1); @@ -917,11 +997,16 @@ gl::Error TextureD3D_2D::setStorage(GLenum target, size_t levels, GLenum interna return error; } - ANGLE_TRY(updateStorage()); + error = updateStorage(); + + if (error.isError()) + { + return error; + } mImmutable = true; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void TextureD3D_2D::bindTexImage(egl::Surface *surface) @@ -1006,8 +1091,17 @@ gl::Error TextureD3D_2D::getRenderTarget(const gl::ImageIndex &index, RenderTarg ASSERT(!index.hasLayer()); // ensure the underlying texture is created - ANGLE_TRY(ensureRenderTarget()); - ANGLE_TRY(updateStorageLevel(index.mipIndex)); + gl::Error error = ensureRenderTarget(); + if (error.isError()) + { + return error; + } + + error = updateStorageLevel(index.mipIndex); + if (error.isError()) + { + return error; + } return mTexStorage->getRenderTarget(index, outRT); } @@ -1082,9 +1176,13 @@ gl::Error TextureD3D_2D::initializeStorage(bool renderTarget) bool createRenderTarget = (renderTarget || IsRenderTargetUsage(mState.getUsage())); TextureStorage *storage = NULL; - ANGLE_TRY(createCompleteStorage(createRenderTarget, &storage)); + gl::Error error = createCompleteStorage(createRenderTarget, &storage); + if (error.isError()) + { + return error; + } - gl::Error error = setCompleteTexStorage(storage); + error = setCompleteTexStorage(storage); if (error.isError()) { SafeDelete(storage); @@ -1094,7 +1192,11 @@ gl::Error TextureD3D_2D::initializeStorage(bool renderTarget) ASSERT(mTexStorage); // flush image data to the storage - ANGLE_TRY(updateStorage()); + error = updateStorage(); + if (error.isError()) + { + return error; + } return gl::Error(GL_NO_ERROR); } @@ -1134,7 +1236,11 @@ gl::Error TextureD3D_2D::setCompleteTexStorage(TextureStorage *newCompleteTexSto { for (int level = 0; level < newCompleteTexStorage->getLevelCount(); level++) { - ANGLE_TRY(mImageArray[level]->setManagedSurface2D(newCompleteTexStorage, level)); + gl::Error error = mImageArray[level]->setManagedSurface2D(newCompleteTexStorage, level); + if (error.isError()) + { + return error; + } } } @@ -1143,7 +1249,7 @@ gl::Error TextureD3D_2D::setCompleteTexStorage(TextureStorage *newCompleteTexSto mDirtyImages = true; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D_2D::updateStorage() @@ -1154,11 +1260,15 @@ gl::Error TextureD3D_2D::updateStorage() { if (mImageArray[level]->isDirty() && isLevelComplete(level)) { - ANGLE_TRY(updateStorageLevel(level)); + gl::Error error = updateStorageLevel(level); + if (error.isError()) + { + return error; + } } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D_2D::updateStorageLevel(int level) @@ -1170,10 +1280,14 @@ gl::Error TextureD3D_2D::updateStorageLevel(int level) { gl::ImageIndex index = gl::ImageIndex::Make2D(level); gl::Box region(0, 0, 0, getWidth(level), getHeight(level), 1); - ANGLE_TRY(commitRegion(index, region)); + gl::Error error = commitRegion(index, region); + if (error.isError()) + { + return error; + } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void TextureD3D_2D::redefineImage(size_t level, @@ -1352,7 +1466,12 @@ gl::Error TextureD3D_Cube::setCompressedSubImage(GLenum target, size_t level, co gl::ImageIndex index = gl::ImageIndex::MakeCube(target, static_cast<GLint>(level)); - ANGLE_TRY(TextureD3D::subImageCompressed(index, area, format, unpack, pixels, 0)); + gl::Error error = TextureD3D::subImageCompressed(index, area, format, unpack, pixels, 0); + if (error.isError()) + { + return error; + } + return commitRegion(index, area); } @@ -1377,21 +1496,34 @@ gl::Error TextureD3D_Cube::copyImage(GLenum target, // so we should use the non-rendering copy path. if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround) { - ANGLE_TRY( - mImageArray[faceIndex][level]->copyFromFramebuffer(destOffset, sourceArea, source)); + gl::Error error = + mImageArray[faceIndex][level]->copyFromFramebuffer(destOffset, sourceArea, source); + if (error.isError()) + { + return error; + } + mDirtyImages = true; } else { - ANGLE_TRY(ensureRenderTarget()); + gl::Error error = ensureRenderTarget(); + if (error.isError()) + { + return error; + } + mImageArray[faceIndex][level]->markClean(); ASSERT(size.width == size.height); if (size.width > 0 && isValidFaceLevel(faceIndex, level)) { - ANGLE_TRY(mRenderer->copyImageCube(source, sourceArea, internalFormat, destOffset, - mTexStorage, target, level)); + error = mRenderer->copyImageCube(source, sourceArea, internalFormat, destOffset, mTexStorage, target, level); + if (error.isError()) + { + return error; + } } } @@ -1424,13 +1556,26 @@ gl::Error TextureD3D_Cube::copySubImage(GLenum target, } else { - ANGLE_TRY(ensureRenderTarget()); + gl::Error error = ensureRenderTarget(); + if (error.isError()) + { + return error; + } + if (isValidFaceLevel(faceIndex, level)) { - ANGLE_TRY(updateStorageFaceLevel(faceIndex, level)); - ANGLE_TRY(mRenderer->copyImageCube( - source, sourceArea, gl::GetInternalFormatInfo(getBaseLevelInternalFormat()).format, - destOffset, mTexStorage, target, level)); + error = updateStorageFaceLevel(faceIndex, level); + if (error.isError()) + { + return error; + } + + error = mRenderer->copyImageCube(source, sourceArea, gl::GetInternalFormatInfo(getBaseLevelInternalFormat()).format, + destOffset, mTexStorage, target, level); + if (error.isError()) + { + return error; + } } } @@ -1472,11 +1617,16 @@ gl::Error TextureD3D_Cube::setStorage(GLenum target, size_t levels, GLenum inter return error; } - ANGLE_TRY(updateStorage()); + error = updateStorage(); + + if (error.isError()) + { + return error; + } mImmutable = true; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } // Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81. @@ -1539,8 +1689,17 @@ gl::Error TextureD3D_Cube::getRenderTarget(const gl::ImageIndex &index, RenderTa ASSERT(gl::IsCubeMapTextureTarget(index.type)); // ensure the underlying texture is created - ANGLE_TRY(ensureRenderTarget()); - ANGLE_TRY(updateStorageFaceLevel(index.layerIndex, index.mipIndex)); + gl::Error error = ensureRenderTarget(); + if (error.isError()) + { + return error; + } + + error = updateStorageFaceLevel(index.layerIndex, index.mipIndex); + if (error.isError()) + { + return error; + } return mTexStorage->getRenderTarget(index, outRT); } @@ -1550,21 +1709,25 @@ gl::Error TextureD3D_Cube::initializeStorage(bool renderTarget) // Only initialize the first time this texture is used as a render target or shader resource if (mTexStorage) { - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } // do not attempt to create storage for nonexistant data if (!isFaceLevelComplete(0, getBaseLevel())) { - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } bool createRenderTarget = (renderTarget || IsRenderTargetUsage(mState.getUsage())); TextureStorage *storage = NULL; - ANGLE_TRY(createCompleteStorage(createRenderTarget, &storage)); + gl::Error error = createCompleteStorage(createRenderTarget, &storage); + if (error.isError()) + { + return error; + } - gl::Error error = setCompleteTexStorage(storage); + error = setCompleteTexStorage(storage); if (error.isError()) { SafeDelete(storage); @@ -1574,9 +1737,13 @@ gl::Error TextureD3D_Cube::initializeStorage(bool renderTarget) ASSERT(mTexStorage); // flush image data to the storage - ANGLE_TRY(updateStorage()); + error = updateStorage(); + if (error.isError()) + { + return error; + } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D_Cube::createCompleteStorage(bool renderTarget, TextureStorage **outTexStorage) const @@ -1617,8 +1784,11 @@ gl::Error TextureD3D_Cube::setCompleteTexStorage(TextureStorage *newCompleteTexS { for (int level = 0; level < newCompleteTexStorage->getLevelCount(); level++) { - ANGLE_TRY(mImageArray[faceIndex][level]->setManagedSurfaceCube( - newCompleteTexStorage, faceIndex, level)); + gl::Error error = mImageArray[faceIndex][level]->setManagedSurfaceCube(newCompleteTexStorage, faceIndex, level); + if (error.isError()) + { + return error; + } } } } @@ -1640,12 +1810,16 @@ gl::Error TextureD3D_Cube::updateStorage() { if (mImageArray[face][level]->isDirty() && isFaceLevelComplete(face, level)) { - ANGLE_TRY(updateStorageFaceLevel(face, level)); + gl::Error error = updateStorageFaceLevel(face, level); + if (error.isError()) + { + return error; + } } } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } bool TextureD3D_Cube::isValidFaceLevel(int faceIndex, int level) const @@ -1713,10 +1887,14 @@ gl::Error TextureD3D_Cube::updateStorageFaceLevel(int faceIndex, int level) GLenum faceTarget = gl::LayerIndexToCubeMapTextureTarget(faceIndex); gl::ImageIndex index = gl::ImageIndex::MakeCube(faceTarget, level); gl::Box region(0, 0, 0, image->getWidth(), image->getHeight(), 1); - ANGLE_TRY(commitRegion(index, region)); + gl::Error error = commitRegion(index, region); + if (error.isError()) + { + return error; + } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void TextureD3D_Cube::redefineImage(int faceIndex, GLint level, GLenum internalformat, const gl::Extents &size) @@ -1882,12 +2060,19 @@ gl::Error TextureD3D_3D::setImage(GLenum target, { // Will try to create RT storage if it does not exist RenderTargetD3D *destRenderTarget = NULL; - ANGLE_TRY(getRenderTarget(index, &destRenderTarget)); + gl::Error error = getRenderTarget(index, &destRenderTarget); + if (error.isError()) + { + return error; + } gl::Box destArea(0, 0, 0, getWidth(level), getHeight(level), getDepth(level)); - ANGLE_TRY(fastUnpackPixels(unpack, pixels, destArea, sizedInternalFormat, type, - destRenderTarget)); + error = fastUnpackPixels(unpack, pixels, destArea, sizedInternalFormat, type, destRenderTarget); + if (error.isError()) + { + return error; + } // Ensure we don't overwrite our newly initialized data mImageArray[level]->markClean(); @@ -1897,7 +2082,11 @@ gl::Error TextureD3D_3D::setImage(GLenum target, if (!fastUnpacked) { - ANGLE_TRY(setImageImpl(index, type, unpack, pixels, 0)); + gl::Error error = setImageImpl(index, type, unpack, pixels, 0); + if (error.isError()) + { + return error; + } } return gl::Error(GL_NO_ERROR); @@ -1920,7 +2109,12 @@ gl::Error TextureD3D_3D::setSubImage(GLenum target, if (isFastUnpackable(unpack, getInternalFormat(level)) && isLevelComplete(level)) { RenderTargetD3D *destRenderTarget = NULL; - ANGLE_TRY(getRenderTarget(index, &destRenderTarget)); + gl::Error error = getRenderTarget(index, &destRenderTarget); + if (error.isError()) + { + return error; + } + ASSERT(!mImageArray[level]->isDirty()); return fastUnpackPixels(unpack, pixels, area, getInternalFormat(level), type, destRenderTarget); @@ -1955,7 +2149,12 @@ gl::Error TextureD3D_3D::setCompressedSubImage(GLenum target, size_t level, cons ASSERT(target == GL_TEXTURE_3D); gl::ImageIndex index = gl::ImageIndex::Make3D(static_cast<GLint>(level)); - ANGLE_TRY(TextureD3D::subImageCompressed(index, area, format, unpack, pixels, 0)); + gl::Error error = TextureD3D::subImageCompressed(index, area, format, unpack, pixels, 0); + if (error.isError()) + { + return error; + } + return commitRegion(index, area); } @@ -1979,18 +2178,37 @@ gl::Error TextureD3D_3D::copySubImage(GLenum target, if (canCreateRenderTargetForImage(index)) { - ANGLE_TRY(mImageArray[level]->copyFromFramebuffer(destOffset, sourceArea, source)); + gl::Error error = mImageArray[level]->copyFromFramebuffer(destOffset, sourceArea, source); + if (error.isError()) + { + return error; + } + mDirtyImages = true; } else { - ANGLE_TRY(ensureRenderTarget()); + gl::Error error = ensureRenderTarget(); + if (error.isError()) + { + return error; + } + if (isValidLevel(level)) { - ANGLE_TRY(updateStorageLevel(level)); - ANGLE_TRY(mRenderer->copyImage3D( - source, sourceArea, gl::GetInternalFormatInfo(getBaseLevelInternalFormat()).format, - destOffset, mTexStorage, level)); + error = updateStorageLevel(level); + if (error.isError()) + { + return error; + } + + error = mRenderer->copyImage3D(source, sourceArea, + gl::GetInternalFormatInfo(getBaseLevelInternalFormat()).format, + destOffset, mTexStorage, level); + if (error.isError()) + { + return error; + } } } @@ -2027,11 +2245,16 @@ gl::Error TextureD3D_3D::setStorage(GLenum target, size_t levels, GLenum interna return error; } - ANGLE_TRY(updateStorage()); + error = updateStorage(); + + if (error.isError()) + { + return error; + } mImmutable = true; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void TextureD3D_3D::bindTexImage(egl::Surface *surface) @@ -2062,15 +2285,27 @@ void TextureD3D_3D::initMipmapImages() gl::Error TextureD3D_3D::getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT) { // ensure the underlying texture is created - ANGLE_TRY(ensureRenderTarget()); + gl::Error error = ensureRenderTarget(); + if (error.isError()) + { + return error; + } if (index.hasLayer()) { - ANGLE_TRY(updateStorage()); + error = updateStorage(); + if (error.isError()) + { + return error; + } } else { - ANGLE_TRY(updateStorageLevel(index.mipIndex)); + error = updateStorageLevel(index.mipIndex); + if (error.isError()) + { + return error; + } } return mTexStorage->getRenderTarget(index, outRT); @@ -2093,9 +2328,13 @@ gl::Error TextureD3D_3D::initializeStorage(bool renderTarget) bool createRenderTarget = (renderTarget || IsRenderTargetUsage(mState.getUsage())); TextureStorage *storage = NULL; - ANGLE_TRY(createCompleteStorage(createRenderTarget, &storage)); + gl::Error error = createCompleteStorage(createRenderTarget, &storage); + if (error.isError()) + { + return error; + } - gl::Error error = setCompleteTexStorage(storage); + error = setCompleteTexStorage(storage); if (error.isError()) { SafeDelete(storage); @@ -2105,9 +2344,13 @@ gl::Error TextureD3D_3D::initializeStorage(bool renderTarget) ASSERT(mTexStorage); // flush image data to the storage - ANGLE_TRY(updateStorage()); + error = updateStorage(); + if (error.isError()) + { + return error; + } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D_3D::createCompleteStorage(bool renderTarget, TextureStorage **outStorage) const @@ -2137,7 +2380,7 @@ gl::Error TextureD3D_3D::setCompleteTexStorage(TextureStorage *newCompleteTexSto // We do not support managed 3D storage, as that is D3D9/ES2-only ASSERT(!mTexStorage->isManaged()); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D_3D::updateStorage() @@ -2148,11 +2391,15 @@ gl::Error TextureD3D_3D::updateStorage() { if (mImageArray[level]->isDirty() && isLevelComplete(level)) { - ANGLE_TRY(updateStorageLevel(level)); + gl::Error error = updateStorageLevel(level); + if (error.isError()) + { + return error; + } } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } bool TextureD3D_3D::isValidLevel(int level) const @@ -2222,10 +2469,14 @@ gl::Error TextureD3D_3D::updateStorageLevel(int level) { gl::ImageIndex index = gl::ImageIndex::Make3D(level); gl::Box region(0, 0, 0, getWidth(level), getHeight(level), getDepth(level)); - ANGLE_TRY(commitRegion(index, region)); + gl::Error error = commitRegion(index, region); + if (error.isError()) + { + return error; + } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void TextureD3D_3D::redefineImage(GLint level, GLenum internalformat, const gl::Extents &size) @@ -2234,12 +2485,12 @@ void TextureD3D_3D::redefineImage(GLint level, GLenum internalformat, const gl:: const int storageWidth = std::max(1, getLevelZeroWidth() >> level); const int storageHeight = std::max(1, getLevelZeroHeight() >> level); const int storageDepth = std::max(1, getLevelZeroDepth() >> level); - const GLenum storageFormat = getBaseLevelInternalFormat(); mImageArray[level]->redefine(GL_TEXTURE_3D, internalformat, size, false); if (mTexStorage) { + const GLenum storageFormat = getBaseLevelInternalFormat(); const int storageLevels = mTexStorage->getLevelCount(); if ((level >= storageLevels && storageLevels != 0) || @@ -2366,25 +2617,29 @@ gl::Error TextureD3D_2DArray::setImage(GLenum target, { ASSERT(target == GL_TEXTURE_2D_ARRAY); - GLint level = static_cast<GLint>(imageLevel); GLenum sizedInternalFormat = gl::GetSizedInternalFormat(internalFormat, type); + + GLint level = static_cast<GLint>(imageLevel); redefineImage(level, sizedInternalFormat, size); - const auto sizedInputFormat = gl::GetSizedInternalFormat(format, type); - const gl::InternalFormat &inputFormat = gl::GetInternalFormatInfo(sizedInputFormat); - GLsizei inputDepthPitch = 0; - ANGLE_TRY_RESULT(inputFormat.computeDepthPitch(size.width, size.height, unpack.alignment, - unpack.rowLength, unpack.imageHeight), + const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(sizedInternalFormat); + GLsizei inputDepthPitch = 0; + ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, size.width, size.height, unpack.alignment, + unpack.rowLength, unpack.imageHeight), inputDepthPitch); for (int i = 0; i < size.depth; i++) { const ptrdiff_t layerOffset = (inputDepthPitch * i); gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, i); - ANGLE_TRY(setImageImpl(index, type, unpack, pixels, layerOffset)); + gl::Error error = setImageImpl(index, type, unpack, pixels, layerOffset); + if (error.isError()) + { + return error; + } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D_2DArray::setSubImage(GLenum target, @@ -2396,12 +2651,11 @@ gl::Error TextureD3D_2DArray::setSubImage(GLenum target, const uint8_t *pixels) { ASSERT(target == GL_TEXTURE_2D_ARRAY); - GLint level = static_cast<GLint>(imageLevel); - const auto sizedInputFormat = gl::GetSizedInternalFormat(format, type); - const gl::InternalFormat &inputFormat = gl::GetInternalFormatInfo(sizedInputFormat); - GLsizei inputDepthPitch = 0; - ANGLE_TRY_RESULT(inputFormat.computeDepthPitch(area.width, area.height, unpack.alignment, - unpack.rowLength, unpack.imageHeight), + GLint level = static_cast<GLint>(imageLevel); + const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(getInternalFormat(level)); + GLsizei inputDepthPitch = 0; + ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, area.width, area.height, unpack.alignment, + unpack.rowLength, unpack.imageHeight), inputDepthPitch); for (int i = 0; i < area.depth; i++) @@ -2412,11 +2666,14 @@ gl::Error TextureD3D_2DArray::setSubImage(GLenum target, gl::Box layerArea(area.x, area.y, 0, area.width, area.height, 1); gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, layer); - ANGLE_TRY( - TextureD3D::subImage(index, layerArea, format, type, unpack, pixels, layerOffset)); + gl::Error error = TextureD3D::subImage(index, layerArea, format, type, unpack, pixels, layerOffset); + if (error.isError()) + { + return error; + } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D_2DArray::setCompressedImage(GLenum target, @@ -2436,7 +2693,7 @@ gl::Error TextureD3D_2DArray::setCompressedImage(GLenum target, const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat); GLsizei inputDepthPitch = 0; ANGLE_TRY_RESULT( - formatInfo.computeDepthPitch(size.width, size.height, 1, 0, 0), + formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, size.width, size.height, 1, 0, 0), inputDepthPitch); for (int i = 0; i < size.depth; i++) @@ -2444,10 +2701,14 @@ gl::Error TextureD3D_2DArray::setCompressedImage(GLenum target, const ptrdiff_t layerOffset = (inputDepthPitch * i); gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, i); - ANGLE_TRY(setCompressedImageImpl(index, unpack, pixels, layerOffset)); + gl::Error error = setCompressedImageImpl(index, unpack, pixels, layerOffset); + if (error.isError()) + { + return error; + } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D_2DArray::setCompressedSubImage(GLenum target, size_t level, const gl::Box &area, GLenum format, @@ -2458,7 +2719,7 @@ gl::Error TextureD3D_2DArray::setCompressedSubImage(GLenum target, size_t level, const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format); GLsizei inputDepthPitch = 0; ANGLE_TRY_RESULT( - formatInfo.computeDepthPitch(area.width, area.height, 1, 0, 0), + formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1, 0, 0), inputDepthPitch); for (int i = 0; i < area.depth; i++) @@ -2469,9 +2730,17 @@ gl::Error TextureD3D_2DArray::setCompressedSubImage(GLenum target, size_t level, gl::Box layerArea(area.x, area.y, 0, area.width, area.height, 1); gl::ImageIndex index = gl::ImageIndex::Make2DArray(static_cast<GLint>(level), layer); - ANGLE_TRY( - TextureD3D::subImageCompressed(index, layerArea, format, unpack, pixels, layerOffset)); - ANGLE_TRY(commitRegion(index, layerArea)); + gl::Error error = TextureD3D::subImageCompressed(index, layerArea, format, unpack, pixels, layerOffset); + if (error.isError()) + { + return error; + } + + error = commitRegion(index, layerArea); + if (error.isError()) + { + return error; + } } return gl::Error(GL_NO_ERROR); @@ -2498,21 +2767,39 @@ gl::Error TextureD3D_2DArray::copySubImage(GLenum target, if (canCreateRenderTargetForImage(index)) { gl::Offset destLayerOffset(destOffset.x, destOffset.y, 0); - ANGLE_TRY(mImageArray[level][destOffset.z]->copyFromFramebuffer(destLayerOffset, sourceArea, - source)); + gl::Error error = mImageArray[level][destOffset.z]->copyFromFramebuffer(destLayerOffset, + sourceArea, source); + if (error.isError()) + { + return error; + } + mDirtyImages = true; } else { - ANGLE_TRY(ensureRenderTarget()); + gl::Error error = ensureRenderTarget(); + if (error.isError()) + { + return error; + } if (isValidLevel(level)) { - ANGLE_TRY(updateStorageLevel(level)); - ANGLE_TRY(mRenderer->copyImage2DArray( + error = updateStorageLevel(level); + if (error.isError()) + { + return error; + } + + error = mRenderer->copyImage2DArray( source, sourceArea, gl::GetInternalFormatInfo(getInternalFormat(getBaseLevel())).format, destOffset, - mTexStorage, level)); + mTexStorage, level); + if (error.isError()) + { + return error; + } } } return gl::Error(GL_NO_ERROR); @@ -2558,11 +2845,16 @@ gl::Error TextureD3D_2DArray::setStorage(GLenum target, size_t levels, GLenum in return error; } - ANGLE_TRY(updateStorage()); + error = updateStorage(); + + if (error.isError()) + { + return error; + } mImmutable = true; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void TextureD3D_2DArray::bindTexImage(egl::Surface *surface) @@ -2599,8 +2891,18 @@ void TextureD3D_2DArray::initMipmapImages() gl::Error TextureD3D_2DArray::getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT) { // ensure the underlying texture is created - ANGLE_TRY(ensureRenderTarget()); - ANGLE_TRY(updateStorageLevel(index.mipIndex)); + gl::Error error = ensureRenderTarget(); + if (error.isError()) + { + return error; + } + + error = updateStorageLevel(index.mipIndex); + if (error.isError()) + { + return error; + } + return mTexStorage->getRenderTarget(index, outRT); } @@ -2609,21 +2911,25 @@ gl::Error TextureD3D_2DArray::initializeStorage(bool renderTarget) // Only initialize the first time this texture is used as a render target or shader resource if (mTexStorage) { - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } // do not attempt to create storage for nonexistant data if (!isLevelComplete(getBaseLevel())) { - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } bool createRenderTarget = (renderTarget || IsRenderTargetUsage(mState.getUsage())); - TextureStorage *storage = nullptr; - ANGLE_TRY(createCompleteStorage(createRenderTarget, &storage)); + TextureStorage *storage = NULL; + gl::Error error = createCompleteStorage(createRenderTarget, &storage); + if (error.isError()) + { + return error; + } - gl::Error error = setCompleteTexStorage(storage); + error = setCompleteTexStorage(storage); if (error.isError()) { SafeDelete(storage); @@ -2633,9 +2939,13 @@ gl::Error TextureD3D_2DArray::initializeStorage(bool renderTarget) ASSERT(mTexStorage); // flush image data to the storage - ANGLE_TRY(updateStorage()); + error = updateStorage(); + if (error.isError()) + { + return error; + } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D_2DArray::createCompleteStorage(bool renderTarget, TextureStorage **outStorage) const @@ -2653,7 +2963,7 @@ gl::Error TextureD3D_2DArray::createCompleteStorage(bool renderTarget, TextureSt // TODO(geofflang): Verify storage creation succeeds *outStorage = mRenderer->createTextureStorage2DArray(internalFormat, renderTarget, width, height, depth, levels); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D_2DArray::setCompleteTexStorage(TextureStorage *newCompleteTexStorage) @@ -2665,7 +2975,7 @@ gl::Error TextureD3D_2DArray::setCompleteTexStorage(TextureStorage *newCompleteT // We do not support managed 2D array storage, as managed storage is ES2/D3D9 only ASSERT(!mTexStorage->isManaged()); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureD3D_2DArray::updateStorage() @@ -2676,11 +2986,15 @@ gl::Error TextureD3D_2DArray::updateStorage() { if (isLevelComplete(level)) { - ANGLE_TRY(updateStorageLevel(level)); + gl::Error error = updateStorageLevel(level); + if (error.isError()) + { + return error; + } } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } bool TextureD3D_2DArray::isValidLevel(int level) const @@ -2759,7 +3073,11 @@ gl::Error TextureD3D_2DArray::updateStorageLevel(int level) { gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, layer); gl::Box region(0, 0, 0, getWidth(level), getHeight(level), 1); - ANGLE_TRY(commitRegion(index, region)); + gl::Error error = commitRegion(index, region); + if (error.isError()) + { + return error; + } } } @@ -3083,4 +3401,4 @@ void TextureD3D_External::markAllImagesDirty() { UNREACHABLE(); } -} // namespace rx +} diff --git a/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.h b/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.h index 99343632a..7a8cad980 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.h @@ -69,8 +69,6 @@ class TextureD3D : public TextureImpl void setBaseLevel(GLuint baseLevel) override; - void syncState(const gl::Texture::DirtyBits &dirtyBits) override; - protected: gl::Error setImageImpl(const gl::ImageIndex &index, GLenum type, @@ -172,7 +170,6 @@ class TextureD3D_2D : public TextureD3D bool unpackPremultiplyAlpha, bool unpackUnmultiplyAlpha, const gl::Texture *source) override; - gl::Error copyCompressedTexture(const gl::Texture *source) override; gl::Error setStorage(GLenum target, size_t levels, GLenum internalFormat, const gl::Extents &size) override; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/VaryingPacking.cpp b/gfx/angle/src/libANGLE/renderer/d3d/VaryingPacking.cpp index eea85fea7..0bd783414 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/VaryingPacking.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/VaryingPacking.cpp @@ -271,37 +271,33 @@ bool VaryingPacking::packVaryings(gl::InfoLog &infoLog, continue; } - bool found = false; for (const PackedVarying &packedVarying : packedVaryings) { const auto &varying = *packedVarying.varying; // Make sure transform feedback varyings aren't optimized out. - if (uniqueVaryingNames.count(transformFeedbackVaryingName) > 0) + if (uniqueVaryingNames.count(transformFeedbackVaryingName) == 0) { - found = true; - break; - } - - if (transformFeedbackVaryingName == varying.name) - { - if (!packVarying(packedVarying)) + bool found = false; + if (transformFeedbackVaryingName == varying.name) + { + if (!packVarying(packedVarying)) + { + infoLog << "Could not pack varying " << varying.name; + return false; + } + + found = true; + break; + } + if (!found) { - infoLog << "Could not pack varying " << varying.name; + infoLog << "Transform feedback varying " << transformFeedbackVaryingName + << " does not exist in the vertex shader."; return false; } - - found = true; - break; } } - - if (!found) - { - infoLog << "Transform feedback varying " << transformFeedbackVaryingName - << " does not exist in the vertex shader."; - return false; - } } // Sort the packed register list diff --git a/gfx/angle/src/libANGLE/renderer/d3d/VertexDataManager.cpp b/gfx/angle/src/libANGLE/renderer/d3d/VertexDataManager.cpp index 89dd4faf2..fff16e63a 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/VertexDataManager.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/VertexDataManager.cpp @@ -431,6 +431,7 @@ gl::Error VertexDataManager::reserveSpaceForAttrib(const TranslatedAttribute &tr gl::Buffer *buffer = attrib.buffer.get(); BufferD3D *bufferD3D = buffer ? GetImplAs<BufferD3D>(buffer) : nullptr; ASSERT(!bufferD3D || bufferD3D->getStaticVertexBuffer(attrib) == nullptr); + UNUSED_ASSERTION_VARIABLE(bufferD3D); size_t totalCount = ComputeVertexAttributeElementCount(attrib, count, instances); ASSERT(!bufferD3D || diff --git a/gfx/angle/src/libANGLE/renderer/d3d/WorkaroundsD3D.h b/gfx/angle/src/libANGLE/renderer/d3d/WorkaroundsD3D.h index ede929ce8..a2faf71d9 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/WorkaroundsD3D.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/WorkaroundsD3D.h @@ -67,43 +67,19 @@ struct WorkaroundsD3D // Some drivers (NVIDIA) do not take into account the base level of the texture in the results // of the HLSL GetDimensions builtin. bool getDimensionsIgnoresBaseLevel = false; + + // In the Intel driver, data with format DXGI_FORMAT_B5G6R5_UNORM will be parsed incorrectly. + // This workaroud will disable B5G6R5 support when it's Intel's driver. By default, we will + // use R8G8B8A8 as format. + bool disableB5G6R5Support = false; // On some Intel drivers, HLSL's function texture.Load returns 0 when the parameter Location // is negative, even if the sum of Offset and Location is in range. This may cause errors when // translating GLSL's function texelFetchOffset into texture.Load, as it is valid for // texelFetchOffset to use negative texture coordinates as its parameter P when the sum of P - // and Offset is in range. To work around this, we translate texelFetchOffset into texelFetch + // and Offset is in range. To work around this, we translatie texelFetchOffset into texelFetch // by adding Offset directly to Location before reading the texture. bool preAddTexelFetchOffsets = false; - - // On some AMD drivers, 1x1 and 2x2 mips of depth/stencil textures aren't sampled correctly. - // We can work around this bug by doing an internal blit to a temporary single-channel texture - // before we sample. - bool emulateTinyStencilTextures = false; - - // In Intel driver, the data with format DXGI_FORMAT_B5G6R5_UNORM will be parsed incorrectly. - // This workaroud will disable B5G6R5 support when it's Intel driver. By default, it will use - // R8G8B8A8 format. - bool disableB5G6R5Support = false; - - // On some Intel drivers, evaluating unary minus operator on integer may get wrong answer in - // vertex shaders. To work around this bug, we translate -(int) into ~(int)+1. - bool rewriteUnaryMinusOperator = false; - - // On some Intel drivers, using isnan() on highp float will get wrong answer. To work around - // this bug, we use an expression to emulate function isnan(). Tracking bug: - // https://crbug.com/650547 - bool emulateIsnanFloat = false; - - // On some Intel drivers, using clear() may not take effect. To work around this bug, we call - // clear() twice on these platforms. Tracking bug: https://crbug.com/655534 - bool callClearTwice = false; - - // On some Intel drivers, copying from staging storage to constant buffer storage does not - // seem to work. Work around this by keeping system memory storage as a canonical reference - // for buffer data. - // D3D11-only workaround. See http://crbug.com/593024. - bool useSystemMemoryForConstantBuffers = false; }; } // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp index f8a0ac597..d1e6a13f2 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp @@ -274,93 +274,6 @@ void CopyDepthStencil(const gl::Box &sourceArea, } } -void Depth32FStencil8ToDepth32F(const float *source, float *dest) -{ - *dest = *source; -} - -void Depth24Stencil8ToDepth32F(const uint32_t *source, float *dest) -{ - uint32_t normDepth = source[0] & 0x00FFFFFF; - float floatDepth = gl::normalizedToFloat<24>(normDepth); - *dest = floatDepth; -} - -void BlitD24S8ToD32F(const gl::Box &sourceArea, - const gl::Box &destArea, - const gl::Rectangle &clippedDestArea, - const gl::Extents &sourceSize, - unsigned int sourceRowPitch, - unsigned int destRowPitch, - ptrdiff_t readOffset, - ptrdiff_t writeOffset, - size_t copySize, - size_t srcPixelStride, - size_t destPixelStride, - const uint8_t *sourceData, - uint8_t *destData) -{ - // No stretching or subregions are supported, only full blits. - ASSERT(sourceArea == destArea); - ASSERT(sourceSize.width == sourceArea.width && sourceSize.height == sourceArea.height && - sourceSize.depth == 1); - ASSERT(clippedDestArea.width == sourceSize.width && - clippedDestArea.height == sourceSize.height); - ASSERT(readOffset == 0 && writeOffset == 0); - ASSERT(destArea.x == 0 && destArea.y == 0); - - for (int row = 0; row < destArea.height; ++row) - { - for (int column = 0; column < destArea.width; ++column) - { - ptrdiff_t offset = row * sourceRowPitch + column * srcPixelStride; - const uint32_t *sourcePixel = reinterpret_cast<const uint32_t *>(sourceData + offset); - - float *destPixel = - reinterpret_cast<float *>(destData + row * destRowPitch + column * destPixelStride); - - Depth24Stencil8ToDepth32F(sourcePixel, destPixel); - } - } -} - -void BlitD32FS8ToD32F(const gl::Box &sourceArea, - const gl::Box &destArea, - const gl::Rectangle &clippedDestArea, - const gl::Extents &sourceSize, - unsigned int sourceRowPitch, - unsigned int destRowPitch, - ptrdiff_t readOffset, - ptrdiff_t writeOffset, - size_t copySize, - size_t srcPixelStride, - size_t destPixelStride, - const uint8_t *sourceData, - uint8_t *destData) -{ - // No stretching or subregions are supported, only full blits. - ASSERT(sourceArea == destArea); - ASSERT(sourceSize.width == sourceArea.width && sourceSize.height == sourceArea.height && - sourceSize.depth == 1); - ASSERT(clippedDestArea.width == sourceSize.width && - clippedDestArea.height == sourceSize.height); - ASSERT(readOffset == 0 && writeOffset == 0); - ASSERT(destArea.x == 0 && destArea.y == 0); - - for (int row = 0; row < destArea.height; ++row) - { - for (int column = 0; column < destArea.width; ++column) - { - ptrdiff_t offset = row * sourceRowPitch + column * srcPixelStride; - const float *sourcePixel = reinterpret_cast<const float *>(sourceData + offset); - float *destPixel = - reinterpret_cast<float *>(destData + row * destRowPitch + column * destPixelStride); - - Depth32FStencil8ToDepth32F(sourcePixel, destPixel); - } - } -} - Blit11::BlitConvertFunction *GetCopyDepthStencilFunction(GLenum internalFormat) { switch (internalFormat) @@ -1022,7 +935,8 @@ gl::Error Blit11::swizzleTexture(ID3D11ShaderResourceView *source, D3D11_SHADER_RESOURCE_VIEW_DESC sourceSRVDesc; source->GetDesc(&sourceSRVDesc); - GLenum componentType = d3d11::GetComponentType(sourceSRVDesc.Format); + const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(sourceSRVDesc.Format); + GLenum componentType = dxgiFormatInfo.componentType; if (componentType == GL_NONE) { // We're swizzling the depth component of a depth-stencil texture. @@ -1182,7 +1096,8 @@ gl::Error Blit11::copyTexture(ID3D11ShaderResourceView *source, D3D11_SHADER_RESOURCE_VIEW_DESC sourceSRVDesc; source->GetDesc(&sourceSRVDesc); - GLenum componentType = d3d11::GetComponentType(sourceSRVDesc.Format); + const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(sourceSRVDesc.Format); + GLenum componentType = dxgiFormatInfo.componentType; ASSERT(componentType != GL_NONE); ASSERT(componentType != GL_SIGNED_NORMALIZED); @@ -1457,26 +1372,26 @@ gl::Error Blit11::copyDepthStencilImpl(const TextureHelper11 &source, const gl::Rectangle *scissor, bool stencilOnly) { - auto srcDXGIFormat = source.getFormat(); - const auto &srcSizeInfo = d3d11::GetDXGIFormatSizeInfo(srcDXGIFormat); + auto srcFormat = source.getFormat(); + const auto &srcSizeInfo = d3d11::GetDXGIFormatSizeInfo(srcFormat); unsigned int srcPixelSize = srcSizeInfo.pixelBytes; - unsigned int copyOffset = 0; + unsigned int copyOffset = 0; unsigned int copySize = srcPixelSize; - auto destDXGIFormat = dest.getFormat(); - const auto &destSizeInfo = d3d11::GetDXGIFormatSizeInfo(destDXGIFormat); + auto destFormat = dest.getFormat(); + const auto &destSizeInfo = d3d11::GetDXGIFormatSizeInfo(destFormat); unsigned int destPixelSize = destSizeInfo.pixelBytes; - ASSERT(srcDXGIFormat == destDXGIFormat || destDXGIFormat == DXGI_FORMAT_R32_TYPELESS); + ASSERT(srcFormat == destFormat); if (stencilOnly) { - const auto &srcFormat = source.getFormatSet().format(); + const d3d11::DXGIFormat &srcDXGIFormat = d3d11::GetDXGIFormatInfo(srcFormat); // Stencil channel should be right after the depth channel. Some views to depth/stencil // resources have red channel for depth, in which case the depth channel bit width is in // redBits. - ASSERT((srcFormat.redBits != 0) != (srcFormat.depthBits != 0)); - GLuint depthBits = srcFormat.redBits + srcFormat.depthBits; + ASSERT((srcDXGIFormat.redBits != 0) != (srcDXGIFormat.depthBits != 0)); + GLuint depthBits = srcDXGIFormat.redBits + srcDXGIFormat.depthBits; // Known formats have either 24 or 32 bits of depth. ASSERT(depthBits == 24 || depthBits == 32); copyOffset = depthBits / 8; @@ -1485,22 +1400,6 @@ gl::Error Blit11::copyDepthStencilImpl(const TextureHelper11 &source, copySize = 1; } - if (srcDXGIFormat != destDXGIFormat) - { - if (srcDXGIFormat == DXGI_FORMAT_R24G8_TYPELESS) - { - ASSERT(sourceArea == destArea && sourceSize == destSize && scissor == nullptr); - return copyAndConvert(source, sourceSubresource, sourceArea, sourceSize, dest, - destSubresource, destArea, destSize, scissor, copyOffset, - copyOffset, copySize, srcPixelSize, destPixelSize, - BlitD24S8ToD32F); - } - ASSERT(srcDXGIFormat == DXGI_FORMAT_R32G8X24_TYPELESS); - return copyAndConvert(source, sourceSubresource, sourceArea, sourceSize, dest, - destSubresource, destArea, destSize, scissor, copyOffset, copyOffset, - copySize, srcPixelSize, destPixelSize, BlitD32FS8ToD32F); - } - return copyAndConvert(source, sourceSubresource, sourceArea, sourceSize, dest, destSubresource, destArea, destSize, scissor, copyOffset, copyOffset, copySize, srcPixelSize, destPixelSize, StretchedBlitNearest); @@ -2000,14 +1899,6 @@ gl::Error Blit11::getSwizzleShader(GLenum type, gl::ErrorOrResult<TextureHelper11> Blit11::resolveDepth(RenderTarget11 *depth) { - // Multisampled depth stencil SRVs are not available in feature level 10.0 - if (mRenderer->getRenderer11DeviceCaps().featureLevel <= D3D_FEATURE_LEVEL_10_0) - { - return gl::Error(GL_INVALID_OPERATION, - "Resolving multisampled depth stencil textures is not supported in " - "feature level 10.0."); - } - const auto &extents = depth->getExtents(); ID3D11Device *device = mRenderer->getDevice(); ID3D11DeviceContext *context = mRenderer->getDeviceContext(); @@ -2136,14 +2027,6 @@ gl::Error Blit11::initResolveDepthStencil(const gl::Extents &extents) gl::ErrorOrResult<TextureHelper11> Blit11::resolveStencil(RenderTarget11 *depthStencil, bool alsoDepth) { - // Multisampled depth stencil SRVs are not available in feature level 10.0 - if (mRenderer->getRenderer11DeviceCaps().featureLevel <= D3D_FEATURE_LEVEL_10_0) - { - return gl::Error(GL_INVALID_OPERATION, - "Resolving multisampled depth stencil textures is not supported in " - "feature level 10.0."); - } - const auto &extents = depthStencil->getExtents(); ANGLE_TRY(initResolveDepthStencil(extents)); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp index 90668b759..107a577e4 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp @@ -38,34 +38,12 @@ enum class CopyResult NOT_RECREATED, }; -void CalculateConstantBufferParams(GLintptr offset, - GLsizeiptr size, - UINT *outFirstConstant, - UINT *outNumConstants) -{ - // The offset must be aligned to 256 bytes (should have been enforced by glBindBufferRange). - ASSERT(offset % 256 == 0); - - // firstConstant and numConstants are expressed in constants of 16-bytes. Furthermore they must - // be a multiple of 16 constants. - *outFirstConstant = static_cast<UINT>(offset / 16); - - // The GL size is not required to be aligned to a 256 bytes boundary. - // Round the size up to a 256 bytes boundary then express the results in constants of 16-bytes. - *outNumConstants = static_cast<UINT>(rx::roundUp(size, static_cast<GLsizeiptr>(256)) / 16); - - // Since the size is rounded up, firstConstant + numConstants may be bigger than the actual size - // of the buffer. This behaviour is explictly allowed according to the documentation on - // ID3D11DeviceContext1::PSSetConstantBuffers1 - // https://msdn.microsoft.com/en-us/library/windows/desktop/hh404649%28v=vs.85%29.aspx -} - } // anonymous namespace namespace gl_d3d11 { -D3D11_MAP GetD3DMapTypeFromBits(BufferUsage usage, GLbitfield access) +D3D11_MAP GetD3DMapTypeFromBits(GLbitfield access) { bool readBit = ((access & GL_MAP_READ_BIT) != 0); bool writeBit = ((access & GL_MAP_WRITE_BIT) != 0); @@ -81,8 +59,7 @@ D3D11_MAP GetD3DMapTypeFromBits(BufferUsage usage, GLbitfield access) } else if (writeBit && !readBit) { - // Special case for uniform storage - we only allow full buffer updates. - return usage == BUFFER_USAGE_UNIFORM ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE; + return D3D11_MAP_WRITE; } else if (writeBit && readBit) { @@ -111,7 +88,7 @@ class Buffer11::BufferStorage : angle::NonCopyable size_t getSize() const { return mBufferSize; } void setDataRevision(DataRevision rev) { mRevision = rev; } - virtual bool isMappable(GLbitfield access) const = 0; + virtual bool isMappable() const = 0; virtual gl::ErrorOrResult<CopyResult> copyFromStorage(BufferStorage *source, size_t sourceOffset, @@ -146,7 +123,7 @@ class Buffer11::NativeStorage : public Buffer11::BufferStorage const angle::BroadcastChannel *onStorageChanged); ~NativeStorage() override; - bool isMappable(GLbitfield access) const override; + bool isMappable() const override { return mUsage == BUFFER_USAGE_STAGING; } ID3D11Buffer *getNativeStorage() const { return mNativeStorage; } gl::ErrorOrResult<CopyResult> copyFromStorage(BufferStorage *source, @@ -161,18 +138,14 @@ class Buffer11::NativeStorage : public Buffer11::BufferStorage uint8_t **mapPointerOut) override; void unmap() override; - gl::ErrorOrResult<ID3D11ShaderResourceView *> getSRVForFormat(DXGI_FORMAT srvFormat); - private: - static void FillBufferDesc(D3D11_BUFFER_DESC *bufferDesc, + static void fillBufferDesc(D3D11_BUFFER_DESC *bufferDesc, Renderer11 *renderer, BufferUsage usage, unsigned int bufferSize); - void clearSRVs(); ID3D11Buffer *mNativeStorage; const angle::BroadcastChannel *mOnStorageChanged; - std::map<DXGI_FORMAT, ID3D11ShaderResourceView *> mBufferResourceViews; }; // A emulated indexed buffer storage represents an underlying D3D11 buffer for data @@ -184,7 +157,7 @@ class Buffer11::EmulatedIndexedStorage : public Buffer11::BufferStorage EmulatedIndexedStorage(Renderer11 *renderer); ~EmulatedIndexedStorage() override; - bool isMappable(GLbitfield access) const override { return true; } + bool isMappable() const override { return true; } gl::ErrorOrResult<ID3D11Buffer *> getNativeStorage(SourceIndexData *indexInfo, const TranslatedAttribute &attribute, @@ -217,7 +190,7 @@ class Buffer11::PackStorage : public Buffer11::BufferStorage explicit PackStorage(Renderer11 *renderer); ~PackStorage() override; - bool isMappable(GLbitfield access) const override { return true; } + bool isMappable() const override { return true; } gl::ErrorOrResult<CopyResult> copyFromStorage(BufferStorage *source, size_t sourceOffset, size_t size, @@ -252,7 +225,7 @@ class Buffer11::SystemMemoryStorage : public Buffer11::BufferStorage explicit SystemMemoryStorage(Renderer11 *renderer); ~SystemMemoryStorage() override {} - bool isMappable(GLbitfield access) const override { return true; } + bool isMappable() const override { return true; } gl::ErrorOrResult<CopyResult> copyFromStorage(BufferStorage *source, size_t sourceOffset, size_t size, @@ -271,16 +244,16 @@ class Buffer11::SystemMemoryStorage : public Buffer11::BufferStorage MemoryBuffer mSystemCopy; }; -Buffer11::Buffer11(const gl::BufferState &state, Renderer11 *renderer) - : BufferD3D(state, renderer), +Buffer11::Buffer11(Renderer11 *renderer) + : BufferD3D(renderer), mRenderer(renderer), mSize(0), mMappedStorage(nullptr), - mBufferStorages({}), - mDeallocThresholds({}), - mIdleness({}), + mBufferStorages(BUFFER_USAGE_COUNT, nullptr), mConstantBufferStorageAdditionalSize(0), - mMaxConstantBufferLruCount(0) + mMaxConstantBufferLruCount(0), + mReadUsageCount(0), + mSystemMemoryDeallocThreshold(0) { } @@ -299,10 +272,10 @@ Buffer11::~Buffer11() mRenderer->onBufferDelete(this); } -gl::Error Buffer11::setData(GLenum target, const void *data, size_t size, GLenum usage) +gl::Error Buffer11::setData(const void *data, size_t size, GLenum usage) { updateD3DBufferUsage(usage); - ANGLE_TRY(setSubData(target, data, size, 0)); + ANGLE_TRY(setSubData(data, size, 0)); return gl::NoError(); } @@ -311,6 +284,8 @@ gl::Error Buffer11::getData(const uint8_t **outData) SystemMemoryStorage *systemMemoryStorage = nullptr; ANGLE_TRY_RESULT(getSystemMemoryStorage(), systemMemoryStorage); + mReadUsageCount = 0; + ASSERT(systemMemoryStorage->getSize() >= mSize); *outData = systemMemoryStorage->getSystemCopy()->data(); @@ -324,34 +299,16 @@ gl::ErrorOrResult<Buffer11::SystemMemoryStorage *> Buffer11::getSystemMemoryStor return GetAs<SystemMemoryStorage>(storage); } -gl::Error Buffer11::setSubData(GLenum target, const void *data, size_t size, size_t offset) +gl::Error Buffer11::setSubData(const void *data, size_t size, size_t offset) { size_t requiredSize = size + offset; if (data && size > 0) { // Use system memory storage for dynamic buffers. - // Try using a constant storage for constant buffers + BufferStorage *writeBuffer = nullptr; - if (target == GL_UNIFORM_BUFFER) - { - // If we are a very large uniform buffer, keep system memory storage around so that we - // aren't forced to read back from a constant buffer. We also check the workaround for - // Intel - this requires us to use system memory so we don't end up having to copy from - // a constant buffer to a staging buffer. - // TODO(jmadill): Use Context caps. - if (offset == 0 && size >= mSize && - size <= static_cast<UINT>(mRenderer->getNativeCaps().maxUniformBlockSize) && - !mRenderer->getWorkarounds().useSystemMemoryForConstantBuffers) - { - ANGLE_TRY_RESULT(getBufferStorage(BUFFER_USAGE_UNIFORM), writeBuffer); - } - else - { - ANGLE_TRY_RESULT(getSystemMemoryStorage(), writeBuffer); - } - } - else if (supportsDirectBinding()) + if (supportsDirectBinding()) { ANGLE_TRY_RESULT(getStagingStorage(), writeBuffer); } @@ -406,12 +363,11 @@ gl::Error Buffer11::copySubData(BufferImpl *source, // If copying to/from a pixel pack buffer, we must have a staging or // pack buffer partner, because other native buffers can't be mapped - if (copyDest->getUsage() == BUFFER_USAGE_PIXEL_PACK && !copySource->isMappable(GL_MAP_READ_BIT)) + if (copyDest->getUsage() == BUFFER_USAGE_PIXEL_PACK && !copySource->isMappable()) { ANGLE_TRY_RESULT(sourceBuffer->getStagingStorage(), copySource); } - else if (copySource->getUsage() == BUFFER_USAGE_PIXEL_PACK && - !copyDest->isMappable(GL_MAP_WRITE_BIT)) + else if (copySource->getUsage() == BUFFER_USAGE_PIXEL_PACK && !copyDest->isMappable()) { ANGLE_TRY_RESULT(getStagingStorage(), copyDest); } @@ -518,81 +474,50 @@ gl::Error Buffer11::markTransformFeedbackUsage() return gl::NoError(); } -void Buffer11::updateDeallocThreshold(BufferUsage usage) +void Buffer11::updateSystemMemoryDeallocThreshold() { // The following strategy was tuned on the Oort online benchmark (http://oortonline.gl/) // as well as a custom microbenchmark (IndexConversionPerfTest.Run/index_range_d3d11) - // First readback: 8 unmodified uses before we free buffer memory. + // First readback: 8 unmodified uses before we free system memory. // After that, double the threshold each time until we reach the max. - if (mDeallocThresholds[usage] == 0) + if (mSystemMemoryDeallocThreshold == 0) { - mDeallocThresholds[usage] = 8; + mSystemMemoryDeallocThreshold = 8; } - else if (mDeallocThresholds[usage] < std::numeric_limits<unsigned int>::max() / 2u) + else if (mSystemMemoryDeallocThreshold < std::numeric_limits<unsigned int>::max() / 2u) { - mDeallocThresholds[usage] *= 2u; + mSystemMemoryDeallocThreshold *= 2u; } else { - mDeallocThresholds[usage] = std::numeric_limits<unsigned int>::max(); + mSystemMemoryDeallocThreshold = std::numeric_limits<unsigned int>::max(); } } -// Free the storage if we decide it isn't being used very often. -gl::Error Buffer11::checkForDeallocation(BufferUsage usage) +gl::Error Buffer11::markBufferUsage() { - mIdleness[usage]++; + mReadUsageCount++; - BufferStorage *&storage = mBufferStorages[usage]; - if (storage != nullptr && mIdleness[usage] > mDeallocThresholds[usage]) + // Free the system memory storage if we decide it isn't being used very often. + BufferStorage *&sysMemStorage = mBufferStorages[BUFFER_USAGE_SYSTEM_MEMORY]; + if (sysMemStorage != nullptr && mReadUsageCount > mSystemMemoryDeallocThreshold) { BufferStorage *latestStorage = nullptr; ANGLE_TRY_RESULT(getLatestBufferStorage(), latestStorage); - if (latestStorage != storage) + if (latestStorage != sysMemStorage) { - SafeDelete(storage); + SafeDelete(sysMemStorage); } } return gl::NoError(); } -// Keep system memory when we are using it for the canonical version of data. -bool Buffer11::canDeallocateSystemMemory() const -{ - // Must keep system memory on Intel. - if (mRenderer->getWorkarounds().useSystemMemoryForConstantBuffers) - { - return false; - } - - return (!mBufferStorages[BUFFER_USAGE_UNIFORM] || - mSize <= mRenderer->getNativeCaps().maxUniformBlockSize); -} - -void Buffer11::markBufferUsage(BufferUsage usage) -{ - mIdleness[usage] = 0; -} - -gl::Error Buffer11::garbageCollection(BufferUsage currentUsage) -{ - if (currentUsage != BUFFER_USAGE_SYSTEM_MEMORY && canDeallocateSystemMemory()) - { - ANGLE_TRY(checkForDeallocation(BUFFER_USAGE_SYSTEM_MEMORY)); - } - - if (currentUsage != BUFFER_USAGE_STAGING) - { - ANGLE_TRY(checkForDeallocation(BUFFER_USAGE_STAGING)); - } - - return gl::NoError(); -} - gl::ErrorOrResult<ID3D11Buffer *> Buffer11::getBuffer(BufferUsage usage) { + ANGLE_TRY(markBufferUsage()); + BufferStorage *storage = nullptr; ANGLE_TRY_RESULT(getBufferStorage(usage), storage); return GetAs<NativeStorage>(storage)->getNativeStorage(); @@ -605,6 +530,8 @@ gl::ErrorOrResult<ID3D11Buffer *> Buffer11::getEmulatedIndexedBuffer( { ASSERT(indexInfo); + ANGLE_TRY(markBufferUsage()); + BufferStorage *untypedStorage = nullptr; ANGLE_TRY_RESULT(getBufferStorage(BUFFER_USAGE_EMULATED_INDEXED_VERTEX), untypedStorage); @@ -617,37 +544,64 @@ gl::ErrorOrResult<ID3D11Buffer *> Buffer11::getEmulatedIndexedBuffer( return nativeStorage; } -gl::Error Buffer11::getConstantBufferRange(GLintptr offset, - GLsizeiptr size, - ID3D11Buffer **bufferOut, - UINT *firstConstantOut, - UINT *numConstantsOut) +gl::ErrorOrResult<ID3D11Buffer *> Buffer11::getConstantBufferRange(GLintptr offset, GLsizeiptr size) { + ANGLE_TRY(markBufferUsage()); + BufferStorage *bufferStorage = nullptr; if (offset == 0 || mRenderer->getRenderer11DeviceCaps().supportsConstantBufferOffsets) { ANGLE_TRY_RESULT(getBufferStorage(BUFFER_USAGE_UNIFORM), bufferStorage); - CalculateConstantBufferParams(offset, size, firstConstantOut, numConstantsOut); } else { ANGLE_TRY_RESULT(getConstantBufferRangeStorage(offset, size), bufferStorage); - *firstConstantOut = 0; - *numConstantsOut = 0; } - *bufferOut = GetAs<NativeStorage>(bufferStorage)->getNativeStorage(); - - return gl::NoError(); + return GetAs<NativeStorage>(bufferStorage)->getNativeStorage(); } gl::ErrorOrResult<ID3D11ShaderResourceView *> Buffer11::getSRV(DXGI_FORMAT srvFormat) { BufferStorage *storage = nullptr; ANGLE_TRY_RESULT(getBufferStorage(BUFFER_USAGE_PIXEL_UNPACK), storage); - NativeStorage *nativeStorage = GetAs<NativeStorage>(storage); - return nativeStorage->getSRVForFormat(srvFormat); + ID3D11Buffer *buffer = GetAs<NativeStorage>(storage)->getNativeStorage(); + + auto bufferSRVIt = mBufferResourceViews.find(srvFormat); + + if (bufferSRVIt != mBufferResourceViews.end()) + { + if (bufferSRVIt->second.first == buffer) + { + return bufferSRVIt->second.second; + } + else + { + // The underlying buffer has changed since the SRV was created: recreate the SRV. + SafeRelease(bufferSRVIt->second.second); + } + } + + ID3D11Device *device = mRenderer->getDevice(); + ID3D11ShaderResourceView *bufferSRV = nullptr; + + const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(srvFormat); + + D3D11_SHADER_RESOURCE_VIEW_DESC bufferSRVDesc; + bufferSRVDesc.Buffer.ElementOffset = 0; + bufferSRVDesc.Buffer.ElementWidth = + static_cast<unsigned int>(mSize) / dxgiFormatInfo.pixelBytes; + bufferSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; + bufferSRVDesc.Format = srvFormat; + + HRESULT result = device->CreateShaderResourceView(buffer, &bufferSRVDesc, &bufferSRV); + UNUSED_ASSERTION_VARIABLE(result); + ASSERT(SUCCEEDED(result)); + + mBufferResourceViews[srvFormat] = BufferSRVPair(buffer, bufferSRV); + + return bufferSRV; } gl::Error Buffer11::packPixels(const gl::FramebufferAttachment &readAttachment, @@ -689,31 +643,28 @@ gl::ErrorOrResult<Buffer11::BufferStorage *> Buffer11::getBufferStorage(BufferUs newStorage = allocateStorage(usage); } - markBufferUsage(usage); - // resize buffer if (newStorage->getSize() < mSize) { ANGLE_TRY(newStorage->resize(mSize, true)); } - ASSERT(newStorage); - ANGLE_TRY(updateBufferStorage(newStorage, 0, mSize)); - ANGLE_TRY(garbageCollection(usage)); return newStorage; } Buffer11::BufferStorage *Buffer11::allocateStorage(BufferUsage usage) { - updateDeallocThreshold(usage); switch (usage) { case BUFFER_USAGE_PIXEL_PACK: return new PackStorage(mRenderer); case BUFFER_USAGE_SYSTEM_MEMORY: + { + updateSystemMemoryDeallocThreshold(); return new SystemMemoryStorage(mRenderer); + } case BUFFER_USAGE_EMULATED_INDEXED_VERTEX: return new EmulatedIndexedStorage(mRenderer); case BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK: @@ -744,8 +695,6 @@ gl::ErrorOrResult<Buffer11::BufferStorage *> Buffer11::getConstantBufferRangeSto newStorage = cacheEntry->storage; } - markBufferUsage(BUFFER_USAGE_UNIFORM); - if (newStorage->getSize() < static_cast<size_t>(size)) { size_t maximumAllowedAdditionalSize = 2 * getSize(); @@ -780,7 +729,6 @@ gl::ErrorOrResult<Buffer11::BufferStorage *> Buffer11::getConstantBufferRangeSto } ANGLE_TRY(updateBufferStorage(newStorage, offset, size)); - ANGLE_TRY(garbageCollection(BUFFER_USAGE_UNIFORM)); return newStorage; } @@ -791,8 +739,6 @@ gl::Error Buffer11::updateBufferStorage(BufferStorage *storage, BufferStorage *latestBuffer = nullptr; ANGLE_TRY_RESULT(getLatestBufferStorage(), latestBuffer); - ASSERT(storage); - if (latestBuffer && latestBuffer->getDataRevision() > storage->getDataRevision()) { // Copy through a staging buffer if we're copying from or to a non-staging, mappable @@ -800,7 +746,7 @@ gl::Error Buffer11::updateBufferStorage(BufferStorage *storage, // data directly. If we're already using a staging buffer we're fine. if (latestBuffer->getUsage() != BUFFER_USAGE_STAGING && storage->getUsage() != BUFFER_USAGE_STAGING && - (!latestBuffer->isMappable(GL_MAP_READ_BIT) || !storage->isMappable(GL_MAP_WRITE_BIT))) + (!latestBuffer->isMappable() || !storage->isMappable())) { NativeStorage *stagingBuffer = nullptr; ANGLE_TRY_RESULT(getStagingStorage(), stagingBuffer); @@ -899,8 +845,6 @@ angle::BroadcastChannel *Buffer11::getDirectBroadcastChannel() return &mDirectBroadcastChannel; } -// Buffer11::BufferStorage implementation - Buffer11::BufferStorage::BufferStorage(Renderer11 *renderer, BufferUsage usage) : mRenderer(renderer), mRevision(0), mUsage(usage), mBufferSize(0) { @@ -908,24 +852,18 @@ Buffer11::BufferStorage::BufferStorage(Renderer11 *renderer, BufferUsage usage) gl::Error Buffer11::BufferStorage::setData(const uint8_t *data, size_t offset, size_t size) { - ASSERT(isMappable(GL_MAP_WRITE_BIT)); - - // Uniform storage can have a different internal size than the buffer size. Ensure we don't - // overflow. - size_t mapSize = std::min(size, mBufferSize - offset); + ASSERT(isMappable()); uint8_t *writePointer = nullptr; - ANGLE_TRY(map(offset, mapSize, GL_MAP_WRITE_BIT, &writePointer)); + ANGLE_TRY(map(offset, size, GL_MAP_WRITE_BIT, &writePointer)); - memcpy(writePointer, data, mapSize); + memcpy(writePointer, data, size); unmap(); return gl::NoError(); } -// Buffer11::NativeStorage implementation - Buffer11::NativeStorage::NativeStorage(Renderer11 *renderer, BufferUsage usage, const angle::BroadcastChannel *onStorageChanged) @@ -936,18 +874,6 @@ Buffer11::NativeStorage::NativeStorage(Renderer11 *renderer, Buffer11::NativeStorage::~NativeStorage() { SafeRelease(mNativeStorage); - clearSRVs(); -} - -bool Buffer11::NativeStorage::isMappable(GLbitfield access) const -{ - if ((access & GL_MAP_READ_BIT) != 0) - { - // Read is more exclusive than write mappability. - return (mUsage == BUFFER_USAGE_STAGING); - } - ASSERT((access & GL_MAP_WRITE_BIT) != 0); - return (mUsage == BUFFER_USAGE_STAGING || mUsage == BUFFER_USAGE_UNIFORM); } // Returns true if it recreates the direct buffer @@ -962,38 +888,45 @@ gl::ErrorOrResult<CopyResult> Buffer11::NativeStorage::copyFromStorage(BufferSto bool createBuffer = !mNativeStorage || mBufferSize < requiredSize; // (Re)initialize D3D buffer if needed - bool preserveData = (destOffset > 0); if (createBuffer) { + bool preserveData = (destOffset > 0); resize(requiredSize, preserveData); } - size_t clampedSize = size; - if (mUsage == BUFFER_USAGE_UNIFORM) - { - clampedSize = std::min(clampedSize, mBufferSize - destOffset); - } - if (source->getUsage() == BUFFER_USAGE_PIXEL_PACK || source->getUsage() == BUFFER_USAGE_SYSTEM_MEMORY) { - ASSERT(source->isMappable(GL_MAP_READ_BIT) && isMappable(GL_MAP_WRITE_BIT)); - - // Uniform buffers must be mapped with write/discard. - ASSERT(!(preserveData && mUsage == BUFFER_USAGE_UNIFORM)); + ASSERT(source->isMappable()); uint8_t *sourcePointer = nullptr; - ANGLE_TRY(source->map(sourceOffset, clampedSize, GL_MAP_READ_BIT, &sourcePointer)); + ANGLE_TRY(source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourcePointer)); + + D3D11_MAPPED_SUBRESOURCE mappedResource; + HRESULT hr = context->Map(mNativeStorage, 0, D3D11_MAP_WRITE, 0, &mappedResource); + ASSERT(SUCCEEDED(hr)); + if (FAILED(hr)) + { + source->unmap(); + return gl::Error( + GL_OUT_OF_MEMORY, + "Failed to map native storage in Buffer11::NativeStorage::copyFromStorage"); + } + + uint8_t *destPointer = static_cast<uint8_t *>(mappedResource.pData) + destOffset; - setData(sourcePointer, destOffset, clampedSize); + // Offset bounds are validated at the API layer + ASSERT(sourceOffset + size <= destOffset + mBufferSize); + memcpy(destPointer, sourcePointer, size); + context->Unmap(mNativeStorage, 0); source->unmap(); } else { D3D11_BOX srcBox; srcBox.left = static_cast<unsigned int>(sourceOffset); - srcBox.right = static_cast<unsigned int>(sourceOffset + clampedSize); + srcBox.right = static_cast<unsigned int>(sourceOffset + size); srcBox.top = 0; srcBox.bottom = 1; srcBox.front = 0; @@ -1014,7 +947,7 @@ gl::Error Buffer11::NativeStorage::resize(size_t size, bool preserveData) ID3D11DeviceContext *context = mRenderer->getDeviceContext(); D3D11_BUFFER_DESC bufferDesc; - FillBufferDesc(&bufferDesc, mRenderer, mUsage, static_cast<unsigned int>(size)); + fillBufferDesc(&bufferDesc, mRenderer, mUsage, static_cast<unsigned int>(size)); ID3D11Buffer *newBuffer; HRESULT result = device->CreateBuffer(&bufferDesc, nullptr, &newBuffer); @@ -1049,9 +982,6 @@ gl::Error Buffer11::NativeStorage::resize(size_t size, bool preserveData) mBufferSize = bufferDesc.ByteWidth; - // Free the SRVs. - clearSRVs(); - // Notify that the storage has changed. if (mOnStorageChanged) { @@ -1061,8 +991,7 @@ gl::Error Buffer11::NativeStorage::resize(size_t size, bool preserveData) return gl::NoError(); } -// static -void Buffer11::NativeStorage::FillBufferDesc(D3D11_BUFFER_DESC *bufferDesc, +void Buffer11::NativeStorage::fillBufferDesc(D3D11_BUFFER_DESC *bufferDesc, Renderer11 *renderer, BufferUsage usage, unsigned int bufferSize) @@ -1111,9 +1040,6 @@ void Buffer11::NativeStorage::FillBufferDesc(D3D11_BUFFER_DESC *bufferDesc, // Constant buffers must be of a limited size, and aligned to 16 byte boundaries // For our purposes we ignore any buffer data past the maximum constant buffer size bufferDesc->ByteWidth = roundUp(bufferDesc->ByteWidth, 16u); - - // Note: it seems that D3D11 allows larger buffers on some platforms, but not all. - // (Windows 10 seems to allow larger constant buffers, but not Windows 7) bufferDesc->ByteWidth = std::min<UINT>(bufferDesc->ByteWidth, static_cast<UINT>(renderer->getNativeCaps().maxUniformBlockSize)); @@ -1129,11 +1055,11 @@ gl::Error Buffer11::NativeStorage::map(size_t offset, GLbitfield access, uint8_t **mapPointerOut) { - ASSERT(isMappable(access)); + ASSERT(mUsage == BUFFER_USAGE_STAGING); D3D11_MAPPED_SUBRESOURCE mappedResource; ID3D11DeviceContext *context = mRenderer->getDeviceContext(); - D3D11_MAP d3dMapType = gl_d3d11::GetD3DMapTypeFromBits(mUsage, access); + D3D11_MAP d3dMapType = gl_d3d11::GetD3DMapTypeFromBits(access); UINT d3dMapFlag = ((access & GL_MAP_UNSYNCHRONIZED_BIT) != 0 ? D3D11_MAP_FLAG_DO_NOT_WAIT : 0); HRESULT result = context->Map(mNativeStorage, 0, d3dMapType, d3dMapFlag, &mappedResource); @@ -1150,56 +1076,11 @@ gl::Error Buffer11::NativeStorage::map(size_t offset, void Buffer11::NativeStorage::unmap() { - ASSERT(isMappable(GL_MAP_WRITE_BIT) || isMappable(GL_MAP_READ_BIT)); + ASSERT(mUsage == BUFFER_USAGE_STAGING); ID3D11DeviceContext *context = mRenderer->getDeviceContext(); context->Unmap(mNativeStorage, 0); } -gl::ErrorOrResult<ID3D11ShaderResourceView *> Buffer11::NativeStorage::getSRVForFormat( - DXGI_FORMAT srvFormat) -{ - auto bufferSRVIt = mBufferResourceViews.find(srvFormat); - - if (bufferSRVIt != mBufferResourceViews.end()) - { - return bufferSRVIt->second; - } - - ID3D11Device *device = mRenderer->getDevice(); - ID3D11ShaderResourceView *bufferSRV = nullptr; - - const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(srvFormat); - - D3D11_SHADER_RESOURCE_VIEW_DESC bufferSRVDesc; - bufferSRVDesc.Buffer.ElementOffset = 0; - bufferSRVDesc.Buffer.ElementWidth = static_cast<UINT>(mBufferSize) / dxgiFormatInfo.pixelBytes; - bufferSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; - bufferSRVDesc.Format = srvFormat; - - HRESULT result = device->CreateShaderResourceView(mNativeStorage, &bufferSRVDesc, &bufferSRV); - ASSERT(SUCCEEDED(result)); - if (FAILED(result)) - { - return gl::Error(GL_OUT_OF_MEMORY, - "Error creating buffer SRV in Buffer11::NativeStorage::getSRVForFormat"); - } - - mBufferResourceViews[srvFormat] = bufferSRV; - - return bufferSRV; -} - -void Buffer11::NativeStorage::clearSRVs() -{ - for (auto &srv : mBufferResourceViews) - { - SafeRelease(srv.second); - } - mBufferResourceViews.clear(); -} - -// Buffer11::EmulatedIndexStorage implementation - Buffer11::EmulatedIndexedStorage::EmulatedIndexedStorage(Renderer11 *renderer) : BufferStorage(renderer, BUFFER_USAGE_EMULATED_INDEXED_VERTEX), mNativeStorage(nullptr) { @@ -1334,7 +1215,7 @@ gl::ErrorOrResult<CopyResult> Buffer11::EmulatedIndexedStorage::copyFromStorage( size_t size, size_t destOffset) { - ASSERT(source->isMappable(GL_MAP_READ_BIT)); + ASSERT(source->isMappable()); uint8_t *sourceData = nullptr; ANGLE_TRY(source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourceData)); ASSERT(destOffset + size <= mMemoryBuffer.size()); @@ -1372,8 +1253,6 @@ void Buffer11::EmulatedIndexedStorage::unmap() // No-op } -// Buffer11::PackStorage implementation - Buffer11::PackStorage::PackStorage(Renderer11 *renderer) : BufferStorage(renderer, BUFFER_USAGE_PIXEL_PACK), mStagingTexture(), mDataModified(false) { @@ -1390,8 +1269,9 @@ gl::ErrorOrResult<CopyResult> Buffer11::PackStorage::copyFromStorage(BufferStora { ANGLE_TRY(flushQueuedPackCommand()); - // For all use cases of pack buffers, we must copy through a readable buffer. - ASSERT(source->isMappable(GL_MAP_READ_BIT)); + // We copy through a staging buffer when drawing with a pack buffer, or for other cases where we + // access the pack buffer + ASSERT(source->isMappable() && source->getUsage() == BUFFER_USAGE_STAGING); uint8_t *sourceData = nullptr; ANGLE_TRY(source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourceData)); ASSERT(destOffset + size <= mMemoryBuffer.size()); @@ -1504,8 +1384,6 @@ gl::Error Buffer11::PackStorage::flushQueuedPackCommand() return gl::NoError(); } -// Buffer11::SystemMemoryStorage implementation - Buffer11::SystemMemoryStorage::SystemMemoryStorage(Renderer11 *renderer) : Buffer11::BufferStorage(renderer, BUFFER_USAGE_SYSTEM_MEMORY) { @@ -1516,7 +1394,7 @@ gl::ErrorOrResult<CopyResult> Buffer11::SystemMemoryStorage::copyFromStorage(Buf size_t size, size_t destOffset) { - ASSERT(source->isMappable(GL_MAP_READ_BIT)); + ASSERT(source->isMappable()); uint8_t *sourceData = nullptr; ANGLE_TRY(source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourceData)); ASSERT(destOffset + size <= mSystemCopy.size()); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.h index 3210f05bc..6d56501d8 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.h @@ -9,7 +9,6 @@ #ifndef LIBANGLE_RENDERER_D3D_D3D11_BUFFER11_H_ #define LIBANGLE_RENDERER_D3D_D3D11_BUFFER11_H_ -#include <array> #include <map> #include "libANGLE/angletypes.h" @@ -28,16 +27,15 @@ class Renderer11; struct SourceIndexData; struct TranslatedAttribute; -// The order of this enum governs priority of 'getLatestBufferStorage'. enum BufferUsage { - BUFFER_USAGE_SYSTEM_MEMORY, BUFFER_USAGE_STAGING, BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK, BUFFER_USAGE_INDEX, BUFFER_USAGE_PIXEL_UNPACK, BUFFER_USAGE_PIXEL_PACK, BUFFER_USAGE_UNIFORM, + BUFFER_USAGE_SYSTEM_MEMORY, BUFFER_USAGE_EMULATED_INDEXED_VERTEX, BUFFER_USAGE_COUNT, @@ -48,18 +46,14 @@ typedef size_t DataRevision; class Buffer11 : public BufferD3D { public: - Buffer11(const gl::BufferState &state, Renderer11 *renderer); + Buffer11(Renderer11 *renderer); virtual ~Buffer11(); gl::ErrorOrResult<ID3D11Buffer *> getBuffer(BufferUsage usage); gl::ErrorOrResult<ID3D11Buffer *> getEmulatedIndexedBuffer(SourceIndexData *indexInfo, const TranslatedAttribute &attribute, GLint startVertex); - gl::Error getConstantBufferRange(GLintptr offset, - GLsizeiptr size, - ID3D11Buffer **bufferOut, - UINT *firstConstantOut, - UINT *numConstantsOut); + gl::ErrorOrResult<ID3D11Buffer *> getConstantBufferRange(GLintptr offset, GLsizeiptr size); gl::ErrorOrResult<ID3D11ShaderResourceView *> getSRV(DXGI_FORMAT srvFormat); bool isMapped() const { return mMappedStorage != nullptr; } gl::Error packPixels(const gl::FramebufferAttachment &readAttachment, @@ -74,8 +68,8 @@ class Buffer11 : public BufferD3D void invalidateStaticData() override; // BufferImpl implementation - gl::Error setData(GLenum target, const void *data, size_t size, GLenum usage) override; - gl::Error setSubData(GLenum target, const void *data, size_t size, size_t offset) override; + gl::Error setData(const void *data, size_t size, GLenum usage) override; + gl::Error setSubData(const void *data, size_t size, size_t offset) override; gl::Error copySubData(BufferImpl *source, GLintptr sourceOffset, GLintptr destOffset, @@ -106,8 +100,7 @@ class Buffer11 : public BufferD3D unsigned int lruCount; }; - void markBufferUsage(BufferUsage usage); - gl::Error garbageCollection(BufferUsage currentUsage); + gl::Error markBufferUsage(); gl::ErrorOrResult<NativeStorage *> getStagingStorage(); gl::ErrorOrResult<PackStorage *> getPackStorage(); gl::ErrorOrResult<SystemMemoryStorage *> getSystemMemoryStorage(); @@ -120,24 +113,14 @@ class Buffer11 : public BufferD3D GLsizeiptr size); BufferStorage *allocateStorage(BufferUsage usage); - void updateDeallocThreshold(BufferUsage usage); - - // Free the storage if we decide it isn't being used very often. - gl::Error checkForDeallocation(BufferUsage usage); - - // For some cases of uniform buffer storage, we can't deallocate system memory storage. - bool canDeallocateSystemMemory() const; + void updateSystemMemoryDeallocThreshold(); Renderer11 *mRenderer; size_t mSize; BufferStorage *mMappedStorage; - std::array<BufferStorage *, BUFFER_USAGE_COUNT> mBufferStorages; - - // These two arrays are used to track when to free unused storage. - std::array<unsigned int, BUFFER_USAGE_COUNT> mDeallocThresholds; - std::array<unsigned int, BUFFER_USAGE_COUNT> mIdleness; + std::vector<BufferStorage *> mBufferStorages; // Cache of D3D11 constant buffer for specific ranges of buffer data. // This is used to emulate UBO ranges on 11.0 devices. @@ -147,6 +130,12 @@ class Buffer11 : public BufferD3D size_t mConstantBufferStorageAdditionalSize; unsigned int mMaxConstantBufferLruCount; + typedef std::pair<ID3D11Buffer *, ID3D11ShaderResourceView *> BufferSRVPair; + std::map<DXGI_FORMAT, BufferSRVPair> mBufferResourceViews; + + unsigned int mReadUsageCount; + unsigned int mSystemMemoryDeallocThreshold; + angle::BroadcastChannel mStaticBroadcastChannel; angle::BroadcastChannel mDirectBroadcastChannel; }; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp index f42a59ced..d2d813895 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp @@ -34,40 +34,29 @@ namespace rx { template <typename T> -static void ApplyVertices(const gl::Extents &framebufferSize, - const gl::Rectangle *scissor, - const gl::Color<T> &color, - float depth, - void *buffer) +static void ApplyVertices(const gl::Extents &framebufferSize, const gl::Rectangle *scissor, const gl::Color<T> &color, float depth, void *buffer) { - d3d11::PositionDepthColorVertex<T> *vertices = - reinterpret_cast<d3d11::PositionDepthColorVertex<T> *>(buffer); + d3d11::PositionDepthColorVertex<T> *vertices = reinterpret_cast<d3d11::PositionDepthColorVertex<T>*>(buffer); float depthClear = gl::clamp01(depth); - float left = -1.0f; - float right = 1.0f; - float top = -1.0f; - float bottom = 1.0f; + float left = -1.0f; + float right = 1.0f; + float top = -1.0f; + float bottom = 1.0f; // Clip the quad coordinates to the scissor if needed if (scissor != nullptr) { - left = std::max(left, (scissor->x / float(framebufferSize.width)) * 2.0f - 1.0f); - right = std::min( - right, ((scissor->x + scissor->width) / float(framebufferSize.width)) * 2.0f - 1.0f); - top = std::max(top, ((framebufferSize.height - scissor->y - scissor->height) / - float(framebufferSize.height)) * - 2.0f - - 1.0f); - bottom = std::min( - bottom, - ((framebufferSize.height - scissor->y) / float(framebufferSize.height)) * 2.0f - 1.0f); + left = std::max(left, (scissor->x / float(framebufferSize.width)) * 2.0f - 1.0f); + right = std::min(right, ((scissor->x + scissor->width) / float(framebufferSize.width)) * 2.0f - 1.0f); + top = std::max(top, ((framebufferSize.height - scissor->y - scissor->height) / float(framebufferSize.height)) * 2.0f - 1.0f); + bottom = std::min(bottom, ((framebufferSize.height - scissor->y) / float(framebufferSize.height)) * 2.0f - 1.0f); } - d3d11::SetPositionDepthColorVertex<T>(vertices + 0, left, bottom, depthClear, color); - d3d11::SetPositionDepthColorVertex<T>(vertices + 1, left, top, depthClear, color); + d3d11::SetPositionDepthColorVertex<T>(vertices + 0, left, bottom, depthClear, color); + d3d11::SetPositionDepthColorVertex<T>(vertices + 1, left, top, depthClear, color); d3d11::SetPositionDepthColorVertex<T>(vertices + 2, right, bottom, depthClear, color); - d3d11::SetPositionDepthColorVertex<T>(vertices + 3, right, top, depthClear, color); + d3d11::SetPositionDepthColorVertex<T>(vertices + 3, right, top, depthClear, color); } Clear11::ClearShader::ClearShader(DXGI_FORMAT colorType, @@ -82,9 +71,10 @@ Clear11::ClearShader::ClearShader(DXGI_FORMAT colorType, vertexShader(vsByteCode, vsSize, vsDebugName), pixelShader(psByteCode, psSize, psDebugName) { - D3D11_INPUT_ELEMENT_DESC quadLayout[] = { - {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, - {"COLOR", 0, colorType, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0}, + D3D11_INPUT_ELEMENT_DESC quadLayout[] = + { + { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, colorType, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; inputLayout = new d3d11::LazyInputLayout(quadLayout, 2, vsByteCode, vsSize, inputLayoutName); @@ -113,11 +103,11 @@ Clear11::Clear11(Renderer11 *renderer) ID3D11Device *device = renderer->getDevice(); D3D11_BUFFER_DESC vbDesc; - vbDesc.ByteWidth = sizeof(d3d11::PositionDepthColorVertex<float>) * 4; - vbDesc.Usage = D3D11_USAGE_DYNAMIC; - vbDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; - vbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - vbDesc.MiscFlags = 0; + vbDesc.ByteWidth = sizeof(d3d11::PositionDepthColorVertex<float>) * 4; + vbDesc.Usage = D3D11_USAGE_DYNAMIC; + vbDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + vbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + vbDesc.MiscFlags = 0; vbDesc.StructureByteStride = 0; result = device->CreateBuffer(&vbDesc, nullptr, &mVertexBuffer); @@ -125,15 +115,15 @@ Clear11::Clear11(Renderer11 *renderer) d3d11::SetDebugName(mVertexBuffer, "Clear11 masked clear vertex buffer"); D3D11_RASTERIZER_DESC rsDesc; - rsDesc.FillMode = D3D11_FILL_SOLID; - rsDesc.CullMode = D3D11_CULL_NONE; + rsDesc.FillMode = D3D11_FILL_SOLID; + rsDesc.CullMode = D3D11_CULL_NONE; rsDesc.FrontCounterClockwise = FALSE; - rsDesc.DepthBias = 0; - rsDesc.DepthBiasClamp = 0.0f; - rsDesc.SlopeScaledDepthBias = 0.0f; - rsDesc.DepthClipEnable = TRUE; - rsDesc.ScissorEnable = FALSE; - rsDesc.MultisampleEnable = FALSE; + rsDesc.DepthBias = 0; + rsDesc.DepthBiasClamp = 0.0f; + rsDesc.SlopeScaledDepthBias = 0.0f; + rsDesc.DepthClipEnable = TRUE; + rsDesc.ScissorEnable = FALSE; + rsDesc.MultisampleEnable = FALSE; rsDesc.AntialiasedLineEnable = FALSE; result = device->CreateRasterizerState(&rsDesc, &mRasterizerState); @@ -142,36 +132,51 @@ Clear11::Clear11(Renderer11 *renderer) if (mRenderer->getRenderer11DeviceCaps().featureLevel <= D3D_FEATURE_LEVEL_9_3) { - mFloatClearShader = - new ClearShader(DXGI_FORMAT_R32G32B32A32_FLOAT, "Clear11 Float IL", g_VS_ClearFloat, - ArraySize(g_VS_ClearFloat), "Clear11 Float VS", g_PS_ClearFloat_FL9, - ArraySize(g_PS_ClearFloat_FL9), "Clear11 Float PS"); + mFloatClearShader = new ClearShader(DXGI_FORMAT_R32G32B32A32_FLOAT, + "Clear11 Float IL", + g_VS_ClearFloat, + ArraySize(g_VS_ClearFloat), + "Clear11 Float VS", + g_PS_ClearFloat_FL9, + ArraySize(g_PS_ClearFloat_FL9), + "Clear11 Float PS"); } else { - mFloatClearShader = - new ClearShader(DXGI_FORMAT_R32G32B32A32_FLOAT, "Clear11 Float IL", g_VS_ClearFloat, - ArraySize(g_VS_ClearFloat), "Clear11 Float VS", g_PS_ClearFloat, - ArraySize(g_PS_ClearFloat), "Clear11 Float PS"); + mFloatClearShader = new ClearShader(DXGI_FORMAT_R32G32B32A32_FLOAT, + "Clear11 Float IL", + g_VS_ClearFloat, + ArraySize(g_VS_ClearFloat), + "Clear11 Float VS", + g_PS_ClearFloat, + ArraySize(g_PS_ClearFloat), + "Clear11 Float PS"); } if (renderer->isES3Capable()) { - mUintClearShader = - new ClearShader(DXGI_FORMAT_R32G32B32A32_UINT, "Clear11 UINT IL", g_VS_ClearUint, - ArraySize(g_VS_ClearUint), "Clear11 UINT VS", g_PS_ClearUint, - ArraySize(g_PS_ClearUint), "Clear11 UINT PS"); - mIntClearShader = - new ClearShader(DXGI_FORMAT_R32G32B32A32_UINT, "Clear11 SINT IL", g_VS_ClearSint, - ArraySize(g_VS_ClearSint), "Clear11 SINT VS", g_PS_ClearSint, - ArraySize(g_PS_ClearSint), "Clear11 SINT PS"); + mUintClearShader = new ClearShader(DXGI_FORMAT_R32G32B32A32_UINT, + "Clear11 UINT IL", + g_VS_ClearUint, + ArraySize(g_VS_ClearUint), + "Clear11 UINT VS", + g_PS_ClearUint, + ArraySize(g_PS_ClearUint), + "Clear11 UINT PS"); + mIntClearShader = new ClearShader(DXGI_FORMAT_R32G32B32A32_UINT, + "Clear11 SINT IL", + g_VS_ClearSint, + ArraySize(g_VS_ClearSint), + "Clear11 SINT VS", + g_PS_ClearSint, + ArraySize(g_PS_ClearSint), + "Clear11 SINT PS"); } } Clear11::~Clear11() { - for (ClearBlendStateMap::iterator i = mClearBlendStates.begin(); i != mClearBlendStates.end(); - i++) + for (ClearBlendStateMap::iterator i = mClearBlendStates.begin(); i != mClearBlendStates.end(); i++) { SafeRelease(i->second); } @@ -181,8 +186,7 @@ Clear11::~Clear11() SafeDelete(mUintClearShader); SafeDelete(mIntClearShader); - for (ClearDepthStencilStateMap::iterator i = mClearDepthStencilStates.begin(); - i != mClearDepthStencilStates.end(); i++) + for (ClearDepthStencilStateMap::iterator i = mClearDepthStencilStates.begin(); i != mClearDepthStencilStates.end(); i++) { SafeRelease(i->second); } @@ -195,9 +199,9 @@ Clear11::~Clear11() gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl::FramebufferState &fboData) { - const auto &colorAttachments = fboData.getColorAttachments(); - const auto &drawBufferStates = fboData.getDrawBufferStates(); - const auto *depthAttachment = fboData.getDepthAttachment(); + const auto &colorAttachments = fboData.getColorAttachments(); + const auto &drawBufferStates = fboData.getDrawBufferStates(); + const auto *depthAttachment = fboData.getDepthAttachment(); const auto *stencilAttachment = fboData.getStencilAttachment(); ASSERT(colorAttachments.size() == drawBufferStates.size()); @@ -205,24 +209,20 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, // Iterate over the color buffers which require clearing and determine if they can be // cleared with ID3D11DeviceContext::ClearRenderTargetView or ID3D11DeviceContext1::ClearView. // This requires: - // 1) The render target is being cleared to a float value (will be cast to integer when clearing - // integer + // 1) The render target is being cleared to a float value (will be cast to integer when clearing integer // render targets as expected but does not work the other way around) // 2) The format of the render target has no color channels that are currently masked out. - // Clear the easy-to-clear buffers on the spot and accumulate the ones that require special - // work. + // Clear the easy-to-clear buffers on the spot and accumulate the ones that require special work. // // If these conditions are met, and: // - No scissored clear is needed, then clear using ID3D11DeviceContext::ClearRenderTargetView. // - A scissored clear is needed then clear using ID3D11DeviceContext1::ClearView if available. // Otherwise draw a quad. // - // Also determine if the depth stencil can be cleared with - // ID3D11DeviceContext::ClearDepthStencilView + // Also determine if the depth stencil can be cleared with ID3D11DeviceContext::ClearDepthStencilView // by checking if the stencil write mask covers the entire stencil. // - // To clear the remaining buffers, quads must be drawn containing an int, uint or float vertex - // color + // To clear the remaining buffers, quads must be drawn containing an int, uint or float vertex color // attribute. gl::Extents framebufferSize; @@ -246,7 +246,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, return gl::Error(GL_INVALID_OPERATION); } - if (clearParams.scissorEnabled && (clearParams.scissor.x >= framebufferSize.width || + if (clearParams.scissorEnabled && (clearParams.scissor.x >= framebufferSize.width || clearParams.scissor.y >= framebufferSize.height || clearParams.scissor.x + clearParams.scissor.width <= 0 || clearParams.scissor.y + clearParams.scissor.height <= 0)) @@ -255,18 +255,16 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, return gl::Error(GL_NO_ERROR); } - bool needScissoredClear = - clearParams.scissorEnabled && - (clearParams.scissor.x > 0 || clearParams.scissor.y > 0 || - clearParams.scissor.x + clearParams.scissor.width < framebufferSize.width || - clearParams.scissor.y + clearParams.scissor.height < framebufferSize.height); + bool needScissoredClear = clearParams.scissorEnabled && (clearParams.scissor.x > 0 || clearParams.scissor.y > 0 || + clearParams.scissor.x + clearParams.scissor.width < framebufferSize.width || + clearParams.scissor.y + clearParams.scissor.height < framebufferSize.height); std::vector<MaskedRenderTarget> maskedClearRenderTargets; - RenderTarget11 *maskedClearDepthStencil = nullptr; + RenderTarget11* maskedClearDepthStencil = nullptr; - ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext(); + ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext(); ID3D11DeviceContext1 *deviceContext1 = mRenderer->getDeviceContext1IfSupported(); - ID3D11Device *device = mRenderer->getDevice(); + ID3D11Device *device = mRenderer->getDevice(); for (size_t colorAttachmentIndex = 0; colorAttachmentIndex < colorAttachments.size(); colorAttachmentIndex++) @@ -277,7 +275,11 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, drawBufferStates[colorAttachmentIndex] != GL_NONE) { RenderTarget11 *renderTarget = nullptr; - ANGLE_TRY(attachment.getRenderTarget(&renderTarget)); + gl::Error error = attachment.getRenderTarget(&renderTarget); + if (error.isError()) + { + return error; + } const gl::InternalFormat &formatInfo = *attachment.getFormat().info; @@ -309,8 +311,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, (formatInfo.blueBits > 0 && !clearParams.colorMaskBlue) || (formatInfo.alphaBits > 0 && !clearParams.colorMaskAlpha)) { - // A masked clear is required, or a scissored clear is required and - // ID3D11DeviceContext1::ClearView is unavailable + // A masked clear is required, or a scissored clear is required and ID3D11DeviceContext1::ClearView is unavailable MaskedRenderTarget maskAndRt; bool clearColor = clearParams.clearColor[colorAttachmentIndex]; maskAndRt.colorMask[0] = (clearColor && clearParams.colorMaskRed); @@ -322,40 +323,39 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, } else { - // ID3D11DeviceContext::ClearRenderTargetView or ID3D11DeviceContext1::ClearView is - // possible + // ID3D11DeviceContext::ClearRenderTargetView or ID3D11DeviceContext1::ClearView is possible ID3D11RenderTargetView *framebufferRTV = renderTarget->getRenderTargetView(); if (!framebufferRTV) { - return gl::Error(GL_OUT_OF_MEMORY, - "Internal render target view pointer unexpectedly null."); + return gl::Error(GL_OUT_OF_MEMORY, "Internal render target view pointer unexpectedly null."); } - const auto &nativeFormat = renderTarget->getFormatSet().format(); + const auto &dxgiFormatInfo = + d3d11::GetDXGIFormatInfo(renderTarget->getFormatSet().rtvFormat); - // Check if the actual format has a channel that the internal format does not and - // set them to the default values + // Check if the actual format has a channel that the internal format does not and set them to the + // default values float clearValues[4] = { - ((formatInfo.redBits == 0 && nativeFormat.redBits > 0) + ((formatInfo.redBits == 0 && dxgiFormatInfo.redBits > 0) ? 0.0f : clearParams.colorFClearValue.red), - ((formatInfo.greenBits == 0 && nativeFormat.greenBits > 0) + ((formatInfo.greenBits == 0 && dxgiFormatInfo.greenBits > 0) ? 0.0f : clearParams.colorFClearValue.green), - ((formatInfo.blueBits == 0 && nativeFormat.blueBits > 0) + ((formatInfo.blueBits == 0 && dxgiFormatInfo.blueBits > 0) ? 0.0f : clearParams.colorFClearValue.blue), - ((formatInfo.alphaBits == 0 && nativeFormat.alphaBits > 0) + ((formatInfo.alphaBits == 0 && dxgiFormatInfo.alphaBits > 0) ? 1.0f : clearParams.colorFClearValue.alpha), }; - if (formatInfo.alphaBits == 1) + if (dxgiFormatInfo.alphaBits == 1) { - // Some drivers do not correctly handle calling Clear() on a format with 1-bit - // alpha. They can incorrectly round all non-zero values up to 1.0f. Note that - // WARP does not do this. We should handle the rounding for them instead. + // Some drivers do not correctly handle calling Clear() on a format with 1-bit alpha. + // They can incorrectly round all non-zero values up to 1.0f. Note that WARP does not do this. + // We should handle the rounding for them instead. clearValues[3] = (clearParams.colorFClearValue.alpha >= 0.5f) ? 1.0f : 0.0f; } @@ -365,26 +365,16 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, ASSERT(deviceContext1); D3D11_RECT rect; - rect.left = clearParams.scissor.x; - rect.right = clearParams.scissor.x + clearParams.scissor.width; - rect.top = clearParams.scissor.y; + rect.left = clearParams.scissor.x; + rect.right = clearParams.scissor.x + clearParams.scissor.width; + rect.top = clearParams.scissor.y; rect.bottom = clearParams.scissor.y + clearParams.scissor.height; deviceContext1->ClearView(framebufferRTV, clearValues, &rect, 1); - - if (mRenderer->getWorkarounds().callClearTwice) - { - deviceContext1->ClearView(framebufferRTV, clearValues, &rect, 1); - } } else { deviceContext->ClearRenderTargetView(framebufferRTV, clearValues); - - if (mRenderer->getWorkarounds().callClearTwice) - { - deviceContext->ClearRenderTargetView(framebufferRTV, clearValues); - } } } } @@ -392,20 +382,21 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, if (clearParams.clearDepth || clearParams.clearStencil) { - const gl::FramebufferAttachment *attachment = - (depthAttachment != nullptr) ? depthAttachment : stencilAttachment; + const gl::FramebufferAttachment *attachment = (depthAttachment != nullptr) ? depthAttachment : stencilAttachment; ASSERT(attachment != nullptr); RenderTarget11 *renderTarget = nullptr; - ANGLE_TRY(attachment->getRenderTarget(&renderTarget)); + gl::Error error = attachment->getRenderTarget(&renderTarget); + if (error.isError()) + { + return error; + } - const auto &nativeFormat = renderTarget->getFormatSet().format(); + const auto &dxgiFormatInfo = + d3d11::GetDXGIFormatInfo(renderTarget->getFormatSet().dsvFormat); - unsigned int stencilUnmasked = - (stencilAttachment != nullptr) ? (1 << nativeFormat.stencilBits) - 1 : 0; - bool needMaskedStencilClear = - clearParams.clearStencil && - (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked; + unsigned int stencilUnmasked = (stencilAttachment != nullptr) ? (1 << dxgiFormatInfo.stencilBits) - 1 : 0; + bool needMaskedStencilClear = clearParams.clearStencil && (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked; if (needScissoredClear || needMaskedStencilClear) { @@ -416,156 +407,144 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, ID3D11DepthStencilView *framebufferDSV = renderTarget->getDepthStencilView(); if (!framebufferDSV) { - return gl::Error(GL_OUT_OF_MEMORY, - "Internal depth stencil view pointer unexpectedly null."); + return gl::Error(GL_OUT_OF_MEMORY, "Internal depth stencil view pointer unexpectedly null."); } - UINT clearFlags = (clearParams.clearDepth ? D3D11_CLEAR_DEPTH : 0) | - (clearParams.clearStencil ? D3D11_CLEAR_STENCIL : 0); - FLOAT depthClear = gl::clamp01(clearParams.depthClearValue); + UINT clearFlags = (clearParams.clearDepth ? D3D11_CLEAR_DEPTH : 0) | + (clearParams.clearStencil ? D3D11_CLEAR_STENCIL : 0); + FLOAT depthClear = gl::clamp01(clearParams.depthClearValue); UINT8 stencilClear = clearParams.stencilClearValue & 0xFF; - deviceContext->ClearDepthStencilView(framebufferDSV, clearFlags, depthClear, - stencilClear); + deviceContext->ClearDepthStencilView(framebufferDSV, clearFlags, depthClear, stencilClear); } } - if (maskedClearRenderTargets.empty() && !maskedClearDepthStencil) + if (maskedClearRenderTargets.size() > 0 || maskedClearDepthStencil) { - return gl::NoError(); - } + // To clear the render targets and depth stencil in one pass: + // + // Render a quad clipped to the scissor rectangle which draws the clear color and a blend + // state that will perform the required color masking. + // + // The quad's depth is equal to the depth clear value with a depth stencil state that + // will enable or disable depth test/writes if the depth buffer should be cleared or not. + // + // The rasterizer state's stencil is set to always pass or fail based on if the stencil + // should be cleared or not with a stencil write mask of the stencil clear value. + // + // ====================================================================================== + // + // Luckily, the gl spec (ES 3.0.2 pg 183) states that the results of clearing a render- + // buffer that is not normalized fixed point or floating point with floating point values + // are undefined so we can just write floats to them and D3D11 will bit cast them to + // integers. + // + // Also, we don't have to worry about attempting to clear a normalized fixed/floating point + // buffer with integer values because there is no gl API call which would allow it, + // glClearBuffer* calls only clear a single renderbuffer at a time which is verified to + // be a compatible clear type. + + // Bind all the render targets which need clearing + ASSERT(maskedClearRenderTargets.size() <= mRenderer->getNativeCaps().maxDrawBuffers); + std::vector<ID3D11RenderTargetView*> rtvs(maskedClearRenderTargets.size()); + for (unsigned int i = 0; i < maskedClearRenderTargets.size(); i++) + { + RenderTarget11 *renderTarget = maskedClearRenderTargets[i].renderTarget; + ID3D11RenderTargetView *rtv = renderTarget->getRenderTargetView(); + if (!rtv) + { + return gl::Error(GL_OUT_OF_MEMORY, "Internal render target view pointer unexpectedly null."); + } - // To clear the render targets and depth stencil in one pass: - // - // Render a quad clipped to the scissor rectangle which draws the clear color and a blend - // state that will perform the required color masking. - // - // The quad's depth is equal to the depth clear value with a depth stencil state that - // will enable or disable depth test/writes if the depth buffer should be cleared or not. - // - // The rasterizer state's stencil is set to always pass or fail based on if the stencil - // should be cleared or not with a stencil write mask of the stencil clear value. - // - // ====================================================================================== - // - // Luckily, the gl spec (ES 3.0.2 pg 183) states that the results of clearing a render- - // buffer that is not normalized fixed point or floating point with floating point values - // are undefined so we can just write floats to them and D3D11 will bit cast them to - // integers. - // - // Also, we don't have to worry about attempting to clear a normalized fixed/floating point - // buffer with integer values because there is no gl API call which would allow it, - // glClearBuffer* calls only clear a single renderbuffer at a time which is verified to - // be a compatible clear type. - - // Bind all the render targets which need clearing - ASSERT(maskedClearRenderTargets.size() <= mRenderer->getNativeCaps().maxDrawBuffers); - std::vector<ID3D11RenderTargetView *> rtvs(maskedClearRenderTargets.size()); - for (unsigned int i = 0; i < maskedClearRenderTargets.size(); i++) - { - RenderTarget11 *renderTarget = maskedClearRenderTargets[i].renderTarget; - ID3D11RenderTargetView *rtv = renderTarget->getRenderTargetView(); - if (!rtv) + rtvs[i] = rtv; + } + ID3D11DepthStencilView *dsv = maskedClearDepthStencil ? maskedClearDepthStencil->getDepthStencilView() : nullptr; + + ID3D11BlendState *blendState = getBlendState(maskedClearRenderTargets); + const FLOAT blendFactors[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; + const UINT sampleMask = 0xFFFFFFFF; + + ID3D11DepthStencilState *dsState = getDepthStencilState(clearParams); + const UINT stencilClear = clearParams.stencilClearValue & 0xFF; + + // Set the vertices + UINT vertexStride = 0; + const UINT startIdx = 0; + ClearShader *shader = nullptr; + D3D11_MAPPED_SUBRESOURCE mappedResource; + HRESULT result = deviceContext->Map(mVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); + if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, - "Internal render target view pointer unexpectedly null."); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal masked clear vertex buffer, HRESULT: 0x%X.", result); } - rtvs[i] = rtv; - } - ID3D11DepthStencilView *dsv = - maskedClearDepthStencil ? maskedClearDepthStencil->getDepthStencilView() : nullptr; - - ID3D11BlendState *blendState = getBlendState(maskedClearRenderTargets); - const FLOAT blendFactors[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - const UINT sampleMask = 0xFFFFFFFF; - - ID3D11DepthStencilState *dsState = getDepthStencilState(clearParams); - const UINT stencilClear = clearParams.stencilClearValue & 0xFF; - - // Set the vertices - UINT vertexStride = 0; - const UINT startIdx = 0; - ClearShader *shader = nullptr; - D3D11_MAPPED_SUBRESOURCE mappedResource; - HRESULT result = - deviceContext->Map(mVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); - if (FAILED(result)) - { - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to map internal masked clear vertex buffer, HRESULT: 0x%X.", - result); - } - - const gl::Rectangle *scissorPtr = clearParams.scissorEnabled ? &clearParams.scissor : nullptr; - switch (clearParams.colorClearType) - { - case GL_FLOAT: - ApplyVertices(framebufferSize, scissorPtr, clearParams.colorFClearValue, - clearParams.depthClearValue, mappedResource.pData); + const gl::Rectangle *scissorPtr = clearParams.scissorEnabled ? &clearParams.scissor : nullptr; + switch (clearParams.colorClearType) + { + case GL_FLOAT: + ApplyVertices(framebufferSize, scissorPtr, clearParams.colorFClearValue, clearParams.depthClearValue, mappedResource.pData); vertexStride = sizeof(d3d11::PositionDepthColorVertex<float>); - shader = mFloatClearShader; + shader = mFloatClearShader; break; - case GL_UNSIGNED_INT: - ApplyVertices(framebufferSize, scissorPtr, clearParams.colorUIClearValue, - clearParams.depthClearValue, mappedResource.pData); + case GL_UNSIGNED_INT: + ApplyVertices(framebufferSize, scissorPtr, clearParams.colorUIClearValue, clearParams.depthClearValue, mappedResource.pData); vertexStride = sizeof(d3d11::PositionDepthColorVertex<unsigned int>); - shader = mUintClearShader; + shader = mUintClearShader; break; - case GL_INT: - ApplyVertices(framebufferSize, scissorPtr, clearParams.colorIClearValue, - clearParams.depthClearValue, mappedResource.pData); + case GL_INT: + ApplyVertices(framebufferSize, scissorPtr, clearParams.colorIClearValue, clearParams.depthClearValue, mappedResource.pData); vertexStride = sizeof(d3d11::PositionDepthColorVertex<int>); - shader = mIntClearShader; + shader = mIntClearShader; break; - default: + default: UNREACHABLE(); break; - } - - deviceContext->Unmap(mVertexBuffer, 0); - - // Set the viewport to be the same size as the framebuffer - D3D11_VIEWPORT viewport; - viewport.TopLeftX = 0; - viewport.TopLeftY = 0; - viewport.Width = static_cast<FLOAT>(framebufferSize.width); - viewport.Height = static_cast<FLOAT>(framebufferSize.height); - viewport.MinDepth = 0; - viewport.MaxDepth = 1; - deviceContext->RSSetViewports(1, &viewport); - - // Apply state - deviceContext->OMSetBlendState(blendState, blendFactors, sampleMask); - deviceContext->OMSetDepthStencilState(dsState, stencilClear); - deviceContext->RSSetState(mRasterizerState); - - // Apply shaders - deviceContext->IASetInputLayout(shader->inputLayout->resolve(device)); - deviceContext->VSSetShader(shader->vertexShader.resolve(device), nullptr, 0); - deviceContext->PSSetShader(shader->pixelShader.resolve(device), nullptr, 0); - deviceContext->GSSetShader(nullptr, nullptr, 0); - - // Apply vertex buffer - deviceContext->IASetVertexBuffers(0, 1, &mVertexBuffer, &vertexStride, &startIdx); - deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - - // Apply render targets - mRenderer->getStateManager()->setOneTimeRenderTargets(rtvs, dsv); - - // Draw the clear quad - deviceContext->Draw(4, 0); + } - // Clean up - mRenderer->markAllStateDirty(); + deviceContext->Unmap(mVertexBuffer, 0); + + // Set the viewport to be the same size as the framebuffer + D3D11_VIEWPORT viewport; + viewport.TopLeftX = 0; + viewport.TopLeftY = 0; + viewport.Width = static_cast<FLOAT>(framebufferSize.width); + viewport.Height = static_cast<FLOAT>(framebufferSize.height); + viewport.MinDepth = 0; + viewport.MaxDepth = 1; + deviceContext->RSSetViewports(1, &viewport); + + // Apply state + deviceContext->OMSetBlendState(blendState, blendFactors, sampleMask); + deviceContext->OMSetDepthStencilState(dsState, stencilClear); + deviceContext->RSSetState(mRasterizerState); + + // Apply shaders + deviceContext->IASetInputLayout(shader->inputLayout->resolve(device)); + deviceContext->VSSetShader(shader->vertexShader.resolve(device), nullptr, 0); + deviceContext->PSSetShader(shader->pixelShader.resolve(device), nullptr, 0); + deviceContext->GSSetShader(nullptr, nullptr, 0); + + // Apply vertex buffer + deviceContext->IASetVertexBuffers(0, 1, &mVertexBuffer, &vertexStride, &startIdx); + deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + + // Apply render targets + mRenderer->getStateManager()->setOneTimeRenderTargets(rtvs, dsv); + + // Draw the clear quad + deviceContext->Draw(4, 0); + + // Clean up + mRenderer->markAllStateDirty(); + } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } -ID3D11BlendState *Clear11::getBlendState(const std::vector<MaskedRenderTarget> &rts) +ID3D11BlendState *Clear11::getBlendState(const std::vector<MaskedRenderTarget>& rts) { ClearBlendInfo blendKey = {}; for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++) @@ -573,12 +552,11 @@ ID3D11BlendState *Clear11::getBlendState(const std::vector<MaskedRenderTarget> & if (i < rts.size()) { RenderTarget11 *rt = rts[i].renderTarget; - const gl::InternalFormat &formatInfo = - gl::GetInternalFormatInfo(rt->getInternalFormat()); + const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(rt->getInternalFormat()); - blendKey.maskChannels[i][0] = (rts[i].colorMask[0] && formatInfo.redBits > 0); + blendKey.maskChannels[i][0] = (rts[i].colorMask[0] && formatInfo.redBits > 0); blendKey.maskChannels[i][1] = (rts[i].colorMask[1] && formatInfo.greenBits > 0); - blendKey.maskChannels[i][2] = (rts[i].colorMask[2] && formatInfo.blueBits > 0); + blendKey.maskChannels[i][2] = (rts[i].colorMask[2] && formatInfo.blueBits > 0); blendKey.maskChannels[i][3] = (rts[i].colorMask[3] && formatInfo.alphaBits > 0); } else @@ -597,21 +575,22 @@ ID3D11BlendState *Clear11::getBlendState(const std::vector<MaskedRenderTarget> & } else { - D3D11_BLEND_DESC blendDesc = {0}; - blendDesc.AlphaToCoverageEnable = FALSE; + D3D11_BLEND_DESC blendDesc = { 0 }; + blendDesc.AlphaToCoverageEnable = FALSE; blendDesc.IndependentBlendEnable = (rts.size() > 1) ? TRUE : FALSE; for (unsigned int j = 0; j < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; j++) { - blendDesc.RenderTarget[j].BlendEnable = FALSE; - blendDesc.RenderTarget[j].RenderTargetWriteMask = gl_d3d11::ConvertColorMask( - blendKey.maskChannels[j][0], blendKey.maskChannels[j][1], - blendKey.maskChannels[j][2], blendKey.maskChannels[j][3]); + blendDesc.RenderTarget[j].BlendEnable = FALSE; + blendDesc.RenderTarget[j].RenderTargetWriteMask = gl_d3d11::ConvertColorMask(blendKey.maskChannels[j][0], + blendKey.maskChannels[j][1], + blendKey.maskChannels[j][2], + blendKey.maskChannels[j][3]); } - ID3D11Device *device = mRenderer->getDevice(); - ID3D11BlendState *blendState = nullptr; - HRESULT result = device->CreateBlendState(&blendDesc, &blendState); + ID3D11Device *device = mRenderer->getDevice(); + ID3D11BlendState* blendState = nullptr; + HRESULT result = device->CreateBlendState(&blendDesc, &blendState); if (FAILED(result) || !blendState) { ERR("Unable to create a ID3D11BlendState, HRESULT: 0x%X.", result); @@ -626,10 +605,10 @@ ID3D11BlendState *Clear11::getBlendState(const std::vector<MaskedRenderTarget> & ID3D11DepthStencilState *Clear11::getDepthStencilState(const ClearParameters &clearParams) { - ClearDepthStencilInfo dsKey = {0}; - dsKey.clearDepth = clearParams.clearDepth; - dsKey.clearStencil = clearParams.clearStencil; - dsKey.stencilWriteMask = clearParams.stencilWriteMask & 0xFF; + ClearDepthStencilInfo dsKey = { 0 }; + dsKey.clearDepth = clearParams.clearDepth; + dsKey.clearStencil = clearParams.clearStencil; + dsKey.stencilWriteMask = clearParams.stencilWriteMask & 0xFF; ClearDepthStencilStateMap::const_iterator i = mClearDepthStencilStates.find(dsKey); if (i != mClearDepthStencilStates.end()) @@ -638,26 +617,25 @@ ID3D11DepthStencilState *Clear11::getDepthStencilState(const ClearParameters &cl } else { - D3D11_DEPTH_STENCIL_DESC dsDesc = {0}; - dsDesc.DepthEnable = dsKey.clearDepth ? TRUE : FALSE; - dsDesc.DepthWriteMask = - dsKey.clearDepth ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; - dsDesc.DepthFunc = D3D11_COMPARISON_ALWAYS; - dsDesc.StencilEnable = dsKey.clearStencil ? TRUE : FALSE; - dsDesc.StencilReadMask = 0; - dsDesc.StencilWriteMask = dsKey.stencilWriteMask; - dsDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_REPLACE; + D3D11_DEPTH_STENCIL_DESC dsDesc = { 0 }; + dsDesc.DepthEnable = dsKey.clearDepth ? TRUE : FALSE; + dsDesc.DepthWriteMask = dsKey.clearDepth ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; + dsDesc.DepthFunc = D3D11_COMPARISON_ALWAYS; + dsDesc.StencilEnable = dsKey.clearStencil ? TRUE : FALSE; + dsDesc.StencilReadMask = 0; + dsDesc.StencilWriteMask = dsKey.stencilWriteMask; + dsDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_REPLACE; dsDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_REPLACE; - dsDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; - dsDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - dsDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_REPLACE; - dsDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_REPLACE; - dsDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; - dsDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - - ID3D11Device *device = mRenderer->getDevice(); - ID3D11DepthStencilState *dsState = nullptr; - HRESULT result = device->CreateDepthStencilState(&dsDesc, &dsState); + dsDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; + dsDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + dsDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_REPLACE; + dsDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_REPLACE; + dsDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; + dsDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + + ID3D11Device *device = mRenderer->getDevice(); + ID3D11DepthStencilState* dsState = nullptr; + HRESULT result = device->CreateDepthStencilState(&dsDesc, &dsState); if (FAILED(result) || !dsState) { ERR("Unable to create a ID3D11DepthStencilState, HRESULT: 0x%X.", result); @@ -669,4 +647,5 @@ ID3D11DepthStencilState *Clear11::getDepthStencilState(const ClearParameters &cl return dsState; } } + } diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Context11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Context11.cpp index 05da453f0..304bbe8cb 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Context11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Context11.cpp @@ -94,9 +94,9 @@ RenderbufferImpl *Context11::createRenderbuffer() return new RenderbufferD3D(mRenderer); } -BufferImpl *Context11::createBuffer(const gl::BufferState &state) +BufferImpl *Context11::createBuffer() { - Buffer11 *buffer = new Buffer11(state, mRenderer); + Buffer11 *buffer = new Buffer11(mRenderer); mRenderer->onBufferCreate(buffer); return buffer; } diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Context11.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Context11.h index e36a6e978..debf2f9be 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Context11.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Context11.h @@ -39,7 +39,7 @@ class Context11 : public ContextImpl RenderbufferImpl *createRenderbuffer() override; // Buffer creation - BufferImpl *createBuffer(const gl::BufferState &state) override; + BufferImpl *createBuffer() override; // Vertex Array creation VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Fence11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Fence11.cpp index 1f0eedb6e..fb3a18336 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Fence11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Fence11.cpp @@ -4,8 +4,7 @@ // found in the LICENSE file. // -// Fence11.cpp: Defines the rx::FenceNV11 and rx::FenceSync11 classes which implement -// rx::FenceNVImpl and rx::FenceSyncImpl. +// Fence11.cpp: Defines the rx::FenceNV11 and rx::FenceSync11 classes which implement rx::FenceNVImpl and rx::FenceSyncImpl. #include "libANGLE/renderer/d3d/d3d11/Fence11.h" #include "libANGLE/renderer/d3d/d3d11/Renderer11.h" @@ -21,20 +20,19 @@ static const int kDeviceLostCheckPeriod = 64; // Template helpers for set and test operations. // -template <class FenceClass> +template<class FenceClass> gl::Error FenceSetHelper(FenceClass *fence) { if (!fence->mQuery) { D3D11_QUERY_DESC queryDesc; - queryDesc.Query = D3D11_QUERY_EVENT; + queryDesc.Query = D3D11_QUERY_EVENT; queryDesc.MiscFlags = 0; HRESULT result = fence->mRenderer->getDevice()->CreateQuery(&queryDesc, &fence->mQuery); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, "Failed to create event query, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create event query, result: 0x%X.", result); } } @@ -48,8 +46,7 @@ gl::Error FenceTestHelper(FenceClass *fence, bool flushCommandBuffer, GLboolean ASSERT(fence->mQuery); UINT getDataFlags = (flushCommandBuffer ? 0 : D3D11_ASYNC_GETDATA_DONOTFLUSH); - HRESULT result = - fence->mRenderer->getDeviceContext()->GetData(fence->mQuery, NULL, 0, getDataFlags); + HRESULT result = fence->mRenderer->getDeviceContext()->GetData(fence->mQuery, NULL, 0, getDataFlags); if (FAILED(result)) { @@ -65,7 +62,10 @@ gl::Error FenceTestHelper(FenceClass *fence, bool flushCommandBuffer, GLboolean // FenceNV11 // -FenceNV11::FenceNV11(Renderer11 *renderer) : FenceNVImpl(), mRenderer(renderer), mQuery(NULL) +FenceNV11::FenceNV11(Renderer11 *renderer) + : FenceNVImpl(), + mRenderer(renderer), + mQuery(NULL) { } @@ -92,7 +92,11 @@ gl::Error FenceNV11::finish() while (finished != GL_TRUE) { loopCount++; - ANGLE_TRY(FenceTestHelper(this, true, &finished)); + gl::Error error = FenceTestHelper(this, true, &finished); + if (error.isError()) + { + return error; + } if (loopCount % kDeviceLostCheckPeriod == 0 && mRenderer->testDeviceLost()) { @@ -103,7 +107,7 @@ gl::Error FenceNV11::finish() ScheduleYield(); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } // @@ -121,10 +125,14 @@ gl::Error FenceNV11::finish() // We still opt to use QPC. In the present and moving forward, most newer systems will not suffer // from buggy implementations. -FenceSync11::FenceSync11(Renderer11 *renderer) : FenceSyncImpl(), mRenderer(renderer), mQuery(NULL) +FenceSync11::FenceSync11(Renderer11 *renderer) + : FenceSyncImpl(), + mRenderer(renderer), + mQuery(NULL) { LARGE_INTEGER counterFreqency = {}; - BOOL success = QueryPerformanceFrequency(&counterFreqency); + BOOL success = QueryPerformanceFrequency(&counterFreqency); + UNUSED_ASSERTION_VARIABLE(success); ASSERT(success); mCounterFrequency = counterFreqency.QuadPart; @@ -148,7 +156,7 @@ gl::Error FenceSync11::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *ou bool flushCommandBuffer = ((flags & GL_SYNC_FLUSH_COMMANDS_BIT) != 0); GLboolean result = GL_FALSE; - gl::Error error = FenceTestHelper(this, flushCommandBuffer, &result); + gl::Error error = FenceTestHelper(this, flushCommandBuffer, &result); if (error.isError()) { *outResult = GL_WAIT_FAILED; @@ -168,11 +176,12 @@ gl::Error FenceSync11::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *ou } LARGE_INTEGER currentCounter = {}; - BOOL success = QueryPerformanceCounter(¤tCounter); + BOOL success = QueryPerformanceCounter(¤tCounter); + UNUSED_ASSERTION_VARIABLE(success); ASSERT(success); LONGLONG timeoutInSeconds = static_cast<LONGLONG>(timeout) * static_cast<LONGLONG>(1000000ll); - LONGLONG endCounter = currentCounter.QuadPart + mCounterFrequency * timeoutInSeconds; + LONGLONG endCounter = currentCounter.QuadPart + mCounterFrequency * timeoutInSeconds; int loopCount = 0; while (currentCounter.QuadPart < endCounter && !result) @@ -180,6 +189,7 @@ gl::Error FenceSync11::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *ou loopCount++; ScheduleYield(); success = QueryPerformanceCounter(¤tCounter); + UNUSED_ASSERTION_VARIABLE(success); ASSERT(success); error = FenceTestHelper(this, flushCommandBuffer, &result); @@ -212,19 +222,19 @@ gl::Error FenceSync11::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *ou gl::Error FenceSync11::serverWait(GLbitfield flags, GLuint64 timeout) { // Because our API is currently designed to be called from a single thread, we don't need to do - // extra work for a server-side fence. GPU commands issued after the fence is created will - // always be processed after the fence is signaled. + // extra work for a server-side fence. GPU commands issued after the fence is created will always + // be processed after the fence is signaled. return gl::Error(GL_NO_ERROR); } gl::Error FenceSync11::getStatus(GLint *outResult) { GLboolean result = GL_FALSE; - gl::Error error = FenceTestHelper(this, false, &result); + gl::Error error = FenceTestHelper(this, false, &result); if (error.isError()) { - // The spec does not specify any way to report errors during the status test (e.g. device - // lost) so we report the fence is unblocked in case of error or signaled. + // The spec does not specify any way to report errors during the status test (e.g. device lost) + // so we report the fence is unblocked in case of error or signaled. *outResult = GL_SIGNALED; return error; @@ -234,4 +244,4 @@ gl::Error FenceSync11::getStatus(GLint *outResult) return gl::Error(GL_NO_ERROR); } -} // namespace rx +} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp index 90922914a..4e67fa1ef 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp @@ -29,7 +29,7 @@ namespace rx namespace { -gl::Error MarkAttachmentsDirty(const gl::FramebufferAttachment *attachment) +gl::Error InvalidateAttachmentSwizzles(const gl::FramebufferAttachment *attachment) { if (attachment && attachment->type() == GL_TEXTURE) { @@ -45,7 +45,7 @@ gl::Error MarkAttachmentsDirty(const gl::FramebufferAttachment *attachment) TextureStorage11 *texStorage11 = GetAs<TextureStorage11>(texStorage); ASSERT(texStorage11); - texStorage11->markLevelDirty(attachment->mipLevel()); + texStorage11->invalidateSwizzleCacheLevel(attachment->mipLevel()); } } @@ -89,18 +89,18 @@ Framebuffer11::~Framebuffer11() { } -gl::Error Framebuffer11::markAttachmentsDirty() const +gl::Error Framebuffer11::invalidateSwizzles() const { for (const auto &colorAttachment : mState.getColorAttachments()) { if (colorAttachment.isAttached()) { - ANGLE_TRY(MarkAttachmentsDirty(&colorAttachment)); + ANGLE_TRY(InvalidateAttachmentSwizzles(&colorAttachment)); } } - ANGLE_TRY(MarkAttachmentsDirty(mState.getDepthAttachment())); - ANGLE_TRY(MarkAttachmentsDirty(mState.getStencilAttachment())); + ANGLE_TRY(InvalidateAttachmentSwizzles(mState.getDepthAttachment())); + ANGLE_TRY(InvalidateAttachmentSwizzles(mState.getStencilAttachment())); return gl::NoError(); } @@ -128,7 +128,7 @@ gl::Error Framebuffer11::clearImpl(ContextImpl *context, const ClearParameters & ANGLE_TRY(clearer->clearFramebuffer(clearParams, mState)); } - ANGLE_TRY(markAttachmentsDirty()); + ANGLE_TRY(invalidateSwizzles()); return gl::NoError(); } @@ -182,10 +182,7 @@ gl::Error Framebuffer11::invalidateBase(size_t count, const GLenum *attachments, size_t colorIndex = (attachments[i] == GL_COLOR ? 0u : (attachments[i] - GL_COLOR_ATTACHMENT0)); auto colorAttachment = mState.getColorAttachment(colorIndex); - if (colorAttachment) - { - ANGLE_TRY(invalidateAttachment(colorAttachment)); - } + ANGLE_TRY(invalidateAttachment(colorAttachment)); break; } } @@ -354,14 +351,14 @@ gl::Error Framebuffer11::blitImpl(const gl::Rectangle &sourceArea, blitDepth, blitStencil)); } - ANGLE_TRY(markAttachmentsDirty()); + ANGLE_TRY(invalidateSwizzles()); return gl::NoError(); } GLenum Framebuffer11::getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const { RenderTarget11 *renderTarget11 = GetAs<RenderTarget11>(renderTarget); - return renderTarget11->getFormatSet().format().fboImplementationInternalFormat; + return renderTarget11->getFormatSet().format.fboImplementationInternalFormat; } void Framebuffer11::updateColorRenderTarget(size_t colorIndex) diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.h index b1683a206..813e0f32f 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.h @@ -28,7 +28,7 @@ class Framebuffer11 : public FramebufferD3D, public angle::SignalReceiver gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override; // Invalidate the cached swizzles of all bound texture attachments. - gl::Error markAttachmentsDirty() const; + gl::Error invalidateSwizzles() const; void syncState(const gl::Framebuffer::DirtyBits &dirtyBits) override; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp index 3c797f820..d27a8d53a 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp @@ -50,21 +50,25 @@ gl::Error Image11::generateMipmap(Image11 *dest, ASSERT(src->getHeight() == 1 || src->getHeight() / 2 == dest->getHeight()); D3D11_MAPPED_SUBRESOURCE destMapped; - ANGLE_TRY(dest->map(D3D11_MAP_WRITE, &destMapped)); + gl::Error error = dest->map(D3D11_MAP_WRITE, &destMapped); + if (error.isError()) + { + return error; + } D3D11_MAPPED_SUBRESOURCE srcMapped; - gl::Error error = src->map(D3D11_MAP_READ, &srcMapped); + error = src->map(D3D11_MAP_READ, &srcMapped); if (error.isError()) { dest->unmap(); return error; } - const uint8_t *sourceData = reinterpret_cast<const uint8_t *>(srcMapped.pData); - uint8_t *destData = reinterpret_cast<uint8_t *>(destMapped.pData); + const uint8_t *sourceData = reinterpret_cast<const uint8_t*>(srcMapped.pData); + uint8_t *destData = reinterpret_cast<uint8_t*>(destMapped.pData); auto mipGenerationFunction = - d3d11::Format::Get(src->getInternalFormat(), rendererCaps).format().mipGenerationFunction; + d3d11::Format::Get(src->getInternalFormat(), rendererCaps).format.mipGenerationFunction; mipGenerationFunction(src->getWidth(), src->getHeight(), src->getDepth(), sourceData, srcMapped.RowPitch, srcMapped.DepthPitch, destData, destMapped.RowPitch, destMapped.DepthPitch); @@ -74,14 +78,15 @@ gl::Error Image11::generateMipmap(Image11 *dest, dest->markDirty(); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } bool Image11::isDirty() const { - // If mDirty is true AND mStagingTexture doesn't exist AND mStagingTexture doesn't need to be - // recovered from TextureStorage AND the texture doesn't require init data (i.e. a blank new - // texture will suffice) then isDirty should still return false. + // If mDirty is true + // AND mStagingTexture doesn't exist AND mStagingTexture doesn't need to be recovered from TextureStorage + // AND the texture doesn't require init data (i.e. a blank new texture will suffice) + // then isDirty should still return false. if (mDirty && !mStagingTexture && !mRecoverFromStorage) { const Renderer11DeviceCaps &deviceCaps = mRenderer->getRenderer11DeviceCaps(); @@ -95,45 +100,54 @@ bool Image11::isDirty() const return mDirty; } -gl::Error Image11::copyToStorage(TextureStorage *storage, - const gl::ImageIndex &index, - const gl::Box ®ion) +gl::Error Image11::copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box ®ion) { TextureStorage11 *storage11 = GetAs<TextureStorage11>(storage); - // If an app's behavior results in an Image11 copying its data to/from to a TextureStorage - // multiple times, then we should just keep the staging texture around to prevent the copying - // from impacting perf. We allow the Image11 to copy its data to/from TextureStorage once. This - // accounts for an app making a late call to glGenerateMipmap. + // If an app's behavior results in an Image11 copying its data to/from to a TextureStorage multiple times, + // then we should just keep the staging texture around to prevent the copying from impacting perf. + // We allow the Image11 to copy its data to/from TextureStorage once. + // This accounts for an app making a late call to glGenerateMipmap. bool attemptToReleaseStagingTexture = (mRecoveredFromStorageCount < 2); if (attemptToReleaseStagingTexture) { - // If another image is relying on this Storage for its data, then we must let it recover its - // data before we overwrite it. - ANGLE_TRY(storage11->releaseAssociatedImage(index, this)); + // If another image is relying on this Storage for its data, then we must let it recover its data before we overwrite it. + gl::Error error = storage11->releaseAssociatedImage(index, this); + if (error.isError()) + { + return error; + } } - ID3D11Resource *stagingTexture = NULL; + ID3D11Resource *stagingTexture = NULL; unsigned int stagingSubresourceIndex = 0; - ANGLE_TRY(getStagingTexture(&stagingTexture, &stagingSubresourceIndex)); - ANGLE_TRY( - storage11->updateSubresourceLevel(stagingTexture, stagingSubresourceIndex, index, region)); + gl::Error error = getStagingTexture(&stagingTexture, &stagingSubresourceIndex); + if (error.isError()) + { + return error; + } + + error = storage11->updateSubresourceLevel(stagingTexture, stagingSubresourceIndex, index, region); + if (error.isError()) + { + return error; + } // Once the image data has been copied into the Storage, we can release it locally. if (attemptToReleaseStagingTexture) { storage11->associateImage(this, index); releaseStagingTexture(); - mRecoverFromStorage = true; - mAssociatedStorage = storage11; + mRecoverFromStorage = true; + mAssociatedStorage = storage11; mAssociatedImageIndex = index; } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } -bool Image11::isAssociatedStorageValid(TextureStorage11 *textureStorage) const +bool Image11::isAssociatedStorageValid(TextureStorage11* textureStorage) const { return (mAssociatedStorage == textureStorage); } @@ -142,22 +156,28 @@ gl::Error Image11::recoverFromAssociatedStorage() { if (mRecoverFromStorage) { - ANGLE_TRY(createStagingTexture()); + gl::Error error = createStagingTexture(); + if (error.isError()) + { + return error; + } - bool textureStorageCorrect = - mAssociatedStorage->isAssociatedImageValid(mAssociatedImageIndex, this); + bool textureStorageCorrect = mAssociatedStorage->isAssociatedImageValid(mAssociatedImageIndex, this); - // This means that the cached TextureStorage has been modified after this Image11 released - // its copy of its data. This should not have happened. The TextureStorage should have told - // this Image11 to recover its data before it was overwritten. + // This means that the cached TextureStorage has been modified after this Image11 released its copy of its data. + // This should not have happened. The TextureStorage should have told this Image11 to recover its data before it was overwritten. ASSERT(textureStorageCorrect); if (textureStorageCorrect) { // CopySubResource from the Storage to the Staging texture gl::Box region(0, 0, 0, mWidth, mHeight, mDepth); - ANGLE_TRY(mAssociatedStorage->copySubresourceLevel(mStagingTexture, mStagingSubresource, - mAssociatedImageIndex, region)); + error = mAssociatedStorage->copySubresourceLevel(mStagingTexture, mStagingSubresource, mAssociatedImageIndex, region); + if (error.isError()) + { + return error; + } + mRecoveredFromStorageCount += 1; } @@ -165,7 +185,7 @@ gl::Error Image11::recoverFromAssociatedStorage() disassociateStorage(); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void Image11::disassociateStorage() @@ -175,18 +195,17 @@ void Image11::disassociateStorage() // Make the texturestorage release the Image11 too mAssociatedStorage->disassociateImage(mAssociatedImageIndex, this); - mRecoverFromStorage = false; - mAssociatedStorage = NULL; + mRecoverFromStorage = false; + mAssociatedStorage = NULL; mAssociatedImageIndex = gl::ImageIndex::MakeInvalid(); } } -bool Image11::redefine(GLenum target, - GLenum internalformat, - const gl::Extents &size, - bool forceRelease) +bool Image11::redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease) { - if (mWidth != size.width || mHeight != size.height || mInternalFormat != internalformat || + if (mWidth != size.width || + mHeight != size.height || + mInternalFormat != internalformat || forceRelease) { // End the association with the TextureStorage, since that data will be out of date. @@ -194,11 +213,11 @@ bool Image11::redefine(GLenum target, disassociateStorage(); mRecoveredFromStorageCount = 0; - mWidth = size.width; - mHeight = size.height; - mDepth = size.depth; + mWidth = size.width; + mHeight = size.height; + mDepth = size.depth; mInternalFormat = internalformat; - mTarget = target; + mTarget = target; // compute the d3d format that will be used const d3d11::Format &formatInfo = @@ -224,87 +243,93 @@ DXGI_FORMAT Image11::getDXGIFormat() const return mDXGIFormat; } -// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as -// format/type at input +// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input // into the target pixel rectangle. gl::Error Image11::loadData(const gl::Box &area, const gl::PixelUnpackState &unpack, - GLenum inputType, + GLenum type, const void *input, bool applySkipImages) { - const auto sizedInputFormat = getSizedInputFormat(inputType); - const gl::InternalFormat &inputFormat = gl::GetInternalFormatInfo(sizedInputFormat); + const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat); GLuint inputRowPitch = 0; ANGLE_TRY_RESULT( - inputFormat.computeRowPitch(area.width, unpack.alignment, unpack.rowLength), + formatInfo.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength), inputRowPitch); GLuint inputDepthPitch = 0; - ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(area.height, unpack.imageHeight, inputRowPitch), + ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, area.width, area.height, unpack.alignment, + unpack.rowLength, unpack.imageHeight), inputDepthPitch); GLuint inputSkipBytes = 0; ANGLE_TRY_RESULT( - inputFormat.computeSkipBytes(inputRowPitch, inputDepthPitch, unpack, applySkipImages), + formatInfo.computeSkipBytes(inputRowPitch, inputDepthPitch, unpack.skipImages, + unpack.skipRows, unpack.skipPixels, applySkipImages), inputSkipBytes); const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat); - GLuint outputPixelSize = dxgiFormatInfo.pixelBytes; + GLuint outputPixelSize = dxgiFormatInfo.pixelBytes; const d3d11::Format &d3dFormatInfo = d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps()); - LoadImageFunction loadFunction = d3dFormatInfo.getLoadFunctions()(inputType).loadFunction; + LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions(type).loadFunction; D3D11_MAPPED_SUBRESOURCE mappedImage; - ANGLE_TRY(map(D3D11_MAP_WRITE, &mappedImage)); + gl::Error error = map(D3D11_MAP_WRITE, &mappedImage); + if (error.isError()) + { + return error; + } - uint8_t *offsetMappedData = (reinterpret_cast<uint8_t *>(mappedImage.pData) + - (area.y * mappedImage.RowPitch + area.x * outputPixelSize + - area.z * mappedImage.DepthPitch)); + uint8_t *offsetMappedData = (reinterpret_cast<uint8_t*>(mappedImage.pData) + (area.y * mappedImage.RowPitch + area.x * outputPixelSize + area.z * mappedImage.DepthPitch)); loadFunction(area.width, area.height, area.depth, reinterpret_cast<const uint8_t *>(input) + inputSkipBytes, inputRowPitch, inputDepthPitch, offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch); unmap(); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input) { const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat); GLsizei inputRowPitch = 0; - ANGLE_TRY_RESULT(formatInfo.computeRowPitch(area.width, 1, 0), inputRowPitch); + ANGLE_TRY_RESULT(formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0), inputRowPitch); GLsizei inputDepthPitch = 0; - ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(area.height, 0, inputRowPitch), inputDepthPitch); + ANGLE_TRY_RESULT( + formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1, 0, 0), + inputDepthPitch); const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat); - GLuint outputPixelSize = dxgiFormatInfo.pixelBytes; - GLuint outputBlockWidth = dxgiFormatInfo.blockWidth; - GLuint outputBlockHeight = dxgiFormatInfo.blockHeight; + GLuint outputPixelSize = dxgiFormatInfo.pixelBytes; + GLuint outputBlockWidth = dxgiFormatInfo.blockWidth; + GLuint outputBlockHeight = dxgiFormatInfo.blockHeight; ASSERT(area.x % outputBlockWidth == 0); ASSERT(area.y % outputBlockHeight == 0); const d3d11::Format &d3dFormatInfo = d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps()); - LoadImageFunction loadFunction = - d3dFormatInfo.getLoadFunctions()(GL_UNSIGNED_BYTE).loadFunction; + LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions(GL_UNSIGNED_BYTE).loadFunction; D3D11_MAPPED_SUBRESOURCE mappedImage; - ANGLE_TRY(map(D3D11_MAP_WRITE, &mappedImage)); + gl::Error error = map(D3D11_MAP_WRITE, &mappedImage); + if (error.isError()) + { + return error; + } - uint8_t *offsetMappedData = - reinterpret_cast<uint8_t *>(mappedImage.pData) + - ((area.y / outputBlockHeight) * mappedImage.RowPitch + - (area.x / outputBlockWidth) * outputPixelSize + area.z * mappedImage.DepthPitch); + uint8_t* offsetMappedData = reinterpret_cast<uint8_t*>(mappedImage.pData) + ((area.y / outputBlockHeight) * mappedImage.RowPitch + + (area.x / outputBlockWidth) * outputPixelSize + + area.z * mappedImage.DepthPitch); - loadFunction(area.width, area.height, area.depth, reinterpret_cast<const uint8_t *>(input), - inputRowPitch, inputDepthPitch, offsetMappedData, mappedImage.RowPitch, - mappedImage.DepthPitch); + loadFunction(area.width, area.height, area.depth, + reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch, + offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch); unmap(); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error Image11::copyFromTexStorage(const gl::ImageIndex &imageIndex, TextureStorage *source) @@ -312,9 +337,13 @@ gl::Error Image11::copyFromTexStorage(const gl::ImageIndex &imageIndex, TextureS TextureStorage11 *storage11 = GetAs<TextureStorage11>(source); ID3D11Resource *resource = nullptr; - ANGLE_TRY(storage11->getResource(&resource)); + gl::Error error = storage11->getResource(&resource); + if (error.isError()) + { + return error; + } - UINT subresourceIndex = storage11->getSubresourceIndex(imageIndex); + UINT subresourceIndex = storage11->getSubresourceIndex(imageIndex); TextureHelper11 textureHelper = TextureHelper11::MakeAndReference(resource, storage11->getFormatSet()); @@ -336,7 +365,11 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset, if (d3d11Format.texFormat == mDXGIFormat && sourceInternalFormat == mInternalFormat) { RenderTargetD3D *renderTarget = nullptr; - ANGLE_TRY(srcAttachment->getRenderTarget(&renderTarget)); + gl::Error error = srcAttachment->getRenderTarget(&renderTarget); + if (error.isError()) + { + return error; + } RenderTarget11 *rt11 = GetAs<RenderTarget11>(renderTarget); ASSERT(rt11->getTexture()); @@ -352,7 +385,11 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset, // This format requires conversion, so we must copy the texture to staging and manually convert // via readPixels D3D11_MAPPED_SUBRESOURCE mappedImage; - ANGLE_TRY(map(D3D11_MAP_WRITE, &mappedImage)); + gl::Error error = map(D3D11_MAP_WRITE, &mappedImage); + if (error.isError()) + { + return error; + } // determine the offset coordinate into the destination buffer const auto &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat); @@ -366,8 +403,7 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset, const auto &destD3D11Format = d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps()); - auto loadFunction = destD3D11Format.getLoadFunctions()(destFormatInfo.type); - gl::Error error = gl::NoError(); + auto loadFunction = destD3D11Format.loadFunctions(destFormatInfo.type); if (loadFunction.requiresConversion) { size_t bufferSize = destFormatInfo.pixelBytes * sourceArea.width * sourceArea.height; @@ -404,7 +440,11 @@ gl::Error Image11::copyWithoutConversion(const gl::Offset &destOffset, // No conversion needed-- use copyback fastpath ID3D11Resource *stagingTexture = nullptr; unsigned int stagingSubresourceIndex = 0; - ANGLE_TRY(getStagingTexture(&stagingTexture, &stagingSubresourceIndex)); + gl::Error error = getStagingTexture(&stagingTexture, &stagingSubresourceIndex); + if (error.isError()) + { + return error; + } ID3D11Device *device = mRenderer->getDevice(); ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext(); @@ -433,7 +473,7 @@ gl::Error Image11::copyWithoutConversion(const gl::Offset &destOffset, resolveDesc.MiscFlags = 0; ID3D11Texture2D *srcTex2D = NULL; - HRESULT result = device->CreateTexture2D(&resolveDesc, NULL, &srcTex2D); + HRESULT result = device->CreateTexture2D(&resolveDesc, NULL, &srcTex2D); if (FAILED(result)) { return gl::Error(GL_OUT_OF_MEMORY, @@ -469,17 +509,20 @@ gl::Error Image11::copyWithoutConversion(const gl::Offset &destOffset, } mDirty = true; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } -gl::Error Image11::getStagingTexture(ID3D11Resource **outStagingTexture, - unsigned int *outSubresourceIndex) +gl::Error Image11::getStagingTexture(ID3D11Resource **outStagingTexture, unsigned int *outSubresourceIndex) { - ANGLE_TRY(createStagingTexture()); + gl::Error error = createStagingTexture(); + if (error.isError()) + { + return error; + } - *outStagingTexture = mStagingTexture; + *outStagingTexture = mStagingTexture; *outSubresourceIndex = mStagingSubresource; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void Image11::releaseStagingTexture() @@ -501,8 +544,8 @@ gl::Error Image11::createStagingTexture() ID3D11Device *device = mRenderer->getDevice(); HRESULT result; - int lodOffset = 1; - GLsizei width = mWidth; + int lodOffset = 1; + GLsizei width = mWidth; GLsizei height = mHeight; // adjust size if needed for compressed textures @@ -513,24 +556,23 @@ gl::Error Image11::createStagingTexture() ID3D11Texture3D *newTexture = NULL; D3D11_TEXTURE3D_DESC desc; - desc.Width = width; - desc.Height = height; - desc.Depth = mDepth; - desc.MipLevels = lodOffset + 1; - desc.Format = dxgiFormat; - desc.Usage = D3D11_USAGE_STAGING; - desc.BindFlags = 0; + desc.Width = width; + desc.Height = height; + desc.Depth = mDepth; + desc.MipLevels = lodOffset + 1; + desc.Format = dxgiFormat; + desc.Usage = D3D11_USAGE_STAGING; + desc.BindFlags = 0; desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; - desc.MiscFlags = 0; + desc.MiscFlags = 0; if (d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps()) .dataInitializerFunction != NULL) { std::vector<D3D11_SUBRESOURCE_DATA> initialData; std::vector<std::vector<BYTE>> textureData; - d3d11::GenerateInitialTextureData(mInternalFormat, mRenderer->getRenderer11DeviceCaps(), - width, height, mDepth, lodOffset + 1, &initialData, - &textureData); + d3d11::GenerateInitialTextureData(mInternalFormat, mRenderer->getRenderer11DeviceCaps(), width, height, mDepth, + lodOffset + 1, &initialData, &textureData); result = device->CreateTexture3D(&desc, initialData.data(), &newTexture); } @@ -542,39 +584,36 @@ gl::Error Image11::createStagingTexture() if (FAILED(result)) { ASSERT(result == E_OUTOFMEMORY); - return gl::Error(GL_OUT_OF_MEMORY, "Failed to create staging texture, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create staging texture, result: 0x%X.", result); } - mStagingTexture = newTexture; + mStagingTexture = newTexture; mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1); } - else if (mTarget == GL_TEXTURE_2D || mTarget == GL_TEXTURE_2D_ARRAY || - mTarget == GL_TEXTURE_CUBE_MAP) + else if (mTarget == GL_TEXTURE_2D || mTarget == GL_TEXTURE_2D_ARRAY || mTarget == GL_TEXTURE_CUBE_MAP) { ID3D11Texture2D *newTexture = NULL; D3D11_TEXTURE2D_DESC desc; - desc.Width = width; - desc.Height = height; - desc.MipLevels = lodOffset + 1; - desc.ArraySize = 1; - desc.Format = dxgiFormat; - desc.SampleDesc.Count = 1; + desc.Width = width; + desc.Height = height; + desc.MipLevels = lodOffset + 1; + desc.ArraySize = 1; + desc.Format = dxgiFormat; + desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; - desc.Usage = D3D11_USAGE_STAGING; - desc.BindFlags = 0; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; - desc.MiscFlags = 0; + desc.Usage = D3D11_USAGE_STAGING; + desc.BindFlags = 0; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; + desc.MiscFlags = 0; if (d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps()) .dataInitializerFunction != NULL) { std::vector<D3D11_SUBRESOURCE_DATA> initialData; std::vector<std::vector<BYTE>> textureData; - d3d11::GenerateInitialTextureData(mInternalFormat, mRenderer->getRenderer11DeviceCaps(), - width, height, 1, lodOffset + 1, &initialData, - &textureData); + d3d11::GenerateInitialTextureData(mInternalFormat, mRenderer->getRenderer11DeviceCaps(), width, height, 1, + lodOffset + 1, &initialData, &textureData); result = device->CreateTexture2D(&desc, initialData.data(), &newTexture); } @@ -586,11 +625,10 @@ gl::Error Image11::createStagingTexture() if (FAILED(result)) { ASSERT(result == E_OUTOFMEMORY); - return gl::Error(GL_OUT_OF_MEMORY, "Failed to create staging texture, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create staging texture, result: 0x%X.", result); } - mStagingTexture = newTexture; + mStagingTexture = newTexture; mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1); } else @@ -605,11 +643,19 @@ gl::Error Image11::createStagingTexture() gl::Error Image11::map(D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map) { // We must recover from the TextureStorage if necessary, even for D3D11_MAP_WRITE. - ANGLE_TRY(recoverFromAssociatedStorage()); + gl::Error error = recoverFromAssociatedStorage(); + if (error.isError()) + { + return error; + } ID3D11Resource *stagingTexture = NULL; - unsigned int subresourceIndex = 0; - ANGLE_TRY(getStagingTexture(&stagingTexture, &subresourceIndex)); + unsigned int subresourceIndex = 0; + error = getStagingTexture(&stagingTexture, &subresourceIndex); + if (error.isError()) + { + return error; + } ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext(); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Query11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Query11.cpp index 58b18ded5..b256cd51c 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Query11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Query11.cpp @@ -96,11 +96,17 @@ template <typename T> gl::Error Query11::getResultBase(T *params) { ASSERT(mActiveQuery->query == nullptr); - ANGLE_TRY(flush(true)); + + gl::Error error = flush(true); + if (error.isError()) + { + return error; + } + ASSERT(mPendingQueries.empty()); *params = static_cast<T>(mResultSum); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error Query11::getResult(GLint *params) @@ -125,10 +131,14 @@ gl::Error Query11::getResult(GLuint64 *params) gl::Error Query11::isResultAvailable(bool *available) { - ANGLE_TRY(flush(false)); + gl::Error error = flush(false); + if (error.isError()) + { + return error; + } *available = mPendingQueries.empty(); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error Query11::pause() @@ -157,7 +167,11 @@ gl::Error Query11::resume() { if (mActiveQuery->query == nullptr) { - ANGLE_TRY(flush(false)); + gl::Error error = flush(false); + if (error.isError()) + { + return error; + } GLenum queryType = getType(); D3D11_QUERY d3dQueryType = gl_d3d11::ConvertQueryType(queryType); @@ -181,7 +195,7 @@ gl::Error Query11::resume() D3D11_QUERY_DESC desc; desc.Query = D3D11_QUERY_TIMESTAMP; desc.MiscFlags = 0; - result = device->CreateQuery(&desc, &mActiveQuery->beginTimestamp); + result = device->CreateQuery(&desc, &mActiveQuery->beginTimestamp); if (FAILED(result)) { return gl::Error(GL_OUT_OF_MEMORY, "Internal query creation failed, result: 0x%X.", @@ -220,7 +234,11 @@ gl::Error Query11::flush(bool force) do { - ANGLE_TRY(testQuery(query)); + gl::Error error = testQuery(query); + if (error.isError()) + { + return error; + } if (!query->finished && !force) { return gl::Error(GL_NO_ERROR); @@ -231,7 +249,7 @@ gl::Error Query11::flush(bool force) mPendingQueries.pop_front(); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error Query11::testQuery(QueryState *queryState) @@ -241,8 +259,8 @@ gl::Error Query11::testQuery(QueryState *queryState) ID3D11DeviceContext *context = mRenderer->getDeviceContext(); switch (getType()) { - case GL_ANY_SAMPLES_PASSED_EXT: - case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: + case GL_ANY_SAMPLES_PASSED_EXT: + case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: { ASSERT(queryState->query); UINT64 numPixels = 0; @@ -250,35 +268,31 @@ gl::Error Query11::testQuery(QueryState *queryState) context->GetData(queryState->query, &numPixels, sizeof(numPixels), 0); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to get the data of an internal query, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to get the data of an internal query, result: 0x%X.", result); } if (result == S_OK) { queryState->finished = true; - mResult = (numPixels > 0) ? GL_TRUE : GL_FALSE; + mResult = (numPixels > 0) ? GL_TRUE : GL_FALSE; } } break; - case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: + case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: { ASSERT(queryState->query); - D3D11_QUERY_DATA_SO_STATISTICS soStats = {0}; + D3D11_QUERY_DATA_SO_STATISTICS soStats = { 0 }; HRESULT result = context->GetData(queryState->query, &soStats, sizeof(soStats), 0); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to get the data of an internal query, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to get the data of an internal query, result: 0x%X.", result); } if (result == S_OK) { queryState->finished = true; - mResult = static_cast<GLuint64>(soStats.NumPrimitivesWritten); + mResult = static_cast<GLuint64>(soStats.NumPrimitivesWritten); } } break; @@ -355,7 +369,7 @@ gl::Error Query11::testQuery(QueryState *queryState) // to have any sort of continuity outside of a disjoint timestamp query block, which // GL depends on ASSERT(queryState->query == nullptr); - mResult = 0; + mResult = 0; queryState->finished = true; } break; @@ -382,9 +396,9 @@ gl::Error Query11::testQuery(QueryState *queryState) } break; - default: - UNREACHABLE(); - break; + default: + UNREACHABLE(); + break; } if (!queryState->finished && mRenderer->testDeviceLost()) @@ -394,7 +408,7 @@ gl::Error Query11::testQuery(QueryState *queryState) } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } -} // namespace rx +} diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/RenderStateCache.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/RenderStateCache.cpp index bd870bcbd..2ee25cfb6 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/RenderStateCache.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/RenderStateCache.cpp @@ -436,8 +436,7 @@ gl::Error RenderStateCache::getSamplerState(const gl::SamplerState &samplerState samplerDesc.AddressV = gl_d3d11::ConvertTextureWrap(samplerState.wrapT); samplerDesc.AddressW = gl_d3d11::ConvertTextureWrap(samplerState.wrapR); samplerDesc.MipLODBias = 0; - samplerDesc.MaxAnisotropy = - gl_d3d11::ConvertMaxAnisotropy(samplerState.maxAnisotropy, mDevice->GetFeatureLevel()); + samplerDesc.MaxAnisotropy = static_cast<UINT>(samplerState.maxAnisotropy); samplerDesc.ComparisonFunc = gl_d3d11::ConvertComparison(samplerState.compareFunc); samplerDesc.BorderColor[0] = 0.0f; samplerDesc.BorderColor[1] = 0.0f; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/RenderTarget11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/RenderTarget11.cpp index a042f447d..6449c9e6a 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/RenderTarget11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/RenderTarget11.cpp @@ -258,7 +258,7 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv, { mSubresourceIndex = GetRTVSubresourceIndex(mTexture, mRenderTarget); } - ASSERT(mFormatSet.formatID != angle::Format::ID::NONE || mWidth == 0 || mHeight == 0); + ASSERT(mFormatSet.format.id != angle::Format::ID::NONE || mWidth == 0 || mHeight == 0); } TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, @@ -302,7 +302,7 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, { mSubresourceIndex = GetDSVSubresourceIndex(mTexture, mDepthStencil); } - ASSERT(mFormatSet.formatID != angle::Format::ID::NONE || mWidth == 0 || mHeight == 0); + ASSERT(mFormatSet.format.id != angle::Format::ID::NONE || mWidth == 0 || mHeight == 0); } TextureRenderTarget11::~TextureRenderTarget11() diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp index 8b4abaf9c..d03347d25 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp @@ -98,6 +98,23 @@ enum MAX_TEXTURE_IMAGE_UNITS_VTF_SM4 = 16 }; +void CalculateConstantBufferParams(GLintptr offset, GLsizeiptr size, UINT *outFirstConstant, UINT *outNumConstants) +{ + // The offset must be aligned to 256 bytes (should have been enforced by glBindBufferRange). + ASSERT(offset % 256 == 0); + + // firstConstant and numConstants are expressed in constants of 16-bytes. Furthermore they must be a multiple of 16 constants. + *outFirstConstant = static_cast<UINT>(offset / 16); + + // The GL size is not required to be aligned to a 256 bytes boundary. + // Round the size up to a 256 bytes boundary then express the results in constants of 16-bytes. + *outNumConstants = static_cast<UINT>(rx::roundUp(size, static_cast<GLsizeiptr>(256)) / 16); + + // Since the size is rounded up, firstConstant + numConstants may be bigger than the actual size of the buffer. + // This behaviour is explictly allowed according to the documentation on ID3D11DeviceContext1::PSSetConstantBuffers1 + // https://msdn.microsoft.com/en-us/library/windows/desktop/hh404649%28v=vs.85%29.aspx +} + enum ANGLEFeatureLevel { ANGLE_FEATURE_LEVEL_INVALID, @@ -113,20 +130,14 @@ ANGLEFeatureLevel GetANGLEFeatureLevel(D3D_FEATURE_LEVEL d3dFeatureLevel) { switch (d3dFeatureLevel) { - case D3D_FEATURE_LEVEL_9_3: - return ANGLE_FEATURE_LEVEL_9_3; - case D3D_FEATURE_LEVEL_10_0: - return ANGLE_FEATURE_LEVEL_10_0; - case D3D_FEATURE_LEVEL_10_1: - return ANGLE_FEATURE_LEVEL_10_1; - case D3D_FEATURE_LEVEL_11_0: - return ANGLE_FEATURE_LEVEL_11_0; - // Note: we don't ever request a 11_1 device, because this gives - // an E_INVALIDARG error on systems that don't have the platform update. - case D3D_FEATURE_LEVEL_11_1: - return ANGLE_FEATURE_LEVEL_11_1; - default: - return ANGLE_FEATURE_LEVEL_INVALID; + case D3D_FEATURE_LEVEL_9_3: return ANGLE_FEATURE_LEVEL_9_3; + case D3D_FEATURE_LEVEL_10_0: return ANGLE_FEATURE_LEVEL_10_0; + case D3D_FEATURE_LEVEL_10_1: return ANGLE_FEATURE_LEVEL_10_1; + case D3D_FEATURE_LEVEL_11_0: return ANGLE_FEATURE_LEVEL_11_0; + // Note: we don't ever request a 11_1 device, because this gives + // an E_INVALIDARG error on systems that don't have the platform update. + case D3D_FEATURE_LEVEL_11_1: return ANGLE_FEATURE_LEVEL_11_1; + default: return ANGLE_FEATURE_LEVEL_INVALID; } } @@ -394,13 +405,13 @@ Renderer11::Renderer11(egl::Display *display) mAnnotator(nullptr) { mVertexDataManager = NULL; - mIndexDataManager = NULL; + mIndexDataManager = NULL; - mLineLoopIB = NULL; - mTriangleFanIB = NULL; + mLineLoopIB = NULL; + mTriangleFanIB = NULL; mAppliedIBChanged = false; - mBlit = NULL; + mBlit = NULL; mPixelTransfer = NULL; mClear = NULL; @@ -409,31 +420,31 @@ Renderer11::Renderer11(egl::Display *display) mSyncQuery = NULL; - mRenderer11DeviceCaps.supportsClearView = false; + mRenderer11DeviceCaps.supportsClearView = false; mRenderer11DeviceCaps.supportsConstantBufferOffsets = false; - mRenderer11DeviceCaps.supportsDXGI1_2 = false; - mRenderer11DeviceCaps.B5G6R5support = 0; - mRenderer11DeviceCaps.B4G4R4A4support = 0; - mRenderer11DeviceCaps.B5G5R5A1support = 0; + mRenderer11DeviceCaps.supportsDXGI1_2 = false; + mRenderer11DeviceCaps.B5G6R5support = 0; + mRenderer11DeviceCaps.B4G4R4A4support = 0; + mRenderer11DeviceCaps.B5G5R5A1support = 0; - mD3d11Module = NULL; - mDxgiModule = NULL; + mD3d11Module = NULL; + mDxgiModule = NULL; mDCompModule = NULL; mCreatedWithDeviceEXT = false; mEGLDevice = nullptr; - mDevice = NULL; - mDeviceContext = NULL; + mDevice = NULL; + mDeviceContext = NULL; mDeviceContext1 = NULL; - mDxgiAdapter = NULL; - mDxgiFactory = NULL; + mDxgiAdapter = NULL; + mDxgiFactory = NULL; mDriverConstantBufferVS = NULL; mDriverConstantBufferPS = NULL; - mAppliedVertexShader = NULL; + mAppliedVertexShader = NULL; mAppliedGeometryShader = NULL; - mAppliedPixelShader = NULL; + mAppliedPixelShader = NULL; mAppliedTFObject = angle::DirtyPointer; @@ -509,7 +520,7 @@ Renderer11::Renderer11(egl::Display *display) // Also set EGL_PLATFORM_ANGLE_ANGLE variables, in case they're used elsewhere in ANGLE // mAvailableFeatureLevels defaults to empty - mRequestedDriverType = D3D_DRIVER_TYPE_UNKNOWN; + mRequestedDriverType = D3D_DRIVER_TYPE_UNKNOWN; mPresentPathFastEnabled = false; } @@ -540,17 +551,20 @@ egl::Error Renderer11::initialize() { HRESULT result = S_OK; - ANGLE_TRY(initializeD3DDevice()); + egl::Error error = initializeD3DDevice(); + if (error.isError()) + { + return error; + } #if !defined(ANGLE_ENABLE_WINDOWS_STORE) #if !ANGLE_SKIP_DXGI_1_2_CHECK { TRACE_EVENT0("gpu.angle", "Renderer11::initialize (DXGICheck)"); - // In order to create a swap chain for an HWND owned by another process, DXGI 1.2 is - // required. + // In order to create a swap chain for an HWND owned by another process, DXGI 1.2 is required. // The easiest way to check is to query for a IDXGIDevice2. bool requireDXGI1_2 = false; - HWND hwnd = WindowFromDC(mDisplay->getNativeDisplayId()); + HWND hwnd = WindowFromDC(mDisplay->getNativeDisplayId()); if (hwnd) { DWORD currentProcessId = GetCurrentProcessId(); @@ -566,12 +580,12 @@ egl::Error Renderer11::initialize() if (requireDXGI1_2) { IDXGIDevice2 *dxgiDevice2 = NULL; - result = mDevice->QueryInterface(__uuidof(IDXGIDevice2), (void **)&dxgiDevice2); + result = mDevice->QueryInterface(__uuidof(IDXGIDevice2), (void**)&dxgiDevice2); if (FAILED(result)) { - return egl::Error( - EGL_NOT_INITIALIZED, D3D11_INIT_INCOMPATIBLE_DXGI, - "DXGI 1.2 required to present to HWNDs owned by another process."); + return egl::Error(EGL_NOT_INITIALIZED, + D3D11_INIT_INCOMPATIBLE_DXGI, + "DXGI 1.2 required to present to HWNDs owned by another process."); } SafeRelease(dxgiDevice2); } @@ -587,19 +601,21 @@ egl::Error Renderer11::initialize() mDeviceContext1 = d3d11::DynamicCastComObject<ID3D11DeviceContext1>(mDeviceContext); IDXGIDevice *dxgiDevice = NULL; - result = mDevice->QueryInterface(__uuidof(IDXGIDevice), (void **)&dxgiDevice); + result = mDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice); if (FAILED(result)) { - return egl::Error(EGL_NOT_INITIALIZED, D3D11_INIT_OTHER_ERROR, + return egl::Error(EGL_NOT_INITIALIZED, + D3D11_INIT_OTHER_ERROR, "Could not query DXGI device."); } - result = dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void **)&mDxgiAdapter); + result = dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&mDxgiAdapter); if (FAILED(result)) { - return egl::Error(EGL_NOT_INITIALIZED, D3D11_INIT_OTHER_ERROR, + return egl::Error(EGL_NOT_INITIALIZED, + D3D11_INIT_OTHER_ERROR, "Could not retrieve DXGI adapter"); } @@ -607,28 +623,24 @@ egl::Error Renderer11::initialize() IDXGIAdapter2 *dxgiAdapter2 = d3d11::DynamicCastComObject<IDXGIAdapter2>(mDxgiAdapter); - // On D3D_FEATURE_LEVEL_9_*, IDXGIAdapter::GetDesc returns "Software Adapter" for the - // description string. - // If DXGI1.2 is available then IDXGIAdapter2::GetDesc2 can be used to get the actual - // hardware values. + // On D3D_FEATURE_LEVEL_9_*, IDXGIAdapter::GetDesc returns "Software Adapter" for the description string. + // If DXGI1.2 is available then IDXGIAdapter2::GetDesc2 can be used to get the actual hardware values. if (mRenderer11DeviceCaps.featureLevel <= D3D_FEATURE_LEVEL_9_3 && dxgiAdapter2 != NULL) { DXGI_ADAPTER_DESC2 adapterDesc2 = {}; - result = dxgiAdapter2->GetDesc2(&adapterDesc2); + result = dxgiAdapter2->GetDesc2(&adapterDesc2); if (SUCCEEDED(result)) { - // Copy the contents of the DXGI_ADAPTER_DESC2 into mAdapterDescription (a - // DXGI_ADAPTER_DESC). - memcpy(mAdapterDescription.Description, adapterDesc2.Description, - sizeof(mAdapterDescription.Description)); - mAdapterDescription.VendorId = adapterDesc2.VendorId; - mAdapterDescription.DeviceId = adapterDesc2.DeviceId; - mAdapterDescription.SubSysId = adapterDesc2.SubSysId; - mAdapterDescription.Revision = adapterDesc2.Revision; - mAdapterDescription.DedicatedVideoMemory = adapterDesc2.DedicatedVideoMemory; + // Copy the contents of the DXGI_ADAPTER_DESC2 into mAdapterDescription (a DXGI_ADAPTER_DESC). + memcpy(mAdapterDescription.Description, adapterDesc2.Description, sizeof(mAdapterDescription.Description)); + mAdapterDescription.VendorId = adapterDesc2.VendorId; + mAdapterDescription.DeviceId = adapterDesc2.DeviceId; + mAdapterDescription.SubSysId = adapterDesc2.SubSysId; + mAdapterDescription.Revision = adapterDesc2.Revision; + mAdapterDescription.DedicatedVideoMemory = adapterDesc2.DedicatedVideoMemory; mAdapterDescription.DedicatedSystemMemory = adapterDesc2.DedicatedSystemMemory; - mAdapterDescription.SharedSystemMemory = adapterDesc2.SharedSystemMemory; - mAdapterDescription.AdapterLuid = adapterDesc2.AdapterLuid; + mAdapterDescription.SharedSystemMemory = adapterDesc2.SharedSystemMemory; + mAdapterDescription.AdapterLuid = adapterDesc2.AdapterLuid; } } else @@ -640,23 +652,25 @@ egl::Error Renderer11::initialize() if (FAILED(result)) { - return egl::Error(EGL_NOT_INITIALIZED, D3D11_INIT_OTHER_ERROR, + return egl::Error(EGL_NOT_INITIALIZED, + D3D11_INIT_OTHER_ERROR, "Could not read DXGI adaptor description."); } memset(mDescription, 0, sizeof(mDescription)); wcstombs(mDescription, mAdapterDescription.Description, sizeof(mDescription) - 1); - result = mDxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void **)&mDxgiFactory); + result = mDxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&mDxgiFactory); if (!mDxgiFactory || FAILED(result)) { - return egl::Error(EGL_NOT_INITIALIZED, D3D11_INIT_OTHER_ERROR, + return egl::Error(EGL_NOT_INITIALIZED, + D3D11_INIT_OTHER_ERROR, "Could not create DXGI factory."); } } -// Disable some spurious D3D11 debug warnings to prevent them from flooding the output log + // Disable some spurious D3D11 debug warnings to prevent them from flooding the output log #if defined(ANGLE_SUPPRESS_D3D11_HAZARD_WARNINGS) && defined(_DEBUG) { TRACE_EVENT0("gpu.angle", "Renderer11::initialize (HideWarnings)"); @@ -665,12 +679,14 @@ egl::Error Renderer11::initialize() if (SUCCEEDED(result)) { - D3D11_MESSAGE_ID hideMessages[] = { - D3D11_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET}; + D3D11_MESSAGE_ID hideMessages[] = + { + D3D11_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET + }; D3D11_INFO_QUEUE_FILTER filter = {}; filter.DenyList.NumIDs = static_cast<unsigned int>(ArraySize(hideMessages)); - filter.DenyList.pIDList = hideMessages; + filter.DenyList.pIDList = hideMessages; infoQueue->AddStorageFilterEntries(&filter); SafeRelease(infoQueue); @@ -760,8 +776,12 @@ egl::Error Renderer11::initializeD3DDevice() else { // We should use the inputted D3D11 device instead - void *device = nullptr; - ANGLE_TRY(mEGLDevice->getDevice(&device)); + void *device = nullptr; + egl::Error error = mEGLDevice->getDevice(&device); + if (error.isError()) + { + return error; + } ID3D11Device *d3dDevice = reinterpret_cast<ID3D11Device *>(device); if (FAILED(d3dDevice->GetDeviceRemovedReason())) @@ -802,7 +822,7 @@ void Renderer11::initializeDevice() ASSERT(!mVertexDataManager && !mIndexDataManager); mVertexDataManager = new VertexDataManager(this); - mIndexDataManager = new IndexDataManager(this, getRendererClass()); + mIndexDataManager = new IndexDataManager(this, getRendererClass()); ASSERT(!mBlit); mBlit = new Blit11(this); @@ -856,7 +876,8 @@ void Renderer11::initializeDevice() angleFeatureLevel = ANGLE_FEATURE_LEVEL_11_1; } - ANGLE_HISTOGRAM_ENUMERATION("GPU.ANGLE.D3D11FeatureLevel", angleFeatureLevel, + ANGLE_HISTOGRAM_ENUMERATION("GPU.ANGLE.D3D11FeatureLevel", + angleFeatureLevel, NUM_ANGLE_FEATURE_LEVELS); } @@ -864,28 +885,14 @@ void Renderer11::populateRenderer11DeviceCaps() { HRESULT hr = S_OK; - LARGE_INTEGER version; - hr = mDxgiAdapter->CheckInterfaceSupport(__uuidof(IDXGIDevice), &version); - if (FAILED(hr)) - { - mRenderer11DeviceCaps.driverVersion.reset(); - ERR("Error querying driver version from DXGI Adapter."); - } - else - { - mRenderer11DeviceCaps.driverVersion = version; - } - if (mDeviceContext1) { D3D11_FEATURE_DATA_D3D11_OPTIONS d3d11Options; - HRESULT result = mDevice->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &d3d11Options, - sizeof(D3D11_FEATURE_DATA_D3D11_OPTIONS)); + HRESULT result = mDevice->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &d3d11Options, sizeof(D3D11_FEATURE_DATA_D3D11_OPTIONS)); if (SUCCEEDED(result)) { mRenderer11DeviceCaps.supportsClearView = (d3d11Options.ClearView != FALSE); - mRenderer11DeviceCaps.supportsConstantBufferOffsets = - (d3d11Options.ConstantBufferOffsetting != FALSE); + mRenderer11DeviceCaps.supportsConstantBufferOffsets = (d3d11Options.ConstantBufferOffsetting != FALSE); } } @@ -903,15 +910,13 @@ void Renderer11::populateRenderer11DeviceCaps() } } - hr = mDevice->CheckFormatSupport(DXGI_FORMAT_B4G4R4A4_UNORM, - &(mRenderer11DeviceCaps.B4G4R4A4support)); + hr = mDevice->CheckFormatSupport(DXGI_FORMAT_B4G4R4A4_UNORM, &(mRenderer11DeviceCaps.B4G4R4A4support)); if (FAILED(hr)) { mRenderer11DeviceCaps.B4G4R4A4support = 0; } - hr = mDevice->CheckFormatSupport(DXGI_FORMAT_B5G5R5A1_UNORM, - &(mRenderer11DeviceCaps.B5G5R5A1support)); + hr = mDevice->CheckFormatSupport(DXGI_FORMAT_B5G5R5A1_UNORM, &(mRenderer11DeviceCaps.B5G5R5A1support)); if (FAILED(hr)) { mRenderer11DeviceCaps.B5G5R5A1support = 0; @@ -920,6 +925,18 @@ void Renderer11::populateRenderer11DeviceCaps() IDXGIAdapter2 *dxgiAdapter2 = d3d11::DynamicCastComObject<IDXGIAdapter2>(mDxgiAdapter); mRenderer11DeviceCaps.supportsDXGI1_2 = (dxgiAdapter2 != nullptr); SafeRelease(dxgiAdapter2); + + LARGE_INTEGER version; + hr = mDxgiAdapter->CheckInterfaceSupport(__uuidof(IDXGIDevice), &version); + if (FAILED(hr)) + { + mRenderer11DeviceCaps.driverVersion.reset(); + ERR("Error querying driver version from DXGI Adapter."); + } + else + { + mRenderer11DeviceCaps.driverVersion = version; + } } egl::ConfigSet Renderer11::generateConfigs() @@ -943,8 +960,11 @@ egl::ConfigSet Renderer11::generateConfigs() colorBufferFormats.push_back(GL_RGB565); } - static const GLenum depthStencilBufferFormats[] = { - GL_NONE, GL_DEPTH24_STENCIL8_OES, GL_DEPTH_COMPONENT16, + static const GLenum depthStencilBufferFormats[] = + { + GL_NONE, + GL_DEPTH24_STENCIL8_OES, + GL_DEPTH_COMPONENT16, }; const gl::Caps &rendererCaps = getNativeCaps(); @@ -956,8 +976,7 @@ egl::ConfigSet Renderer11::generateConfigs() egl::ConfigSet configs; for (GLenum colorBufferInternalFormat : colorBufferFormats) { - const gl::TextureCaps &colorBufferFormatCaps = - rendererTextureCaps.get(colorBufferInternalFormat); + const gl::TextureCaps &colorBufferFormatCaps = rendererTextureCaps.get(colorBufferInternalFormat); if (!colorBufferFormatCaps.renderable) { continue; @@ -977,7 +996,6 @@ egl::ConfigSet Renderer11::generateConfigs() gl::GetInternalFormatInfo(colorBufferInternalFormat); const gl::InternalFormat &depthStencilBufferFormatInfo = gl::GetInternalFormatInfo(depthStencilBufferInternalFormat); - const gl::Version &maxVersion = getMaxSupportedESVersion(); egl::Config config; config.renderTargetFormat = colorBufferInternalFormat; @@ -990,27 +1008,20 @@ egl::ConfigSet Renderer11::generateConfigs() config.alphaSize = colorBufferFormatInfo.alphaBits; config.alphaMaskSize = 0; config.bindToTextureRGB = (colorBufferFormatInfo.format == GL_RGB); - config.bindToTextureRGBA = (colorBufferFormatInfo.format == GL_RGBA || + config.bindToTextureRGBA = (colorBufferFormatInfo.format == GL_RGBA || colorBufferFormatInfo.format == GL_BGRA_EXT); config.colorBufferType = EGL_RGB_BUFFER; config.configCaveat = EGL_NONE; config.configID = static_cast<EGLint>(configs.size() + 1); + // Can only support a conformant ES2 with feature level greater than 10.0. + config.conformant = (mRenderer11DeviceCaps.featureLevel >= D3D_FEATURE_LEVEL_10_0) + ? (EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT_KHR) + : 0; // PresentPathFast may not be conformant - config.conformant = 0; - if (!mPresentPathFastEnabled) + if (mPresentPathFastEnabled) { - // Can only support a conformant ES2 with feature level greater than 10.0. - if (mRenderer11DeviceCaps.featureLevel >= D3D_FEATURE_LEVEL_10_0) - { - config.conformant |= EGL_OPENGL_ES2_BIT; - } - - // We can only support conformant ES3 on FL 10.1+ - if (maxVersion.major >= 3) - { - config.conformant |= EGL_OPENGL_ES3_BIT_KHR; - } + config.conformant = 0; } config.depthSize = depthStencilBufferFormatInfo.depthBits; @@ -1018,24 +1029,21 @@ egl::ConfigSet Renderer11::generateConfigs() config.matchNativePixmap = EGL_NONE; config.maxPBufferWidth = rendererCaps.max2DTextureSize; config.maxPBufferHeight = rendererCaps.max2DTextureSize; - config.maxPBufferPixels = rendererCaps.max2DTextureSize * rendererCaps.max2DTextureSize; - config.maxSwapInterval = 4; - config.minSwapInterval = 0; - config.nativeRenderable = EGL_FALSE; - config.nativeVisualID = 0; - config.nativeVisualType = EGL_NONE; - - // Can't support ES3 at all without feature level 10.1 - config.renderableType = EGL_OPENGL_ES2_BIT; - if (maxVersion.major >= 3) - { - config.renderableType |= EGL_OPENGL_ES3_BIT_KHR; - } - - config.sampleBuffers = 0; // FIXME: enumerate multi-sampling - config.samples = 0; - config.stencilSize = depthStencilBufferFormatInfo.stencilBits; - config.surfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; + config.maxPBufferPixels = rendererCaps.max2DTextureSize * rendererCaps.max2DTextureSize; + config.maxSwapInterval = 4; + config.minSwapInterval = 0; + config.nativeRenderable = EGL_FALSE; + config.nativeVisualID = 0; + config.nativeVisualType = EGL_NONE; + // Can't support ES3 at all without feature level 10.0 + config.renderableType = + EGL_OPENGL_ES2_BIT | ((mRenderer11DeviceCaps.featureLevel >= D3D_FEATURE_LEVEL_10_0) + ? EGL_OPENGL_ES3_BIT_KHR + : 0); + config.sampleBuffers = 0; // FIXME: enumerate multi-sampling + config.samples = 0; + config.stencilSize = depthStencilBufferFormatInfo.stencilBits; + config.surfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; config.transparentType = EGL_NONE; config.transparentRedValue = 0; config.transparentGreenValue = 0; @@ -1059,9 +1067,8 @@ void Renderer11::generateDisplayExtensions(egl::DisplayExtensions *outExtensions outExtensions->d3dShareHandleClientBuffer = true; outExtensions->surfaceD3DTexture2DShareHandle = true; } - outExtensions->d3dTextureClientBuffer = true; - outExtensions->keyedMutex = true; + outExtensions->keyedMutex = true; outExtensions->querySurfacePointer = true; outExtensions->windowFixedSize = true; @@ -1105,15 +1112,14 @@ gl::Error Renderer11::finish() if (!mSyncQuery) { D3D11_QUERY_DESC queryDesc; - queryDesc.Query = D3D11_QUERY_EVENT; + queryDesc.Query = D3D11_QUERY_EVENT; queryDesc.MiscFlags = 0; result = mDevice->CreateQuery(&queryDesc, &mSyncQuery); ASSERT(SUCCEEDED(result)); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, "Failed to create event query, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create event query, result: 0x%X.", result); } } @@ -1129,8 +1135,7 @@ gl::Error Renderer11::finish() result = mDeviceContext->GetData(mSyncQuery, NULL, 0, flags); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, "Failed to get event query data, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to get event query data, result: 0x%X.", result); } // Keep polling, but allow other threads to do something useful first @@ -1141,7 +1146,8 @@ gl::Error Renderer11::finish() mDisplay->notifyDeviceLost(); return gl::Error(GL_OUT_OF_MEMORY, "Device was lost while waiting for sync."); } - } while (result == S_FALSE); + } + while (result == S_FALSE); return gl::Error(GL_NO_ERROR); } @@ -1169,124 +1175,19 @@ NativeWindowD3D *Renderer11::createNativeWindow(EGLNativeWindowType window, #endif } -egl::Error Renderer11::getD3DTextureInfo(IUnknown *d3dTexture, - EGLint *width, - EGLint *height, - GLenum *fboFormat) const -{ - ID3D11Texture2D *texture = d3d11::DynamicCastComObject<ID3D11Texture2D>(d3dTexture); - if (texture == nullptr) - { - return egl::Error(EGL_BAD_PARAMETER, "client buffer is not a ID3D11Texture2D"); - } - - ID3D11Device *textureDevice = nullptr; - texture->GetDevice(&textureDevice); - if (textureDevice != mDevice) - { - SafeRelease(texture); - return egl::Error(EGL_BAD_PARAMETER, "Texture's device does not match."); - } - SafeRelease(textureDevice); - - D3D11_TEXTURE2D_DESC desc = {0}; - texture->GetDesc(&desc); - SafeRelease(texture); - - if (width) - { - *width = static_cast<EGLint>(desc.Width); - } - if (height) - { - *height = static_cast<EGLint>(desc.Height); - } - - // From table egl.restrictions in EGL_ANGLE_d3d_texture_client_buffer. - switch (desc.Format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - break; - - default: - return egl::Error(EGL_BAD_PARAMETER, "Unknown client buffer texture format: %u.", - desc.Format); - } - - if (fboFormat) - { - const angle::Format &angleFormat = d3d11_angle::GetFormat(desc.Format); - *fboFormat = angleFormat.fboImplementationInternalFormat; - } - - return egl::Error(EGL_SUCCESS); -} - -egl::Error Renderer11::validateShareHandle(const egl::Config *config, - HANDLE shareHandle, - const egl::AttributeMap &attribs) const -{ - if (shareHandle == nullptr) - { - return egl::Error(EGL_BAD_PARAMETER, "NULL share handle."); - } - - ID3D11Resource *tempResource11 = nullptr; - HRESULT result = mDevice->OpenSharedResource(shareHandle, __uuidof(ID3D11Resource), - (void **)&tempResource11); - if (FAILED(result)) - { - return egl::Error(EGL_BAD_PARAMETER, "Failed to open share handle, result: 0x%X.", result); - } - - ID3D11Texture2D *texture2D = d3d11::DynamicCastComObject<ID3D11Texture2D>(tempResource11); - SafeRelease(tempResource11); - - if (texture2D == nullptr) - { - return egl::Error(EGL_BAD_PARAMETER, - "Failed to query ID3D11Texture2D object from share handle."); - } - - D3D11_TEXTURE2D_DESC desc = {0}; - texture2D->GetDesc(&desc); - SafeRelease(texture2D); - - EGLint width = attribs.getAsInt(EGL_WIDTH, 0); - EGLint height = attribs.getAsInt(EGL_HEIGHT, 0); - ASSERT(width != 0 && height != 0); - - const d3d11::Format &backbufferFormatInfo = - d3d11::Format::Get(config->renderTargetFormat, getRenderer11DeviceCaps()); - - if (desc.Width != static_cast<UINT>(width) || desc.Height != static_cast<UINT>(height) || - desc.Format != backbufferFormatInfo.texFormat || desc.MipLevels != 1 || desc.ArraySize != 1) - { - return egl::Error(EGL_BAD_PARAMETER, "Invalid texture parameters in share handle texture."); - } - - return egl::Error(EGL_SUCCESS); -} - SwapChainD3D *Renderer11::createSwapChain(NativeWindowD3D *nativeWindow, HANDLE shareHandle, - IUnknown *d3dTexture, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) { - return new SwapChain11(this, GetAs<NativeWindow11>(nativeWindow), shareHandle, d3dTexture, - backBufferFormat, depthBufferFormat, orientation); + return new SwapChain11(this, GetAs<NativeWindow11>(nativeWindow), shareHandle, backBufferFormat, + depthBufferFormat, orientation); } void *Renderer11::getD3DDevice() { - return reinterpret_cast<void *>(mDevice); + return reinterpret_cast<void*>(mDevice); } gl::Error Renderer11::generateSwizzle(gl::Texture *texture) @@ -1297,13 +1198,21 @@ gl::Error Renderer11::generateSwizzle(gl::Texture *texture) ASSERT(textureD3D); TextureStorage *texStorage = nullptr; - ANGLE_TRY(textureD3D->getNativeTexture(&texStorage)); + gl::Error error = textureD3D->getNativeTexture(&texStorage); + if (error.isError()) + { + return error; + } if (texStorage) { - TextureStorage11 *storage11 = GetAs<TextureStorage11>(texStorage); + TextureStorage11 *storage11 = GetAs<TextureStorage11>(texStorage); const gl::TextureState &textureState = texture->getTextureState(); - ANGLE_TRY(storage11->generateSwizzles(textureState.getSwizzleState())); + error = storage11->generateSwizzles(textureState.getSwizzleState()); + if (error.isError()) + { + return error; + } } } @@ -1349,7 +1258,11 @@ gl::Error Renderer11::setSamplerState(gl::SamplerType type, TextureD3D *textureD3D = GetImplAs<TextureD3D>(texture); TextureStorage *storage = nullptr; - ANGLE_TRY(textureD3D->getNativeTexture(&storage)); + gl::Error error = textureD3D->getNativeTexture(&storage); + if (error.isError()) + { + return error; + } // Storage should exist, texture should be complete ASSERT(storage); @@ -1367,7 +1280,11 @@ gl::Error Renderer11::setSamplerState(gl::SamplerType type, memcmp(&samplerState, &mCurPixelSamplerStates[index], sizeof(gl::SamplerState)) != 0) { ID3D11SamplerState *dxSamplerState = NULL; - ANGLE_TRY(mStateCache.getSamplerState(samplerState, &dxSamplerState)); + error = mStateCache.getSamplerState(samplerState, &dxSamplerState); + if (error.isError()) + { + return error; + } ASSERT(dxSamplerState != NULL); mDeviceContext->PSSetSamplers(index, 1, &dxSamplerState); @@ -1387,7 +1304,11 @@ gl::Error Renderer11::setSamplerState(gl::SamplerType type, memcmp(&samplerState, &mCurVertexSamplerStates[index], sizeof(gl::SamplerState)) != 0) { ID3D11SamplerState *dxSamplerState = NULL; - ANGLE_TRY(mStateCache.getSamplerState(samplerState, &dxSamplerState)); + error = mStateCache.getSamplerState(samplerState, &dxSamplerState); + if (error.isError()) + { + return error; + } ASSERT(dxSamplerState != NULL); mDeviceContext->VSSetSamplers(index, 1, &dxSamplerState); @@ -1399,13 +1320,12 @@ gl::Error Renderer11::setSamplerState(gl::SamplerType type, metadata = &mSamplerMetadataVS; } - else - UNREACHABLE(); + else UNREACHABLE(); ASSERT(metadata != nullptr); metadata->update(index, *texture); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *texture) @@ -1417,7 +1337,11 @@ gl::Error Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *t TextureD3D *textureImpl = GetImplAs<TextureD3D>(texture); TextureStorage *texStorage = nullptr; - ANGLE_TRY(textureImpl->getNativeTexture(&texStorage)); + gl::Error error = textureImpl->getNativeTexture(&texStorage); + if (error.isError()) + { + return error; + } // Texture should be complete and have a storage ASSERT(texStorage); @@ -1426,8 +1350,8 @@ gl::Error Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *t ANGLE_TRY(storage11->getSRV(texture->getTextureState(), &textureSRV)); - // If we get NULL back from getSRV here, something went wrong in the texture class and we're - // unexpectedly missing the shader resource view + // If we get NULL back from getSRV here, something went wrong in the texture class and we're unexpectedly + // missing the shader resource view ASSERT(textureSRV != NULL); textureImpl->resetDirty(); @@ -1447,8 +1371,7 @@ gl::Error Renderer11::setUniformBuffers(const gl::ContextState &data, const std::vector<GLint> &vertexUniformBuffers, const std::vector<GLint> &fragmentUniformBuffers) { - for (size_t uniformBufferIndex = 0; uniformBufferIndex < vertexUniformBuffers.size(); - uniformBufferIndex++) + for (size_t uniformBufferIndex = 0; uniformBufferIndex < vertexUniformBuffers.size(); uniformBufferIndex++) { GLint binding = vertexUniformBuffers[uniformBufferIndex]; @@ -1469,12 +1392,10 @@ gl::Error Renderer11::setUniformBuffers(const gl::ContextState &data, Buffer11 *bufferStorage = GetImplAs<Buffer11>(uniformBuffer.get()); ID3D11Buffer *constantBuffer = nullptr; - UINT firstConstant = 0; - UINT numConstants = 0; - ANGLE_TRY(bufferStorage->getConstantBufferRange(uniformBufferOffset, uniformBufferSize, - &constantBuffer, &firstConstant, - &numConstants)); + ANGLE_TRY_RESULT( + bufferStorage->getConstantBufferRange(uniformBufferOffset, uniformBufferSize), + constantBuffer); if (!constantBuffer) { @@ -1485,9 +1406,11 @@ gl::Error Renderer11::setUniformBuffers(const gl::ContextState &data, mCurrentConstantBufferVSOffset[uniformBufferIndex] != uniformBufferOffset || mCurrentConstantBufferVSSize[uniformBufferIndex] != uniformBufferSize) { - if (firstConstant != 0 && uniformBufferSize != 0) + if (mRenderer11DeviceCaps.supportsConstantBufferOffsets && uniformBufferSize != 0) { - ASSERT(numConstants != 0); + UINT firstConstant = 0, numConstants = 0; + CalculateConstantBufferParams(uniformBufferOffset, uniformBufferSize, + &firstConstant, &numConstants); mDeviceContext1->VSSetConstantBuffers1( getReservedVertexUniformBuffers() + static_cast<unsigned int>(uniformBufferIndex), @@ -1507,8 +1430,7 @@ gl::Error Renderer11::setUniformBuffers(const gl::ContextState &data, } } - for (size_t uniformBufferIndex = 0; uniformBufferIndex < fragmentUniformBuffers.size(); - uniformBufferIndex++) + for (size_t uniformBufferIndex = 0; uniformBufferIndex < fragmentUniformBuffers.size(); uniformBufferIndex++) { GLint binding = fragmentUniformBuffers[uniformBufferIndex]; @@ -1529,12 +1451,10 @@ gl::Error Renderer11::setUniformBuffers(const gl::ContextState &data, Buffer11 *bufferStorage = GetImplAs<Buffer11>(uniformBuffer.get()); ID3D11Buffer *constantBuffer = nullptr; - UINT firstConstant = 0; - UINT numConstants = 0; - ANGLE_TRY(bufferStorage->getConstantBufferRange(uniformBufferOffset, uniformBufferSize, - &constantBuffer, &firstConstant, - &numConstants)); + ANGLE_TRY_RESULT( + bufferStorage->getConstantBufferRange(uniformBufferOffset, uniformBufferSize), + constantBuffer); if (!constantBuffer) { @@ -1545,8 +1465,11 @@ gl::Error Renderer11::setUniformBuffers(const gl::ContextState &data, mCurrentConstantBufferPSOffset[uniformBufferIndex] != uniformBufferOffset || mCurrentConstantBufferPSSize[uniformBufferIndex] != uniformBufferSize) { - if (firstConstant != 0 && uniformBufferSize != 0) + if (mRenderer11DeviceCaps.supportsConstantBufferOffsets && uniformBufferSize != 0) { + UINT firstConstant = 0, numConstants = 0; + CalculateConstantBufferParams(uniformBufferOffset, uniformBufferSize, + &firstConstant, &numConstants); mDeviceContext1->PSSetConstantBuffers1( getReservedFragmentUniformBuffers() + static_cast<unsigned int>(uniformBufferIndex), @@ -1592,17 +1515,7 @@ gl::Error Renderer11::updateState(const gl::ContextState &data, GLenum drawMode) mStateManager.setScissorRectangle(glState.getScissor(), glState.isScissorTestEnabled()); // Applying rasterizer state to D3D11 device - // Since framebuffer->getSamples will return the original samples which may be different with - // the sample counts that we set in render target view, here we use renderTarget->getSamples to - // get the actual samples. - GLsizei samples = 0; - if (firstColorAttachment) - { - ASSERT(firstColorAttachment->isAttached()); - RenderTarget11 *renderTarget = nullptr; - ANGLE_TRY(firstColorAttachment->getRenderTarget(&renderTarget)); - samples = renderTarget->getSamples(); - } + int samples = framebuffer->getSamples(data); gl::RasterizerState rasterizer = glState.getRasterizerState(); rasterizer.pointDrawMode = (drawMode == GL_POINTS); rasterizer.multiSample = (samples != 0); @@ -1628,44 +1541,22 @@ bool Renderer11::applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSi switch (mode) { - case GL_POINTS: - primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; - minCount = 1; - break; - case GL_LINES: - primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINELIST; - minCount = 2; - break; - case GL_LINE_LOOP: - primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; - minCount = 2; - break; - case GL_LINE_STRIP: - primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; - minCount = 2; - break; - case GL_TRIANGLES: - primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; - minCount = 3; - break; - case GL_TRIANGLE_STRIP: - primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; - minCount = 3; - break; - // emulate fans via rewriting index buffer - case GL_TRIANGLE_FAN: - primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; - minCount = 3; - break; - default: - UNREACHABLE(); - return false; + case GL_POINTS: primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; minCount = 1; break; + case GL_LINES: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINELIST; minCount = 2; break; + case GL_LINE_LOOP: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; minCount = 2; break; + case GL_LINE_STRIP: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; minCount = 2; break; + case GL_TRIANGLES: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; minCount = 3; break; + case GL_TRIANGLE_STRIP: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; minCount = 3; break; + // emulate fans via rewriting index buffer + case GL_TRIANGLE_FAN: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; minCount = 3; break; + default: + UNREACHABLE(); + return false; } // If instanced pointsprite emulation is being used and If gl_PointSize is used in the shader, // GL_POINTS mode is expected to render pointsprites. - // Instanced PointSprite emulation requires that the topology to be - // D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST. + // Instanced PointSprite emulation requires that the topology to be D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST. if (mode == GL_POINTS && usesPointSize && getWorkarounds().useInstancedPointSpriteEmulation) { primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; @@ -1695,10 +1586,18 @@ gl::Error Renderer11::applyVertexBuffer(const gl::State &state, const auto &vertexArray = state.getVertexArray(); auto *vertexArray11 = GetImplAs<VertexArray11>(vertexArray); - ANGLE_TRY(vertexArray11->updateDirtyAndDynamicAttribs(mVertexDataManager, state, first, count, - instances)); + gl::Error error = vertexArray11->updateDirtyAndDynamicAttribs(mVertexDataManager, state, first, + count, instances); + if (error.isError()) + { + return error; + } - ANGLE_TRY(mStateManager.updateCurrentValueAttribs(state, mVertexDataManager)); + error = mStateManager.updateCurrentValueAttribs(state, mVertexDataManager); + if (error.isError()) + { + return error; + } // If index information is passed, mark it with the current changed status. if (indexInfo) @@ -1742,8 +1641,7 @@ gl::Error Renderer11::applyIndexBuffer(const gl::ContextState &data, indexInfo, glState.isPrimitiveRestartEnabled())); ID3D11Buffer *buffer = nullptr; - DXGI_FORMAT bufferFormat = - (indexInfo->indexType == GL_UNSIGNED_INT) ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT; + DXGI_FORMAT bufferFormat = (indexInfo->indexType == GL_UNSIGNED_INT) ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT; if (indexInfo->storage) { @@ -1752,19 +1650,18 @@ gl::Error Renderer11::applyIndexBuffer(const gl::ContextState &data, } else { - IndexBuffer11 *indexBuffer = GetAs<IndexBuffer11>(indexInfo->indexBuffer); - buffer = indexBuffer->getBuffer(); + IndexBuffer11* indexBuffer = GetAs<IndexBuffer11>(indexInfo->indexBuffer); + buffer = indexBuffer->getBuffer(); } mAppliedIBChanged = false; - if (buffer != mAppliedIB || bufferFormat != mAppliedIBFormat || - indexInfo->startOffset != mAppliedIBOffset) + if (buffer != mAppliedIB || bufferFormat != mAppliedIBFormat || indexInfo->startOffset != mAppliedIBOffset) { mDeviceContext->IASetIndexBuffer(buffer, bufferFormat, indexInfo->startOffset); - mAppliedIB = buffer; - mAppliedIBFormat = bufferFormat; - mAppliedIBOffset = indexInfo->startOffset; + mAppliedIB = buffer; + mAppliedIBFormat = bufferFormat; + mAppliedIBOffset = indexInfo->startOffset; mAppliedIBChanged = true; } @@ -1834,8 +1731,12 @@ gl::Error Renderer11::drawArraysImpl(const gl::ContextState &data, } rx::ShaderExecutableD3D *pixelExe = nullptr; - ANGLE_TRY( - programD3D->getPixelExecutableForFramebuffer(glState.getDrawFramebuffer(), &pixelExe)); + gl::Error error = + programD3D->getPixelExecutableForFramebuffer(glState.getDrawFramebuffer(), &pixelExe); + if (error.isError()) + { + return error; + } // Skip the draw call if rasterizer discard is enabled (or no fragment shader). if (!pixelExe || glState.getRasterizerState().rasterizerDiscard) @@ -1849,8 +1750,12 @@ gl::Error Renderer11::drawArraysImpl(const gl::ContextState &data, // Retrieve the geometry shader. rx::ShaderExecutableD3D *geometryExe = nullptr; - ANGLE_TRY( - programD3D->getGeometryExecutableForPrimitiveType(data, mode, &geometryExe, nullptr)); + error = + programD3D->getGeometryExecutableForPrimitiveType(data, mode, &geometryExe, nullptr); + if (error.isError()) + { + return error; + } ID3D11GeometryShader *geometryShader = (geometryExe ? GetAs<ShaderExecutable11>(geometryExe)->getGeometryShader() : NULL); @@ -2009,10 +1914,14 @@ gl::Error Renderer11::drawLineLoop(const gl::ContextState &data, if (type != GL_NONE && elementArrayBuffer) { BufferD3D *storage = GetImplAs<BufferD3D>(elementArrayBuffer); - intptr_t offset = reinterpret_cast<intptr_t>(indices); + intptr_t offset = reinterpret_cast<intptr_t>(indices); const uint8_t *bufferData = NULL; - ANGLE_TRY(storage->getData(&bufferData)); + gl::Error error = storage->getData(&bufferData); + if (error.isError()) + { + return error; + } indices = bufferData + offset; } @@ -2020,8 +1929,7 @@ gl::Error Renderer11::drawLineLoop(const gl::ContextState &data, if (!mLineLoopIB) { mLineLoopIB = new StreamingIndexBufferInterface(this); - gl::Error error = - mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT); + gl::Error error = mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT); if (error.isError()) { SafeDelete(mLineLoopIB); @@ -2032,12 +1940,9 @@ gl::Error Renderer11::drawLineLoop(const gl::ContextState &data, // Checked by Renderer11::applyPrimitiveType ASSERT(count >= 0); - if (static_cast<unsigned int>(count) + 1 > - (std::numeric_limits<unsigned int>::max() / sizeof(unsigned int))) + if (static_cast<unsigned int>(count) + 1 > (std::numeric_limits<unsigned int>::max() / sizeof(unsigned int))) { - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to create a 32-bit looping index buffer for GL_LINE_LOOP, too " - "many indices required."); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create a 32-bit looping index buffer for GL_LINE_LOOP, too many indices required."); } GetLineLoopIndices(indices, type, static_cast<GLuint>(count), @@ -2045,33 +1950,45 @@ gl::Error Renderer11::drawLineLoop(const gl::ContextState &data, unsigned int spaceNeeded = static_cast<unsigned int>(sizeof(GLuint) * mScratchIndexDataBuffer.size()); - ANGLE_TRY(mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT)); + gl::Error error = mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT); + if (error.isError()) + { + return error; + } - void *mappedMemory = NULL; + void* mappedMemory = NULL; unsigned int offset; - ANGLE_TRY(mLineLoopIB->mapBuffer(spaceNeeded, &mappedMemory, &offset)); + error = mLineLoopIB->mapBuffer(spaceNeeded, &mappedMemory, &offset); + if (error.isError()) + { + return error; + } // Copy over the converted index data. memcpy(mappedMemory, &mScratchIndexDataBuffer[0], sizeof(GLuint) * mScratchIndexDataBuffer.size()); - ANGLE_TRY(mLineLoopIB->unmapBuffer()); + error = mLineLoopIB->unmapBuffer(); + if (error.isError()) + { + return error; + } - IndexBuffer11 *indexBuffer = GetAs<IndexBuffer11>(mLineLoopIB->getIndexBuffer()); + IndexBuffer11 *indexBuffer = GetAs<IndexBuffer11>(mLineLoopIB->getIndexBuffer()); ID3D11Buffer *d3dIndexBuffer = indexBuffer->getBuffer(); - DXGI_FORMAT indexFormat = indexBuffer->getIndexFormat(); + DXGI_FORMAT indexFormat = indexBuffer->getIndexFormat(); if (mAppliedIB != d3dIndexBuffer || mAppliedIBFormat != indexFormat || mAppliedIBOffset != offset) { mDeviceContext->IASetIndexBuffer(d3dIndexBuffer, indexFormat, offset); - mAppliedIB = d3dIndexBuffer; + mAppliedIB = d3dIndexBuffer; mAppliedIBFormat = indexFormat; mAppliedIBOffset = offset; } INT baseVertexLocation = (indexInfo ? -static_cast<int>(indexInfo->indexRange.start) : 0); - UINT indexCount = static_cast<UINT>(mScratchIndexDataBuffer.size()); + UINT indexCount = static_cast<UINT>(mScratchIndexDataBuffer.size()); if (instances > 0) { @@ -2082,7 +1999,7 @@ gl::Error Renderer11::drawLineLoop(const gl::ContextState &data, mDeviceContext->DrawIndexed(indexCount, 0, baseVertexLocation); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error Renderer11::drawTriangleFan(const gl::ContextState &data, @@ -2101,10 +2018,14 @@ gl::Error Renderer11::drawTriangleFan(const gl::ContextState &data, if (type != GL_NONE && elementArrayBuffer) { BufferD3D *storage = GetImplAs<BufferD3D>(elementArrayBuffer); - intptr_t offset = reinterpret_cast<intptr_t>(indices); + intptr_t offset = reinterpret_cast<intptr_t>(indices); const uint8_t *bufferData = NULL; - ANGLE_TRY(storage->getData(&bufferData)); + gl::Error error = storage->getData(&bufferData); + if (error.isError()) + { + return error; + } indexPointer = bufferData + offset; } @@ -2112,8 +2033,7 @@ gl::Error Renderer11::drawTriangleFan(const gl::ContextState &data, if (!mTriangleFanIB) { mTriangleFanIB = new StreamingIndexBufferInterface(this); - gl::Error error = - mTriangleFanIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT); + gl::Error error = mTriangleFanIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT); if (error.isError()) { SafeDelete(mTriangleFanIB); @@ -2128,9 +2048,7 @@ gl::Error Renderer11::drawTriangleFan(const gl::ContextState &data, if (numTris > (std::numeric_limits<unsigned int>::max() / (sizeof(unsigned int) * 3))) { - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to create a scratch index buffer for GL_TRIANGLE_FAN, too many " - "indices required."); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create a scratch index buffer for GL_TRIANGLE_FAN, too many indices required."); } GetTriFanIndices(indexPointer, type, count, data.getState().isPrimitiveRestartEnabled(), @@ -2138,25 +2056,37 @@ gl::Error Renderer11::drawTriangleFan(const gl::ContextState &data, const unsigned int spaceNeeded = static_cast<unsigned int>(mScratchIndexDataBuffer.size() * sizeof(unsigned int)); - ANGLE_TRY(mTriangleFanIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT)); + gl::Error error = mTriangleFanIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT); + if (error.isError()) + { + return error; + } void *mappedMemory = nullptr; unsigned int offset; - ANGLE_TRY(mTriangleFanIB->mapBuffer(spaceNeeded, &mappedMemory, &offset)); + error = mTriangleFanIB->mapBuffer(spaceNeeded, &mappedMemory, &offset); + if (error.isError()) + { + return error; + } memcpy(mappedMemory, &mScratchIndexDataBuffer[0], spaceNeeded); - ANGLE_TRY(mTriangleFanIB->unmapBuffer()); + error = mTriangleFanIB->unmapBuffer(); + if (error.isError()) + { + return error; + } - IndexBuffer11 *indexBuffer = GetAs<IndexBuffer11>(mTriangleFanIB->getIndexBuffer()); + IndexBuffer11 *indexBuffer = GetAs<IndexBuffer11>(mTriangleFanIB->getIndexBuffer()); ID3D11Buffer *d3dIndexBuffer = indexBuffer->getBuffer(); - DXGI_FORMAT indexFormat = indexBuffer->getIndexFormat(); + DXGI_FORMAT indexFormat = indexBuffer->getIndexFormat(); if (mAppliedIB != d3dIndexBuffer || mAppliedIBFormat != indexFormat || mAppliedIBOffset != offset) { mDeviceContext->IASetIndexBuffer(d3dIndexBuffer, indexFormat, offset); - mAppliedIB = d3dIndexBuffer; + mAppliedIB = d3dIndexBuffer; mAppliedIBFormat = indexFormat; mAppliedIBOffset = offset; } @@ -2172,7 +2102,7 @@ gl::Error Renderer11::drawTriangleFan(const gl::ContextState &data, mDeviceContext->DrawIndexed(indexCount, 0, -minIndex); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error Renderer11::applyShaders(const gl::ContextState &data, GLenum drawMode) @@ -2224,21 +2154,21 @@ gl::Error Renderer11::applyShaders(const gl::ContextState &data, GLenum drawMode { mDeviceContext->VSSetShader(vertexShader, nullptr, 0); mAppliedVertexShader = reinterpret_cast<uintptr_t>(vertexShader); - dirtyUniforms = true; + dirtyUniforms = true; } if (reinterpret_cast<uintptr_t>(geometryShader) != mAppliedGeometryShader) { mDeviceContext->GSSetShader(geometryShader, nullptr, 0); mAppliedGeometryShader = reinterpret_cast<uintptr_t>(geometryShader); - dirtyUniforms = true; + dirtyUniforms = true; } if (reinterpret_cast<uintptr_t>(pixelShader) != mAppliedPixelShader) { mDeviceContext->PSSetShader(pixelShader, nullptr, 0); mAppliedPixelShader = reinterpret_cast<uintptr_t>(pixelShader); - dirtyUniforms = true; + dirtyUniforms = true; } if (dirtyUniforms) @@ -2257,7 +2187,7 @@ gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D, unsigned int totalRegisterCountPS = 0; bool vertexUniformsDirty = false; - bool pixelUniformsDirty = false; + bool pixelUniformsDirty = false; for (const D3DUniform *uniform : uniformArray) { @@ -2282,16 +2212,16 @@ gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D, ASSERT(fragmentUniformStorage); ID3D11Buffer *vertexConstantBuffer = vertexUniformStorage->getConstantBuffer(); - ID3D11Buffer *pixelConstantBuffer = fragmentUniformStorage->getConstantBuffer(); + ID3D11Buffer *pixelConstantBuffer = fragmentUniformStorage->getConstantBuffer(); - float(*mapVS)[4] = NULL; - float(*mapPS)[4] = NULL; + float (*mapVS)[4] = NULL; + float (*mapPS)[4] = NULL; if (totalRegisterCountVS > 0 && vertexUniformsDirty) { D3D11_MAPPED_SUBRESOURCE map = {0}; - HRESULT result = - mDeviceContext->Map(vertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map); + HRESULT result = mDeviceContext->Map(vertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map); + UNUSED_ASSERTION_VARIABLE(result); ASSERT(SUCCEEDED(result)); mapVS = (float(*)[4])map.pData; } @@ -2299,8 +2229,8 @@ gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D, if (totalRegisterCountPS > 0 && pixelUniformsDirty) { D3D11_MAPPED_SUBRESOURCE map = {0}; - HRESULT result = - mDeviceContext->Map(pixelConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map); + HRESULT result = mDeviceContext->Map(pixelConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map); + UNUSED_ASSERTION_VARIABLE(result); ASSERT(SUCCEEDED(result)); mapPS = (float(*)[4])map.pData; } @@ -2363,9 +2293,7 @@ gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D, ASSERT(SUCCEEDED(result)); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to create vertex shader constant buffer, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create vertex shader constant buffer, result: 0x%X.", result); } mDeviceContext->VSSetConstantBuffers(d3d11::RESERVED_CONSTANT_BUFFER_SLOT_DRIVER, 1, &mDriverConstantBufferVS); @@ -2380,9 +2308,7 @@ gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D, ASSERT(SUCCEEDED(result)); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to create pixel shader constant buffer, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create pixel shader constant buffer, result: 0x%X.", result); } mDeviceContext->PSSetConstantBuffers(d3d11::RESERVED_CONSTANT_BUFFER_SLOT_DRIVER, 1, &mDriverConstantBufferPS); @@ -2391,13 +2317,13 @@ gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D, // Sampler metadata and driver constants need to coexist in the same constant buffer to conserve // constant buffer slots. We update both in the constant buffer if needed. const dx_VertexConstants11 &vertexConstants = mStateManager.getVertexConstants(); - size_t samplerMetadataReferencedBytesVS = sizeof(SamplerMetadataD3D11::dx_SamplerMetadata) * + size_t samplerMetadataReferencedBytesVS = sizeof(SamplerMetadataD3D11::dx_SamplerMetadata) * programD3D.getUsedSamplerRange(gl::SAMPLER_VERTEX); applyDriverConstantsIfNeeded(&mAppliedVertexConstants, vertexConstants, &mSamplerMetadataVS, samplerMetadataReferencedBytesVS, mDriverConstantBufferVS); const dx_PixelConstants11 &pixelConstants = mStateManager.getPixelConstants(); - size_t samplerMetadataReferencedBytesPS = sizeof(SamplerMetadataD3D11::dx_SamplerMetadata) * + size_t samplerMetadataReferencedBytesPS = sizeof(SamplerMetadataD3D11::dx_SamplerMetadata) * programD3D.getUsedSamplerRange(gl::SAMPLER_PIXEL); applyDriverConstantsIfNeeded(&mAppliedPixelConstants, pixelConstants, &mSamplerMetadataPS, samplerMetadataReferencedBytesPS, mDriverConstantBufferPS); @@ -2469,7 +2395,7 @@ void Renderer11::SamplerMetadataD3D11::update(unsigned int samplerIndex, const g case GL_R16I: case GL_R16UI: needIntegerTextureMetadata = true; - internalFormatBits = 16; + internalFormatBits = 16; break; case GL_RGBA8I: case GL_RGBA8UI: @@ -2480,11 +2406,11 @@ void Renderer11::SamplerMetadataD3D11::update(unsigned int samplerIndex, const g case GL_R8I: case GL_R8UI: needIntegerTextureMetadata = true; - internalFormatBits = 8; + internalFormatBits = 8; break; case GL_RGB10_A2UI: needIntegerTextureMetadata = true; - internalFormatBits = 10; + internalFormatBits = 10; break; default: break; @@ -2538,6 +2464,7 @@ void Renderer11::applyDriverConstantsIfNeeded(TShaderConstants *appliedConstants HRESULT result = mDeviceContext->Map(driverConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapping); ASSERT(SUCCEEDED(result)); + UNUSED_ASSERTION_VARIABLE(result); memcpy(mapping.pData, appliedConstants, sizeof(TShaderConstants)); // Previous buffer contents were discarded, so we need to refresh also the area of the // buffer that isn't used by this program. @@ -2578,7 +2505,7 @@ void Renderer11::markAllStateDirty() mStateManager.invalidateEverything(); - mAppliedIB = NULL; + mAppliedIB = NULL; mAppliedIBFormat = DXGI_FORMAT_UNKNOWN; mAppliedIBOffset = 0; @@ -2595,16 +2522,16 @@ void Renderer11::markAllStateDirty() for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS; i++) { - mCurrentConstantBufferVS[i] = static_cast<unsigned int>(-1); + mCurrentConstantBufferVS[i] = static_cast<unsigned int>(-1); mCurrentConstantBufferVSOffset[i] = 0; - mCurrentConstantBufferVSSize[i] = 0; - mCurrentConstantBufferPS[i] = static_cast<unsigned int>(-1); + mCurrentConstantBufferVSSize[i] = 0; + mCurrentConstantBufferPS[i] = static_cast<unsigned int>(-1); mCurrentConstantBufferPSOffset[i] = 0; - mCurrentConstantBufferPSSize[i] = 0; + mCurrentConstantBufferPSSize[i] = 0; } - mCurrentVertexConstantBuffer = NULL; - mCurrentPixelConstantBuffer = NULL; + mCurrentVertexConstantBuffer = NULL; + mCurrentPixelConstantBuffer = NULL; mCurrentGeometryConstantBuffer = NULL; mCurrentPrimitiveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; @@ -2635,14 +2562,13 @@ bool Renderer11::testDeviceLost() { bool isLost = false; - if (!mDevice) - { + if (!mDevice) { return true; } // GetRemovedReason is used to test if the device is removed HRESULT result = mDevice->GetDeviceRemovedReason(); - isLost = d3d11::isDeviceLostError(result); + isLost = d3d11::isDeviceLostError(result); if (isLost) { @@ -2655,26 +2581,25 @@ bool Renderer11::testDeviceLost() bool Renderer11::testDeviceResettable() { // determine if the device is resettable by creating a dummy device - PFN_D3D11_CREATE_DEVICE D3D11CreateDevice = - (PFN_D3D11_CREATE_DEVICE)GetProcAddress(mD3d11Module, "D3D11CreateDevice"); + PFN_D3D11_CREATE_DEVICE D3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(mD3d11Module, "D3D11CreateDevice"); if (D3D11CreateDevice == NULL) { return false; } - ID3D11Device *dummyDevice; + ID3D11Device* dummyDevice; D3D_FEATURE_LEVEL dummyFeatureLevel; - ID3D11DeviceContext *dummyContext; + ID3D11DeviceContext* dummyContext; ASSERT(mRequestedDriverType != D3D_DRIVER_TYPE_UNKNOWN); HRESULT result = D3D11CreateDevice( NULL, mRequestedDriverType, NULL, -#if defined(_DEBUG) + #if defined(_DEBUG) D3D11_CREATE_DEVICE_DEBUG, -#else + #else 0, -#endif + #endif mAvailableFeatureLevels.data(), static_cast<unsigned int>(mAvailableFeatureLevels.size()), D3D11_SDK_VERSION, &dummyDevice, &dummyFeatureLevel, &dummyContext); @@ -2763,6 +2688,11 @@ bool Renderer11::resetDevice() return true; } +VendorID Renderer11::getVendorId() const +{ + return static_cast<VendorID>(mAdapterDescription.VendorId); +} + SIZE_T Renderer11::getMaxResourceSize() const { // This formula comes from http://msdn.microsoft.com/en-us/library/windows/desktop/ff819065%28v=vs.85%29.aspx @@ -2776,10 +2706,8 @@ std::string Renderer11::getRendererDescription() const rendererString << mDescription; rendererString << " Direct3D11"; - rendererString << " vs_" << getMajorShaderModel() << "_" << getMinorShaderModel() - << getShaderModelSuffix(); - rendererString << " ps_" << getMajorShaderModel() << "_" << getMinorShaderModel() - << getShaderModelSuffix(); + rendererString << " vs_" << getMajorShaderModel() << "_" << getMinorShaderModel() << getShaderModelSuffix(); + rendererString << " ps_" << getMajorShaderModel() << "_" << getMinorShaderModel() << getShaderModelSuffix(); return rendererString.str(); } @@ -2787,12 +2715,12 @@ std::string Renderer11::getRendererDescription() const DeviceIdentifier Renderer11::getAdapterIdentifier() const { // Don't use the AdapterLuid here, since that doesn't persist across reboot. - DeviceIdentifier deviceIdentifier = {0}; - deviceIdentifier.VendorId = mAdapterDescription.VendorId; - deviceIdentifier.DeviceId = mAdapterDescription.DeviceId; - deviceIdentifier.SubSysId = mAdapterDescription.SubSysId; - deviceIdentifier.Revision = mAdapterDescription.Revision; - deviceIdentifier.FeatureLevel = static_cast<UINT>(mRenderer11DeviceCaps.featureLevel); + DeviceIdentifier deviceIdentifier = { 0 }; + deviceIdentifier.VendorId = mAdapterDescription.VendorId; + deviceIdentifier.DeviceId = mAdapterDescription.DeviceId; + deviceIdentifier.SubSysId = mAdapterDescription.SubSysId; + deviceIdentifier.Revision = mAdapterDescription.Revision; + deviceIdentifier.FeatureLevel = static_cast<UINT>(mRenderer11DeviceCaps.featureLevel); return deviceIdentifier; } @@ -2865,8 +2793,7 @@ bool Renderer11::getShareHandleSupport() const return false; } - // Also disable share handles on Feature Level 9_3, since it doesn't support share handles on - // RGBA8 textures/swapchains. + // Also disable share handles on Feature Level 9_3, since it doesn't support share handles on RGBA8 textures/swapchains. if (mRenderer11DeviceCaps.featureLevel <= D3D_FEATURE_LEVEL_9_3) { mSupportsShareHandles = false; @@ -2929,17 +2856,11 @@ int Renderer11::getMajorShaderModel() const { switch (mRenderer11DeviceCaps.featureLevel) { - 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: - return D3D10_SHADER_MAJOR_VERSION; // 4 - default: - UNREACHABLE(); - return 0; + 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: return D3D10_SHADER_MAJOR_VERSION; // 4 + default: UNREACHABLE(); return 0; } } @@ -2947,17 +2868,11 @@ int Renderer11::getMinorShaderModel() const { switch (mRenderer11DeviceCaps.featureLevel) { - 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: - return D3D10_SHADER_MINOR_VERSION; // 0 - default: - UNREACHABLE(); - return 0; + 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: return D3D10_SHADER_MINOR_VERSION; // 0 + default: UNREACHABLE(); return 0; } } @@ -2965,17 +2880,11 @@ std::string Renderer11::getShaderModelSuffix() const { switch (mRenderer11DeviceCaps.featureLevel) { - case D3D_FEATURE_LEVEL_11_0: - return ""; - case D3D_FEATURE_LEVEL_10_1: - return ""; - case D3D_FEATURE_LEVEL_10_0: - return ""; - case D3D_FEATURE_LEVEL_9_3: - return "_level_9_3"; - default: - UNREACHABLE(); - return ""; + case D3D_FEATURE_LEVEL_11_0: return ""; + case D3D_FEATURE_LEVEL_10_1: return ""; + case D3D_FEATURE_LEVEL_10_0: return ""; + case D3D_FEATURE_LEVEL_9_3: return "_level_9_3"; + default: UNREACHABLE(); return ""; } } @@ -3048,73 +2957,60 @@ gl::Error Renderer11::copyImage2D(const gl::Framebuffer *framebuffer, ANGLE_TRY(copyImageInternal(framebuffer, sourceRect, destFormat, destOffset, destRenderTarget)); - storage11->markLevelDirty(level); + storage11->invalidateSwizzleCacheLevel(level); return gl::NoError(); } -gl::Error Renderer11::copyImageCube(const gl::Framebuffer *framebuffer, - const gl::Rectangle &sourceRect, - GLenum destFormat, - const gl::Offset &destOffset, - TextureStorage *storage, - GLenum target, - GLint level) +gl::Error Renderer11::copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, + const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level) { TextureStorage11_Cube *storage11 = GetAs<TextureStorage11_Cube>(storage); ASSERT(storage11); - gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level); + gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level); RenderTargetD3D *destRenderTarget = nullptr; ANGLE_TRY(storage11->getRenderTarget(index, &destRenderTarget)); ASSERT(destRenderTarget); ANGLE_TRY(copyImageInternal(framebuffer, sourceRect, destFormat, destOffset, destRenderTarget)); - storage11->markLevelDirty(level); + storage11->invalidateSwizzleCacheLevel(level); return gl::NoError(); } -gl::Error Renderer11::copyImage3D(const gl::Framebuffer *framebuffer, - const gl::Rectangle &sourceRect, - GLenum destFormat, - const gl::Offset &destOffset, - TextureStorage *storage, - GLint level) +gl::Error Renderer11::copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, + const gl::Offset &destOffset, TextureStorage *storage, GLint level) { TextureStorage11_3D *storage11 = GetAs<TextureStorage11_3D>(storage); ASSERT(storage11); - gl::ImageIndex index = gl::ImageIndex::Make3D(level, destOffset.z); + gl::ImageIndex index = gl::ImageIndex::Make3D(level, destOffset.z); RenderTargetD3D *destRenderTarget = nullptr; ANGLE_TRY(storage11->getRenderTarget(index, &destRenderTarget)); ASSERT(destRenderTarget); ANGLE_TRY(copyImageInternal(framebuffer, sourceRect, destFormat, destOffset, destRenderTarget)); - storage11->markLevelDirty(level); + storage11->invalidateSwizzleCacheLevel(level); return gl::NoError(); } -gl::Error Renderer11::copyImage2DArray(const gl::Framebuffer *framebuffer, - const gl::Rectangle &sourceRect, - GLenum destFormat, - const gl::Offset &destOffset, - TextureStorage *storage, - GLint level) +gl::Error Renderer11::copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, + const gl::Offset &destOffset, TextureStorage *storage, GLint level) { TextureStorage11_2DArray *storage11 = GetAs<TextureStorage11_2DArray>(storage); ASSERT(storage11); - gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, destOffset.z); + gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, destOffset.z); RenderTargetD3D *destRenderTarget = nullptr; ANGLE_TRY(storage11->getRenderTarget(index, &destRenderTarget)); ASSERT(destRenderTarget); ANGLE_TRY(copyImageInternal(framebuffer, sourceRect, destFormat, destOffset, destRenderTarget)); - storage11->markLevelDirty(level); + storage11->invalidateSwizzleCacheLevel(level); return gl::NoError(); } @@ -3204,44 +3100,9 @@ gl::Error Renderer11::copyTexture(const gl::Texture *source, unpackUnmultiplyAlpha)); } - destStorage11->markLevelDirty(destLevel); - - return gl::NoError(); -} - -gl::Error Renderer11::copyCompressedTexture(const gl::Texture *source, - GLint sourceLevel, - TextureStorage *storage, - GLint destLevel) -{ - TextureStorage11_2D *destStorage11 = GetAs<TextureStorage11_2D>(storage); - ASSERT(destStorage11); - - ID3D11Resource *destResource = nullptr; - ANGLE_TRY(destStorage11->getResource(&destResource)); - - gl::ImageIndex destIndex = gl::ImageIndex::Make2D(destLevel); - UINT destSubresource = destStorage11->getSubresourceIndex(destIndex); - - TextureD3D *sourceD3D = GetImplAs<TextureD3D>(source); - ASSERT(sourceD3D); + destStorage11->invalidateSwizzleCacheLevel(destLevel); - TextureStorage *sourceStorage = nullptr; - ANGLE_TRY(sourceD3D->getNativeTexture(&sourceStorage)); - - TextureStorage11_2D *sourceStorage11 = GetAs<TextureStorage11_2D>(sourceStorage); - ASSERT(sourceStorage11); - - ID3D11Resource *sourceResource = nullptr; - ANGLE_TRY(sourceStorage11->getResource(&sourceResource)); - - gl::ImageIndex sourceIndex = gl::ImageIndex::Make2D(sourceLevel); - UINT sourceSubresource = sourceStorage11->getSubresourceIndex(sourceIndex); - - mDeviceContext->CopySubresourceRegion(destResource, destSubresource, 0, 0, 0, sourceResource, - sourceSubresource, nullptr); - - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } UINT64 EstimateSize(D3D11_TEXTURE2D_DESC &desc) @@ -3253,31 +3114,27 @@ UINT64 EstimateSize(D3D11_TEXTURE2D_DESC &desc) return total; } -gl::Error Renderer11::createRenderTarget(int width, - int height, - GLenum format, - GLsizei samples, - RenderTargetD3D **outRT) +gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT) { const d3d11::Format &formatInfo = d3d11::Format::Get(format, mRenderer11DeviceCaps); const gl::TextureCaps &textureCaps = getNativeTextureCaps().get(format); - GLuint supportedSamples = textureCaps.getNearestSamples(samples); + GLuint supportedSamples = textureCaps.getNearestSamples(samples); if (width > 0 && height > 0) { // Create texture resource D3D11_TEXTURE2D_DESC desc; - desc.Width = width; - desc.Height = height; - desc.MipLevels = 1; - desc.ArraySize = 1; + desc.Width = width; + desc.Height = height; + desc.MipLevels = 1; + desc.ArraySize = 1; desc.Format = formatInfo.texFormat; - desc.SampleDesc.Count = (supportedSamples == 0) ? 1 : supportedSamples; + desc.SampleDesc.Count = (supportedSamples == 0) ? 1 : supportedSamples; desc.SampleDesc.Quality = 0; - desc.Usage = D3D11_USAGE_DEFAULT; - desc.CPUAccessFlags = 0; - desc.MiscFlags = 0; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.CPUAccessFlags = 0; + desc.MiscFlags = 0; // If a rendertarget or depthstencil format exists for this texture format, // we'll flag it to allow binding that way. Shader resource views are a little @@ -3287,18 +3144,8 @@ gl::Error Renderer11::createRenderTarget(int width, bindDSV = (formatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN); bindSRV = (formatInfo.srvFormat != DXGI_FORMAT_UNKNOWN); - // D3D feature level 10.0 no longer allows creation of textures with both the bind SRV and - // DSV flags when multisampled. crbug.com/656989 - bool supportsMultisampledDepthStencilSRVs = - mRenderer11DeviceCaps.featureLevel > D3D_FEATURE_LEVEL_10_0; - bool isMultisampledDepthStencil = bindDSV && desc.SampleDesc.Count > 1; - if (isMultisampledDepthStencil && !supportsMultisampledDepthStencilSRVs) - { - bindSRV = false; - } - - desc.BindFlags = (bindRTV ? D3D11_BIND_RENDER_TARGET : 0) | - (bindDSV ? D3D11_BIND_DEPTH_STENCIL : 0) | + desc.BindFlags = (bindRTV ? D3D11_BIND_RENDER_TARGET : 0) | + (bindDSV ? D3D11_BIND_DEPTH_STENCIL : 0) | (bindSRV ? D3D11_BIND_SHADER_RESOURCE : 0); // The format must be either an RTV or a DSV @@ -3320,8 +3167,7 @@ gl::Error Renderer11::createRenderTarget(int width, if (FAILED(result)) { ASSERT(result == E_OUTOFMEMORY); - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to create render target texture, result: 0x%X.", result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target texture, result: 0x%X.", result); } ID3D11ShaderResourceView *srv = nullptr; @@ -3329,20 +3175,17 @@ gl::Error Renderer11::createRenderTarget(int width, if (bindSRV) { D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; - srvDesc.Format = formatInfo.srvFormat; - srvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_SRV_DIMENSION_TEXTURE2D - : D3D11_SRV_DIMENSION_TEXTURE2DMS; + srvDesc.Format = formatInfo.srvFormat; + srvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_SRV_DIMENSION_TEXTURE2D : D3D11_SRV_DIMENSION_TEXTURE2DMS; srvDesc.Texture2D.MostDetailedMip = 0; - srvDesc.Texture2D.MipLevels = 1; + srvDesc.Texture2D.MipLevels = 1; result = mDevice->CreateShaderResourceView(texture, &srvDesc, &srv); if (FAILED(result)) { ASSERT(result == E_OUTOFMEMORY); SafeRelease(texture); - return gl::Error( - GL_OUT_OF_MEMORY, - "Failed to create render target shader resource view, result: 0x%X.", result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target shader resource view, result: 0x%X.", result); } if (formatInfo.blitSRVFormat != formatInfo.srvFormat) @@ -3377,23 +3220,20 @@ gl::Error Renderer11::createRenderTarget(int width, if (bindDSV) { D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; - dsvDesc.Format = formatInfo.dsvFormat; - dsvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_DSV_DIMENSION_TEXTURE2D - : D3D11_DSV_DIMENSION_TEXTURE2DMS; + dsvDesc.Format = formatInfo.dsvFormat; + dsvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_DSV_DIMENSION_TEXTURE2D : D3D11_DSV_DIMENSION_TEXTURE2DMS; dsvDesc.Texture2D.MipSlice = 0; - dsvDesc.Flags = 0; + dsvDesc.Flags = 0; ID3D11DepthStencilView *dsv = NULL; - result = mDevice->CreateDepthStencilView(texture, &dsvDesc, &dsv); + result = mDevice->CreateDepthStencilView(texture, &dsvDesc, &dsv); if (FAILED(result)) { ASSERT(result == E_OUTOFMEMORY); SafeRelease(texture); SafeRelease(srv); SafeRelease(blitSRV); - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to create render target depth stencil view, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target depth stencil view, result: 0x%X.", result); } *outRT = new TextureRenderTarget11(dsv, texture, srv, format, formatInfo, width, height, @@ -3404,27 +3244,24 @@ gl::Error Renderer11::createRenderTarget(int width, else if (bindRTV) { D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; - rtvDesc.Format = formatInfo.rtvFormat; - rtvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_RTV_DIMENSION_TEXTURE2D - : D3D11_RTV_DIMENSION_TEXTURE2DMS; + rtvDesc.Format = formatInfo.rtvFormat; + rtvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_RTV_DIMENSION_TEXTURE2D : D3D11_RTV_DIMENSION_TEXTURE2DMS; rtvDesc.Texture2D.MipSlice = 0; ID3D11RenderTargetView *rtv = NULL; - result = mDevice->CreateRenderTargetView(texture, &rtvDesc, &rtv); + result = mDevice->CreateRenderTargetView(texture, &rtvDesc, &rtv); if (FAILED(result)) { ASSERT(result == E_OUTOFMEMORY); SafeRelease(texture); SafeRelease(srv); SafeRelease(blitSRV); - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to create render target render target view, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target render target view, result: 0x%X.", result); } if (formatInfo.dataInitializerFunction != NULL) { - const float clearValues[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + const float clearValues[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; mDeviceContext->ClearRenderTargetView(rtv, clearValues); } @@ -3457,8 +3294,12 @@ gl::Error Renderer11::createRenderTargetCopy(RenderTargetD3D *source, RenderTarg ASSERT(source != nullptr); RenderTargetD3D *newRT = nullptr; - ANGLE_TRY(createRenderTarget(source->getWidth(), source->getHeight(), - source->getInternalFormat(), source->getSamples(), &newRT)); + gl::Error error = createRenderTarget(source->getWidth(), source->getHeight(), + source->getInternalFormat(), source->getSamples(), &newRT); + if (error.isError()) + { + return error; + } RenderTarget11 *source11 = GetAs<RenderTarget11>(source); RenderTarget11 *dest11 = GetAs<RenderTarget11>(newRT); @@ -3479,17 +3320,16 @@ gl::Error Renderer11::loadExecutable(const void *function, { switch (type) { - case SHADER_VERTEX: + case SHADER_VERTEX: { - ID3D11VertexShader *vertexShader = NULL; + ID3D11VertexShader *vertexShader = NULL; ID3D11GeometryShader *streamOutShader = NULL; HRESULT result = mDevice->CreateVertexShader(function, length, NULL, &vertexShader); ASSERT(SUCCEEDED(result)); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, "Failed to create vertex shader, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create vertex shader, result: 0x%X.", result); } if (!streamOutVaryings.empty()) @@ -3504,8 +3344,8 @@ gl::Error Renderer11::loadExecutable(const void *function, entry.SemanticName = streamOutVarying.semanticName.c_str(); entry.SemanticIndex = streamOutVarying.semanticIndex; entry.StartComponent = 0; - entry.ComponentCount = static_cast<BYTE>(streamOutVarying.componentCount); - entry.OutputSlot = static_cast<BYTE>( + entry.ComponentCount = static_cast<BYTE>(streamOutVarying.componentCount); + entry.OutputSlot = static_cast<BYTE>( (separatedOutputBuffers ? streamOutVarying.outputSlot : 0)); soDeclaration.push_back(entry); } @@ -3517,16 +3357,14 @@ gl::Error Renderer11::loadExecutable(const void *function, ASSERT(SUCCEEDED(result)); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to create steam output shader, result: 0x%X.", result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create steam output shader, result: 0x%X.", result); } } - *outExecutable = - new ShaderExecutable11(function, length, vertexShader, streamOutShader); + *outExecutable = new ShaderExecutable11(function, length, vertexShader, streamOutShader); } break; - case SHADER_PIXEL: + case SHADER_PIXEL: { ID3D11PixelShader *pixelShader = NULL; @@ -3534,14 +3372,13 @@ gl::Error Renderer11::loadExecutable(const void *function, ASSERT(SUCCEEDED(result)); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, "Failed to create pixel shader, result: 0x%X.", - result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create pixel shader, result: 0x%X.", result); } *outExecutable = new ShaderExecutable11(function, length, pixelShader); } break; - case SHADER_GEOMETRY: + case SHADER_GEOMETRY: { ID3D11GeometryShader *geometryShader = NULL; @@ -3549,16 +3386,15 @@ gl::Error Renderer11::loadExecutable(const void *function, ASSERT(SUCCEEDED(result)); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to create geometry shader, result: 0x%X.", result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to create geometry shader, result: 0x%X.", result); } *outExecutable = new ShaderExecutable11(function, length, geometryShader); } break; - default: - UNREACHABLE(); - return gl::Error(GL_INVALID_OPERATION); + default: + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); } return gl::Error(GL_NO_ERROR); @@ -3575,22 +3411,21 @@ gl::Error Renderer11::compileToExecutable(gl::InfoLog &infoLog, const char *profileType = NULL; switch (type) { - case SHADER_VERTEX: - profileType = "vs"; - break; - case SHADER_PIXEL: - profileType = "ps"; - break; - case SHADER_GEOMETRY: - profileType = "gs"; - break; - default: - UNREACHABLE(); - return gl::Error(GL_INVALID_OPERATION); + case SHADER_VERTEX: + profileType = "vs"; + break; + case SHADER_PIXEL: + profileType = "ps"; + break; + case SHADER_GEOMETRY: + profileType = "gs"; + break; + default: + UNREACHABLE(); + return gl::Error(GL_INVALID_OPERATION); } - std::string profile = FormatString("%s_%d_%d%s", profileType, getMajorShaderModel(), - getMinorShaderModel(), getShaderModelSuffix().c_str()); + std::string profile = FormatString("%s_%d_%d%s", profileType, getMajorShaderModel(), getMinorShaderModel(), getShaderModelSuffix().c_str()); UINT flags = D3DCOMPILE_OPTIMIZATION_LEVEL2; @@ -3606,12 +3441,11 @@ gl::Error Renderer11::compileToExecutable(gl::InfoLog &infoLog, if (workarounds.enableIEEEStrictness) flags |= D3DCOMPILE_IEEE_STRICTNESS; - // Sometimes D3DCompile will fail with the default compilation flags for complicated shaders - // when it would otherwise pass with alternative options. + // Sometimes D3DCompile will fail with the default compilation flags for complicated shaders when it would otherwise pass with alternative options. // Try the default flags first and if compilation fails, try some alternatives. std::vector<CompileConfig> configs; - configs.push_back(CompileConfig(flags, "default")); - configs.push_back(CompileConfig(flags | D3DCOMPILE_SKIP_VALIDATION, "skip validation")); + configs.push_back(CompileConfig(flags, "default" )); + configs.push_back(CompileConfig(flags | D3DCOMPILE_SKIP_VALIDATION, "skip validation" )); configs.push_back(CompileConfig(flags | D3DCOMPILE_SKIP_OPTIMIZATION, "skip optimization")); if (getMajorShaderModel() == 4 && getShaderModelSuffix() != "") @@ -3623,24 +3457,26 @@ gl::Error Renderer11::compileToExecutable(gl::InfoLog &infoLog, CompileConfig(flags | D3DCOMPILE_AVOID_FLOW_CONTROL, "avoid flow control")); } - D3D_SHADER_MACRO loopMacros[] = {{"ANGLE_ENABLE_LOOP_FLATTEN", "1"}, {0, 0}}; + D3D_SHADER_MACRO loopMacros[] = { {"ANGLE_ENABLE_LOOP_FLATTEN", "1"}, {0, 0} }; ID3DBlob *binary = NULL; std::string debugInfo; - ANGLE_TRY(mCompiler.compileToBinary(infoLog, shaderHLSL, profile, configs, loopMacros, &binary, - &debugInfo)); + gl::Error error = mCompiler.compileToBinary(infoLog, shaderHLSL, profile, configs, loopMacros, &binary, &debugInfo); + if (error.isError()) + { + return error; + } - // It's possible that binary is NULL if the compiler failed in all configurations. Set the - // executable to NULL and return GL_NO_ERROR to signify that there was a link error but the - // internal state is still OK. + // It's possible that binary is NULL if the compiler failed in all configurations. Set the executable to NULL + // and return GL_NO_ERROR to signify that there was a link error but the internal state is still OK. if (!binary) { *outExectuable = NULL; return gl::Error(GL_NO_ERROR); } - gl::Error error = loadExecutable(binary->GetBufferPointer(), binary->GetBufferSize(), type, - streamOutVaryings, separatedOutputBuffers, outExectuable); + error = loadExecutable(binary->GetBufferPointer(), binary->GetBufferSize(), type, + streamOutVaryings, separatedOutputBuffers, outExectuable); SafeRelease(binary); if (error.isError()) @@ -3653,7 +3489,7 @@ gl::Error Renderer11::compileToExecutable(gl::InfoLog &infoLog, (*outExectuable)->appendDebugInfo(debugInfo); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } UniformStorageD3D *Renderer11::createUniformStorage(size_t storageSize) @@ -3705,19 +3541,14 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const } // We don't support formats which we can't represent without conversion - if (d3d11FormatInfo.format().glInternalFormat != internalFormat) + if (d3d11FormatInfo.format.glInternalFormat != internalFormat) { return false; } - // Buffer SRV creation for this format was not working on Windows 10. - if (d3d11FormatInfo.texFormat == DXGI_FORMAT_B5G5R5A1_UNORM) - { - return false; - } - - // This format is not supported as a buffer SRV. - if (d3d11FormatInfo.texFormat == DXGI_FORMAT_A8_UNORM) + // Buffer SRV creation in this format was not working on Windows 10, repro at least on Intel + // and NVIDIA. + if (internalFormat == GL_RGB5_A1) { return false; } @@ -3725,16 +3556,11 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const return true; } -gl::Error Renderer11::fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, - unsigned int offset, - RenderTargetD3D *destRenderTarget, - GLenum destinationFormat, - GLenum sourcePixelsType, - const gl::Box &destArea) +gl::Error Renderer11::fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTargetD3D *destRenderTarget, + GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea) { ASSERT(supportsFastCopyBufferToTexture(destinationFormat)); - return mPixelTransfer->copyBufferToTexture(unpack, offset, destRenderTarget, destinationFormat, - sourcePixelsType, destArea); + return mPixelTransfer->copyBufferToTexture(unpack, offset, destRenderTarget, destinationFormat, sourcePixelsType, destArea); } ImageD3D *Renderer11::createImage() @@ -3745,7 +3571,7 @@ ImageD3D *Renderer11::createImage() gl::Error Renderer11::generateMipmap(ImageD3D *dest, ImageD3D *src) { Image11 *dest11 = GetAs<Image11>(dest); - Image11 *src11 = GetAs<Image11>(src); + Image11 *src11 = GetAs<Image11>(src); return Image11::generateMipmap(dest11, src11, mRenderer11DeviceCaps); } @@ -3758,12 +3584,16 @@ gl::Error Renderer11::generateMipmapUsingD3D(TextureStorage *storage, ASSERT(storage11->supportsNativeMipmapFunction()); ID3D11ShaderResourceView *srv; - ANGLE_TRY(storage11->getSRVLevels(textureState.getEffectiveBaseLevel(), - textureState.getEffectiveMaxLevel(), &srv)); + gl::Error error = storage11->getSRVLevels(textureState.getEffectiveBaseLevel(), + textureState.getEffectiveMaxLevel(), &srv); + if (error.isError()) + { + return error; + } mDeviceContext->GenerateMips(srv); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } TextureStorage *Renderer11::createTextureStorage2D(SwapChainD3D *swapChain) @@ -3785,47 +3615,24 @@ TextureStorage *Renderer11::createTextureStorageExternal( return new TextureStorage11_External(this, stream, desc); } -TextureStorage *Renderer11::createTextureStorage2D(GLenum internalformat, - bool renderTarget, - GLsizei width, - GLsizei height, - int levels, - bool hintLevelZeroOnly) +TextureStorage *Renderer11::createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels, bool hintLevelZeroOnly) { - return new TextureStorage11_2D(this, internalformat, renderTarget, width, height, levels, - hintLevelZeroOnly); + return new TextureStorage11_2D(this, internalformat, renderTarget, width, height, levels, hintLevelZeroOnly); } -TextureStorage *Renderer11::createTextureStorageCube(GLenum internalformat, - bool renderTarget, - int size, - int levels, - bool hintLevelZeroOnly) +TextureStorage *Renderer11::createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels, bool hintLevelZeroOnly) { - return new TextureStorage11_Cube(this, internalformat, renderTarget, size, levels, - hintLevelZeroOnly); + return new TextureStorage11_Cube(this, internalformat, renderTarget, size, levels, hintLevelZeroOnly); } -TextureStorage *Renderer11::createTextureStorage3D(GLenum internalformat, - bool renderTarget, - GLsizei width, - GLsizei height, - GLsizei depth, - int levels) +TextureStorage *Renderer11::createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels) { - return new TextureStorage11_3D(this, internalformat, renderTarget, width, height, depth, - levels); + return new TextureStorage11_3D(this, internalformat, renderTarget, width, height, depth, levels); } -TextureStorage *Renderer11::createTextureStorage2DArray(GLenum internalformat, - bool renderTarget, - GLsizei width, - GLsizei height, - GLsizei depth, - int levels) +TextureStorage *Renderer11::createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels) { - return new TextureStorage11_2DArray(this, internalformat, renderTarget, width, height, depth, - levels); + return new TextureStorage11_2DArray(this, internalformat, renderTarget, width, height, depth, levels); } gl::Error Renderer11::readFromAttachment(const gl::FramebufferAttachment &srcAttachment, @@ -3897,15 +3704,15 @@ gl::Error Renderer11::readFromAttachment(const gl::FramebufferAttachment &srcAtt D3D11_TEXTURE2D_DESC resolveDesc; resolveDesc.Width = static_cast<UINT>(texSize.width); resolveDesc.Height = static_cast<UINT>(texSize.height); - resolveDesc.MipLevels = 1; - resolveDesc.ArraySize = 1; + resolveDesc.MipLevels = 1; + resolveDesc.ArraySize = 1; resolveDesc.Format = textureHelper.getFormat(); - resolveDesc.SampleDesc.Count = 1; + resolveDesc.SampleDesc.Count = 1; resolveDesc.SampleDesc.Quality = 0; - resolveDesc.Usage = D3D11_USAGE_DEFAULT; - resolveDesc.BindFlags = 0; - resolveDesc.CPUAccessFlags = 0; - resolveDesc.MiscFlags = 0; + resolveDesc.Usage = D3D11_USAGE_DEFAULT; + resolveDesc.BindFlags = 0; + resolveDesc.CPUAccessFlags = 0; + resolveDesc.MiscFlags = 0; ID3D11Texture2D *resolveTex2D = nullptr; HRESULT result = mDevice->CreateTexture2D(&resolveDesc, nullptr, &resolveTex2D); @@ -3977,17 +3784,16 @@ gl::Error Renderer11::packPixels(const TextureHelper11 &textureHelper, if (FAILED(hr)) { ASSERT(hr == E_OUTOFMEMORY); - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to map internal texture for reading, result: 0x%X.", hr); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal texture for reading, result: 0x%X.", hr); } uint8_t *source = static_cast<uint8_t *>(mapping.pData); int inputPitch = static_cast<int>(mapping.RowPitch); const auto &formatInfo = textureHelper.getFormatSet(); - ASSERT(formatInfo.format().glInternalFormat != GL_NONE); + ASSERT(formatInfo.format.glInternalFormat != GL_NONE); - PackPixels(params, formatInfo.format(), inputPitch, source, pixelsOut); + PackPixels(params, formatInfo.format, inputPitch, source, pixelsOut); mDeviceContext->Unmap(readResource, 0); @@ -4012,27 +3818,23 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn, RenderTarget11 *drawRenderTarget11 = GetAs<RenderTarget11>(drawRenderTarget); if (!drawRenderTarget11) { - return gl::Error( - GL_OUT_OF_MEMORY, - "Failed to retrieve the internal draw render target from the draw framebuffer."); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to retrieve the internal draw render target from the draw framebuffer."); } TextureHelper11 drawTexture = TextureHelper11::MakeAndReference( drawRenderTarget11->getTexture(), drawRenderTarget11->getFormatSet()); - unsigned int drawSubresource = drawRenderTarget11->getSubresourceIndex(); + unsigned int drawSubresource = drawRenderTarget11->getSubresourceIndex(); ID3D11RenderTargetView *drawRTV = drawRenderTarget11->getRenderTargetView(); ID3D11DepthStencilView *drawDSV = drawRenderTarget11->getDepthStencilView(); RenderTarget11 *readRenderTarget11 = GetAs<RenderTarget11>(readRenderTarget); if (!readRenderTarget11) { - return gl::Error( - GL_OUT_OF_MEMORY, - "Failed to retrieve the internal read render target from the read framebuffer."); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to retrieve the internal read render target from the read framebuffer."); } TextureHelper11 readTexture; - unsigned int readSubresource = 0; + unsigned int readSubresource = 0; ID3D11ShaderResourceView *readSRV = nullptr; if (readRenderTarget->getSamples() > 1) @@ -4066,7 +3868,7 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn, readTexture = TextureHelper11::MakeAndReference(readRenderTarget11->getTexture(), readRenderTarget11->getFormatSet()); readSubresource = readRenderTarget11->getSubresourceIndex(); - readSRV = readRenderTarget11->getBlitShaderResourceView(); + readSRV = readRenderTarget11->getBlitShaderResourceView(); if (readSRV == nullptr) { ASSERT(depthBlit || stencilBlit); @@ -4090,7 +3892,8 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn, // by internally scaling the read and draw rectangles. gl::Rectangle readRect = readRectIn; gl::Rectangle drawRect = drawRectIn; - auto readToDrawX = [&drawRectIn, &readRectIn](int readOffset) { + auto readToDrawX = [&drawRectIn, &readRectIn](int readOffset) + { double readToDrawScale = static_cast<double>(drawRectIn.width) / static_cast<double>(readRectIn.width); return static_cast<int>(round(static_cast<double>(readOffset) * readToDrawScale)); @@ -4106,7 +3909,8 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn, drawRect.width -= drawOffset; } - auto readToDrawY = [&drawRectIn, &readRectIn](int readOffset) { + auto readToDrawY = [&drawRectIn, &readRectIn](int readOffset) + { double readToDrawScale = static_cast<double>(drawRectIn.height) / static_cast<double>(readRectIn.height); return static_cast<int>(round(static_cast<double>(readOffset) * readToDrawScale)); @@ -4145,20 +3949,21 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn, const auto &destFormatInfo = gl::GetInternalFormatInfo(drawRenderTarget->getInternalFormat()); const auto &srcFormatInfo = gl::GetInternalFormatInfo(readRenderTarget->getInternalFormat()); const auto &formatSet = drawRenderTarget11->getFormatSet(); - const auto &nativeFormat = formatSet.format(); + const DXGI_FORMAT drawDXGIFormat = colorBlit ? formatSet.rtvFormat : formatSet.dsvFormat; + const auto &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(drawDXGIFormat); // Some blits require masking off emulated texture channels. eg: from RGBA8 to RGB8, we // emulate RGB8 with RGBA8, so we need to mask off the alpha channel when we copy. gl::Color<bool> colorMask; - colorMask.red = - (srcFormatInfo.redBits > 0) && (destFormatInfo.redBits == 0) && (nativeFormat.redBits > 0); + colorMask.red = (srcFormatInfo.redBits > 0) && (destFormatInfo.redBits == 0) && + (dxgiFormatInfo.redBits > 0); colorMask.green = (srcFormatInfo.greenBits > 0) && (destFormatInfo.greenBits == 0) && - (nativeFormat.greenBits > 0); + (dxgiFormatInfo.greenBits > 0); colorMask.blue = (srcFormatInfo.blueBits > 0) && (destFormatInfo.blueBits == 0) && - (nativeFormat.blueBits > 0); + (dxgiFormatInfo.blueBits > 0); colorMask.alpha = (srcFormatInfo.alphaBits > 0) && (destFormatInfo.alphaBits == 0) && - (nativeFormat.alphaBits > 0); + (dxgiFormatInfo.alphaBits > 0); // We only currently support masking off the alpha channel. bool colorMaskingNeeded = colorMask.alpha; @@ -4172,19 +3977,17 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn, bool stretchRequired = readRect.width != drawRect.width || readRect.height != drawRect.height; - bool flipRequired = - readRect.width < 0 || readRect.height < 0 || drawRect.width < 0 || drawRect.height < 0; + bool flipRequired = readRect.width < 0 || readRect.height < 0 || drawRect.width < 0 || drawRect.height < 0; bool outOfBounds = readRect.x < 0 || readRect.x + readRect.width > readSize.width || readRect.y < 0 || readRect.y + readRect.height > readSize.height || drawRect.x < 0 || drawRect.x + drawRect.width > drawSize.width || drawRect.y < 0 || drawRect.y + drawRect.height > drawSize.height; - bool partialDSBlit = - (nativeFormat.depthBits > 0 && depthBlit) != (nativeFormat.stencilBits > 0 && stencilBlit); + bool partialDSBlit = (dxgiFormatInfo.depthBits > 0 && depthBlit) != (dxgiFormatInfo.stencilBits > 0 && stencilBlit); - if (readRenderTarget11->getFormatSet().formatID == - drawRenderTarget11->getFormatSet().formatID && + if (readRenderTarget11->getFormatSet().format.id == + drawRenderTarget11->getFormatSet().format.id && !stretchRequired && !outOfBounds && !flipRequired && !partialDSBlit && !colorMaskingNeeded && (!(depthBlit || stencilBlit) || wholeBufferCopy)) { @@ -4192,17 +3995,16 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn, UINT dstY = drawRect.y; D3D11_BOX readBox; - readBox.left = readRect.x; - readBox.right = readRect.x + readRect.width; - readBox.top = readRect.y; + readBox.left = readRect.x; + readBox.right = readRect.x + readRect.width; + readBox.top = readRect.y; readBox.bottom = readRect.y + readRect.height; - readBox.front = 0; - readBox.back = 1; + readBox.front = 0; + readBox.back = 1; if (scissorNeeded) { - // drawRect is guaranteed to have positive width and height because stretchRequired is - // false. + // drawRect is guaranteed to have positive width and height because stretchRequired is false. ASSERT(drawRect.width >= 0 || drawRect.height >= 0); if (drawRect.x < scissor->x) @@ -4282,7 +4084,7 @@ void Renderer11::onSwap() // Send histogram updates every half hour const double kHistogramUpdateInterval = 30 * 60; - const double currentTime = ANGLEPlatformCurrent()->monotonicallyIncreasingTime(); + const double currentTime = ANGLEPlatformCurrent()->monotonicallyIncreasingTime(); const double timeSinceLastUpdate = currentTime - mLastHistogramUpdateTime; if (timeSinceLastUpdate > kHistogramUpdateInterval) @@ -4363,7 +4165,7 @@ Renderer11::resolveMultisampledTexture(RenderTarget11 *renderTarget, bool depth, bool Renderer11::getLUID(LUID *adapterLuid) const { adapterLuid->HighPart = 0; - adapterLuid->LowPart = 0; + adapterLuid->LowPart = 0; if (!mDxgiAdapter) { @@ -4380,18 +4182,14 @@ bool Renderer11::getLUID(LUID *adapterLuid) const return true; } -VertexConversionType Renderer11::getVertexConversionType( - gl::VertexFormatType vertexFormatType) const +VertexConversionType Renderer11::getVertexConversionType(gl::VertexFormatType vertexFormatType) const { - return d3d11::GetVertexFormatInfo(vertexFormatType, mRenderer11DeviceCaps.featureLevel) - .conversionType; + return d3d11::GetVertexFormatInfo(vertexFormatType, mRenderer11DeviceCaps.featureLevel).conversionType; } GLenum Renderer11::getVertexComponentType(gl::VertexFormatType vertexFormatType) const { - const auto &format = - d3d11::GetVertexFormatInfo(vertexFormatType, mRenderer11DeviceCaps.featureLevel); - return d3d11::GetComponentType(format.nativeFormat); + return d3d11::GetDXGIFormatInfo(d3d11::GetVertexFormatInfo(vertexFormatType, mRenderer11DeviceCaps.featureLevel).nativeFormat).componentType; } gl::ErrorOrResult<unsigned int> Renderer11::getVertexSpaceRequired( @@ -4430,10 +4228,8 @@ gl::ErrorOrResult<unsigned int> Renderer11::getVertexSpaceRequired( return elementSize * elementCount; } -void Renderer11::generateCaps(gl::Caps *outCaps, - gl::TextureCapsMap *outTextureCaps, - gl::Extensions *outExtensions, - gl::Limitations *outLimitations) const +void Renderer11::generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureCaps, + gl::Extensions *outExtensions, gl::Limitations *outLimitations) const { d3d11_gl::GenerateCaps(mDevice, mDeviceContext, mRenderer11DeviceCaps, outCaps, outTextureCaps, outExtensions, outLimitations); @@ -4576,7 +4372,7 @@ gl::Error Renderer11::getScratchMemoryBuffer(size_t requestedSize, MemoryBuffer if (mScratchMemoryBuffer.size() == requestedSize) { mScratchMemoryBufferResetCounter = ScratchMemoryBufferLifetime; - *bufferOut = &mScratchMemoryBuffer; + *bufferOut = &mScratchMemoryBuffer; return gl::NoError(); } diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h index 576fe3215..2f536bfd8 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h @@ -123,17 +123,9 @@ class Renderer11 : public RendererD3D SwapChainD3D *createSwapChain(NativeWindowD3D *nativeWindow, HANDLE shareHandle, - IUnknown *d3dTexture, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) override; - egl::Error getD3DTextureInfo(IUnknown *d3dTexture, - EGLint *width, - EGLint *height, - GLenum *fboFormat) const override; - egl::Error validateShareHandle(const egl::Config *config, - HANDLE shareHandle, - const egl::AttributeMap &attribs) const override; gl::Error setSamplerState(gl::SamplerType type, int index, @@ -170,6 +162,7 @@ class Renderer11 : public RendererD3D bool testDeviceLost() override; bool testDeviceResettable() override; + VendorID getVendorId() const; SIZE_T getMaxResourceSize() const; std::string getRendererDescription() const; DeviceIdentifier getAdapterIdentifier() const override; @@ -224,10 +217,6 @@ class Renderer11 : public RendererD3D bool unpackFlipY, bool unpackPremultiplyAlpha, bool unpackUnmultiplyAlpha) override; - gl::Error copyCompressedTexture(const gl::Texture *source, - GLint sourceLevel, - TextureStorage *storage, - GLint destLevel) override; // RenderTarget creation gl::Error createRenderTarget(int width, @@ -343,7 +332,7 @@ class Renderer11 : public RendererD3D bool colorBlit, bool depthBlit, bool stencilBlit); bool isES3Capable() const; - const Renderer11DeviceCaps &getRenderer11DeviceCaps() const { return mRenderer11DeviceCaps; }; + const Renderer11DeviceCaps &getRenderer11DeviceCaps() { return mRenderer11DeviceCaps; }; RendererClass getRendererClass() const override { return RENDERER_D3D11; } InputLayoutCache *getInputLayoutCache() { return &mInputLayoutCache; } diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/ShaderExecutable11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/ShaderExecutable11.cpp index e20b161ef..4da51afe4 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/ShaderExecutable11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/ShaderExecutable11.cpp @@ -85,6 +85,7 @@ UniformStorage11::UniformStorage11(Renderer11 *renderer, size_t initialSize) constantBufferDescription.StructureByteStride = 0; HRESULT result = d3d11Device->CreateBuffer(&constantBufferDescription, NULL, &mConstantBuffer); + UNUSED_ASSERTION_VARIABLE(result); ASSERT(SUCCEEDED(result)); } } diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp index 0e28c8c18..b8b0e45c4 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp @@ -492,11 +492,16 @@ gl::Error StateManager11::setBlendState(const gl::Framebuffer *framebuffer, { if (!mBlendStateIsDirty && sampleMask == mCurSampleMask) { - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } ID3D11BlendState *dxBlendState = nullptr; - ANGLE_TRY(mRenderer->getStateCache().getBlendState(framebuffer, blendState, &dxBlendState)); + gl::Error error = + mRenderer->getStateCache().getBlendState(framebuffer, blendState, &dxBlendState); + if (error.isError()) + { + return error; + } ASSERT(dxBlendState != nullptr); @@ -527,7 +532,7 @@ gl::Error StateManager11::setBlendState(const gl::Framebuffer *framebuffer, mBlendStateIsDirty = false; - return gl::NoError(); + return error; } gl::Error StateManager11::setDepthStencilState(const gl::State &glState) @@ -547,7 +552,7 @@ gl::Error StateManager11::setDepthStencilState(const gl::State &glState) disableDepth == mCurDisableDepth.value() && mCurDisableStencil.valid() && disableStencil == mCurDisableStencil.value()) { - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } const auto &depthStencilState = glState.getDepthStencilState(); @@ -567,8 +572,12 @@ gl::Error StateManager11::setDepthStencilState(const gl::State &glState) (depthStencilState.stencilBackMask & maxStencil)); ID3D11DepthStencilState *dxDepthStencilState = NULL; - ANGLE_TRY(mRenderer->getStateCache().getDepthStencilState( - depthStencilState, disableDepth, disableStencil, &dxDepthStencilState)); + gl::Error error = mRenderer->getStateCache().getDepthStencilState( + depthStencilState, disableDepth, disableStencil, &dxDepthStencilState); + if (error.isError()) + { + return error; + } ASSERT(dxDepthStencilState); @@ -592,7 +601,7 @@ gl::Error StateManager11::setDepthStencilState(const gl::State &glState) mDepthStencilStateIsDirty = false; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error StateManager11::setRasterizerState(const gl::RasterizerState &rasterState) @@ -601,10 +610,11 @@ gl::Error StateManager11::setRasterizerState(const gl::RasterizerState &rasterSt if (!mRasterizerStateIsDirty && rasterState.pointDrawMode == mCurRasterState.pointDrawMode && rasterState.multiSample == mCurRasterState.multiSample) { - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } ID3D11RasterizerState *dxRasterState = nullptr; + gl::Error error(GL_NO_ERROR); if (mCurPresentPathFastEnabled) { @@ -623,13 +633,18 @@ gl::Error StateManager11::setRasterizerState(const gl::RasterizerState &rasterSt modifiedRasterState.frontFace = GL_CCW; } - ANGLE_TRY(mRenderer->getStateCache().getRasterizerState( - modifiedRasterState, mCurScissorEnabled, &dxRasterState)); + error = mRenderer->getStateCache().getRasterizerState(modifiedRasterState, + mCurScissorEnabled, &dxRasterState); } else { - ANGLE_TRY(mRenderer->getStateCache().getRasterizerState(rasterState, mCurScissorEnabled, - &dxRasterState)); + error = mRenderer->getStateCache().getRasterizerState(rasterState, mCurScissorEnabled, + &dxRasterState); + } + + if (error.isError()) + { + return error; } mRenderer->getDeviceContext()->RSSetState(dxRasterState); @@ -637,7 +652,7 @@ gl::Error StateManager11::setRasterizerState(const gl::RasterizerState &rasterSt mCurRasterState = rasterState; mRasterizerStateIsDirty = false; - return gl::NoError(); + return error; } void StateManager11::setScissorRectangle(const gl::Rectangle &scissor, bool enabled) @@ -852,7 +867,7 @@ gl::Error StateManager11::onMakeCurrent(const gl::ContextState &data) } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void StateManager11::setShaderResource(gl::SamplerType shaderType, @@ -886,7 +901,7 @@ gl::Error StateManager11::clearTextures(gl::SamplerType samplerType, { if (rangeStart == rangeEnd) { - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } auto ¤tSRVs = (samplerType == gl::SAMPLER_VERTEX ? mCurVertexSRVs : mCurPixelSRVs); @@ -896,7 +911,7 @@ gl::Error StateManager11::clearTextures(gl::SamplerType samplerType, if (clearRange.empty()) { - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } auto deviceContext = mRenderer->getDeviceContext(); @@ -918,7 +933,7 @@ gl::Error StateManager11::clearTextures(gl::SamplerType samplerType, currentSRVs.update(samplerIndex, nullptr); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void StateManager11::unsetConflictingSRVs(gl::SamplerType samplerType, @@ -974,7 +989,11 @@ void StateManager11::deinitialize() gl::Error StateManager11::syncFramebuffer(gl::Framebuffer *framebuffer) { Framebuffer11 *framebuffer11 = GetImplAs<Framebuffer11>(framebuffer); - ANGLE_TRY(framebuffer11->markAttachmentsDirty()); + gl::Error error = framebuffer11->invalidateSwizzles(); + if (error.isError()) + { + return error; + } if (framebuffer11->hasAnyInternalDirtyBit()) { @@ -984,7 +1003,7 @@ gl::Error StateManager11::syncFramebuffer(gl::Framebuffer *framebuffer) if (!mRenderTargetIsDirty) { - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } mRenderTargetIsDirty = false; @@ -998,7 +1017,7 @@ gl::Error StateManager11::syncFramebuffer(gl::Framebuffer *framebuffer) const gl::Extents &size = framebuffer->getFirstColorbuffer()->getSize(); if (size.width == 0 || size.height == 0) { - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } } @@ -1082,7 +1101,7 @@ gl::Error StateManager11::syncFramebuffer(gl::Framebuffer *framebuffer) setViewportBounds(renderTargetWidth, renderTargetHeight); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error StateManager11::updateCurrentValueAttribs(const gl::State &state, @@ -1105,11 +1124,15 @@ gl::Error StateManager11::updateCurrentValueAttribs(const gl::State &state, currentValueAttrib->currentValueType = currentValue.Type; currentValueAttrib->attribute = &vertexAttributes[attribIndex]; - ANGLE_TRY(vertexDataManager->storeCurrentValue(currentValue, currentValueAttrib, - static_cast<size_t>(attribIndex))); + gl::Error error = vertexDataManager->storeCurrentValue(currentValue, currentValueAttrib, + static_cast<size_t>(attribIndex)); + if (error.isError()) + { + return error; + } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } const std::vector<TranslatedAttribute> &StateManager11::getCurrentValueAttribs() const diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp index a410c425d..b12fd80d2 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp @@ -45,11 +45,10 @@ bool NeedsOffscreenTexture(Renderer11 *renderer, NativeWindow11 *nativeWindow, E SwapChain11::SwapChain11(Renderer11 *renderer, NativeWindow11 *nativeWindow, HANDLE shareHandle, - IUnknown *d3dTexture, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) - : SwapChainD3D(shareHandle, d3dTexture, backBufferFormat, depthBufferFormat), + : SwapChainD3D(shareHandle, backBufferFormat, depthBufferFormat), mRenderer(renderer), mWidth(-1), mHeight(-1), @@ -181,29 +180,43 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe const d3d11::Format &backbufferFormatInfo = d3d11::Format::Get(mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps()); - // If the app passed in a share handle or D3D texture, open the resource - // See EGL_ANGLE_d3d_share_handle_client_buffer and EGL_ANGLE_d3d_texture_client_buffer - if (mAppCreatedShareHandle || mD3DTexture != nullptr) + // If the app passed in a share handle, open the resource + // See EGL_ANGLE_d3d_share_handle_client_buffer + if (mAppCreatedShareHandle) { - if (mAppCreatedShareHandle) - { - ID3D11Resource *tempResource11; - HRESULT result = device->OpenSharedResource(mShareHandle, __uuidof(ID3D11Resource), - (void **)&tempResource11); - ASSERT(SUCCEEDED(result)); + ID3D11Resource *tempResource11; + HRESULT result = device->OpenSharedResource(mShareHandle, __uuidof(ID3D11Resource), (void**)&tempResource11); - mOffscreenTexture = d3d11::DynamicCastComObject<ID3D11Texture2D>(tempResource11); - SafeRelease(tempResource11); + if (FAILED(result)) + { + ERR("Failed to open the swap chain pbuffer share handle: %08lX", result); + release(); + return EGL_BAD_PARAMETER; } - else if (mD3DTexture != nullptr) + + result = tempResource11->QueryInterface(__uuidof(ID3D11Texture2D), (void**)&mOffscreenTexture); + SafeRelease(tempResource11); + + if (FAILED(result)) { - mOffscreenTexture = d3d11::DynamicCastComObject<ID3D11Texture2D>(mD3DTexture); + ERR("Failed to query texture2d interface in pbuffer share handle: %08lX", result); + release(); + return EGL_BAD_PARAMETER; } - else + + // Validate offscreen texture parameters + D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0}; + mOffscreenTexture->GetDesc(&offscreenTextureDesc); + + if (offscreenTextureDesc.Width != (UINT)backbufferWidth || + offscreenTextureDesc.Height != (UINT)backbufferHeight || + offscreenTextureDesc.Format != backbufferFormatInfo.texFormat || + offscreenTextureDesc.MipLevels != 1 || offscreenTextureDesc.ArraySize != 1) { - UNREACHABLE(); + ERR("Invalid texture parameters in the shared offscreen texture pbuffer"); + release(); + return EGL_BAD_PARAMETER; } - ASSERT(mOffscreenTexture != nullptr); } else { diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.h index 1d7e57b7c..1ea608054 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.h @@ -24,7 +24,6 @@ class SwapChain11 final : public SwapChainD3D SwapChain11(Renderer11 *renderer, NativeWindow11 *nativeWindow, HANDLE shareHandle, - IUnknown *d3dTexture, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp index 36c888dd3..738dae13f 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp @@ -31,15 +31,15 @@ namespace rx { -TextureStorage11::SRVKey::SRVKey(int baseLevel, int mipLevels, bool swizzle, bool dropStencil) - : baseLevel(baseLevel), mipLevels(mipLevels), swizzle(swizzle), dropStencil(dropStencil) +TextureStorage11::SRVKey::SRVKey(int baseLevel, int mipLevels, bool swizzle) + : baseLevel(baseLevel), mipLevels(mipLevels), swizzle(swizzle) { } bool TextureStorage11::SRVKey::operator<(const SRVKey &rhs) const { - return std::tie(baseLevel, mipLevels, swizzle, dropStencil) < - std::tie(rhs.baseLevel, rhs.mipLevels, rhs.swizzle, rhs.dropStencil); + return std::tie(baseLevel, mipLevels, swizzle) < + std::tie(rhs.baseLevel, rhs.mipLevels, rhs.swizzle); } TextureStorage11::TextureStorage11(Renderer11 *renderer, @@ -53,7 +53,6 @@ TextureStorage11::TextureStorage11(Renderer11 *renderer, mTextureWidth(0), mTextureHeight(0), mTextureDepth(0), - mDropStencilTexture(nullptr), mBindFlags(bindFlags), mMiscFlags(miscFlags) { @@ -74,7 +73,6 @@ TextureStorage11::~TextureStorage11() SafeRelease(i->second); } mSrvCache.clear(); - SafeRelease(mDropStencilTexture); } DWORD TextureStorage11::GetTextureBindFlags(GLenum internalFormat, @@ -110,7 +108,9 @@ DWORD TextureStorage11::GetTextureMiscFlags(GLenum internalFormat, const d3d11::Format &formatInfo = d3d11::Format::Get(internalFormat, renderer11DeviceCaps); if (renderTarget && levels > 1) { - if (d3d11::SupportsMipGen(formatInfo.texFormat, renderer11DeviceCaps.featureLevel)) + const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(formatInfo.texFormat); + + if (dxgiFormatInfo.nativeMipmapSupport(renderer11DeviceCaps.featureLevel)) { miscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS; } @@ -185,8 +185,8 @@ gl::Error TextureStorage11::getSRV(const gl::TextureState &textureState, { // Make sure to add the level offset for our tiny compressed texture workaround const GLuint effectiveBaseLevel = textureState.getEffectiveBaseLevel(); - bool swizzleRequired = textureState.swizzleRequired(); - bool mipmapping = gl::IsMipmapFiltered(textureState.getSamplerState()); + bool swizzleRequired = textureState.swizzleRequired(); + bool mipmapping = gl::IsMipmapFiltered(textureState.getSamplerState()); unsigned int mipLevels = mipmapping ? (textureState.getEffectiveMaxLevel() - effectiveBaseLevel + 1) : 1; @@ -203,7 +203,11 @@ gl::Error TextureStorage11::getSRV(const gl::TextureState &textureState, if (mRenderer->getWorkarounds().zeroMaxLodWorkaround) { // We must ensure that the level zero texture is in sync with mipped texture. - ANGLE_TRY(useLevelZeroWorkaroundTexture(mipLevels == 1)); + gl::Error error = useLevelZeroWorkaroundTexture(mipLevels == 1); + if (error.isError()) + { + return error; + } } if (swizzleRequired) @@ -211,22 +215,7 @@ gl::Error TextureStorage11::getSRV(const gl::TextureState &textureState, verifySwizzleExists(textureState.getSwizzleState()); } - // We drop the stencil when sampling from the SRV if three conditions hold: - // 1. the drop stencil workaround is enabled. - bool workaround = mRenderer->getWorkarounds().emulateTinyStencilTextures; - // 2. this is a stencil texture. - bool hasStencil = (mFormatInfo.format().stencilBits > 0); - // 3. the texture has a 1x1 or 2x2 mip. - bool hasSmallMips = (getLevelWidth(mMipLevels - 1) <= 2 || getLevelHeight(mMipLevels - 1) <= 2); - - bool useDropStencil = (workaround && hasStencil && hasSmallMips); - if (useDropStencil) - { - // Ensure drop texture gets re-created, if SRV is cached. - ANGLE_TRY(createDropStencilTexture()); - } - - SRVKey key(effectiveBaseLevel, mipLevels, swizzleRequired, useDropStencil); + SRVKey key(effectiveBaseLevel, mipLevels, swizzleRequired); ANGLE_TRY(getCachedOrCreateSRV(key, outSRV)); return gl::NoError(); @@ -243,30 +232,17 @@ gl::Error TextureStorage11::getCachedOrCreateSRV(const SRVKey &key, } ID3D11Resource *texture = nullptr; - DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; - if (key.swizzle) { - const auto &swizzleFormat = - mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()); - ASSERT(!key.dropStencil || swizzleFormat.format().stencilBits == 0); ANGLE_TRY(getSwizzleTexture(&texture)); - format = swizzleFormat.srvFormat; - } - else if (key.dropStencil) - { - ASSERT(mDropStencilTexture); - texture = mDropStencilTexture; - format = DXGI_FORMAT_R32_FLOAT; } else { ANGLE_TRY(getResource(&texture)); - format = mFormatInfo.srvFormat; } ID3D11ShaderResourceView *srv = nullptr; - + DXGI_FORMAT format = (key.swizzle ? mFormatInfo.swizzle.srvFormat : mFormatInfo.srvFormat); ANGLE_TRY(createSRV(key.baseLevel, key.mipLevels, format, texture, &srv)); mSrvCache.insert(std::make_pair(key, srv)); @@ -295,17 +271,25 @@ gl::Error TextureStorage11::getSRVLevel(int mipLevel, else { ID3D11Resource *resource = nullptr; - ANGLE_TRY(getResource(&resource)); + gl::Error error = getResource(&resource); + if (error.isError()) + { + return error; + } DXGI_FORMAT resourceFormat = blitSRV ? mFormatInfo.blitSRVFormat : mFormatInfo.srvFormat; - ANGLE_TRY(createSRV(mipLevel, 1, resourceFormat, resource, &levelSRVs[mipLevel])); + error = createSRV(mipLevel, 1, resourceFormat, resource, &levelSRVs[mipLevel]); + if (error.isError()) + { + return error; + } } } *outSRV = levelSRVs[mipLevel]; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11::getSRVLevels(GLint baseLevel, @@ -326,12 +310,14 @@ gl::Error TextureStorage11::getSRVLevels(GLint baseLevel, if (mRenderer->getWorkarounds().zeroMaxLodWorkaround) { // We must ensure that the level zero texture is in sync with mipped texture. - ANGLE_TRY(useLevelZeroWorkaroundTexture(mipLevels == 1)); + gl::Error error = useLevelZeroWorkaroundTexture(mipLevels == 1); + if (error.isError()) + { + return error; + } } - // TODO(jmadill): Assert we don't need to drop stencil. - - SRVKey key(baseLevel, mipLevels, false, false); + SRVKey key(baseLevel, mipLevels, false); ANGLE_TRY(getCachedOrCreateSRV(key, outSRV)); return gl::NoError(); @@ -351,25 +337,38 @@ gl::Error TextureStorage11::generateSwizzles(const gl::SwizzleState &swizzleTarg { // Need to re-render the swizzle for this level ID3D11ShaderResourceView *sourceSRV = nullptr; - ANGLE_TRY(getSRVLevel(level, true, &sourceSRV)); + gl::Error error = getSRVLevel(level, true, &sourceSRV); + + if (error.isError()) + { + return error; + } ID3D11RenderTargetView *destRTV = nullptr; - ANGLE_TRY(getSwizzleRenderTarget(level, &destRTV)); + error = getSwizzleRenderTarget(level, &destRTV); + if (error.isError()) + { + return error; + } gl::Extents size(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level)); Blit11 *blitter = mRenderer->getBlitter(); - ANGLE_TRY(blitter->swizzleTexture(sourceSRV, destRTV, size, swizzleTarget)); + error = blitter->swizzleTexture(sourceSRV, destRTV, size, swizzleTarget); + if (error.isError()) + { + return error; + } mSwizzleCache[level] = swizzleTarget; } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } -void TextureStorage11::markLevelDirty(int mipLevel) +void TextureStorage11::invalidateSwizzleCacheLevel(int mipLevel) { if (mipLevel >= 0 && static_cast<unsigned int>(mipLevel) < ArraySize(mSwizzleCache)) { @@ -377,15 +376,13 @@ void TextureStorage11::markLevelDirty(int mipLevel) // not a valid swizzle combination mSwizzleCache[mipLevel] = gl::SwizzleState(); } - - SafeRelease(mDropStencilTexture); } -void TextureStorage11::markDirty() +void TextureStorage11::invalidateSwizzleCache() { for (unsigned int mipLevel = 0; mipLevel < ArraySize(mSwizzleCache); mipLevel++) { - markLevelDirty(mipLevel); + invalidateSwizzleCacheLevel(mipLevel); } } @@ -398,7 +395,7 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, const GLint level = index.mipIndex; - markLevelDirty(level); + invalidateSwizzleCacheLevel(level); gl::Extents texSize(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level)); @@ -428,7 +425,7 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, if (!fullCopy && mFormatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN) { // CopySubresourceRegion cannot copy partial depth stencils, use the blitter instead - Blit11 *blitter = mRenderer->getBlitter(); + Blit11 *blitter = mRenderer->getBlitter(); TextureHelper11 source = TextureHelper11::MakeAndReference(srcTexture, getFormatSet()); TextureHelper11 dest = TextureHelper11::MakeAndReference(dstTexture, getFormatSet()); return blitter->copyDepthStencil(source, sourceSubresource, copyArea, texSize, dest, @@ -460,16 +457,22 @@ gl::Error TextureStorage11::copySubresourceLevel(ID3D11Resource *dstTexture, ASSERT(dstTexture); ID3D11Resource *srcTexture = nullptr; + gl::Error error(GL_NO_ERROR); // If the zero-LOD workaround is active and we want to update a level greater than zero, then we // should update the mipmapped texture, even if mapmaps are currently disabled. if (index.mipIndex > 0 && mRenderer->getWorkarounds().zeroMaxLodWorkaround) { - ANGLE_TRY(getMippedResource(&srcTexture)); + error = getMippedResource(&srcTexture); } else { - ANGLE_TRY(getResource(&srcTexture)); + error = getResource(&srcTexture); + } + + if (error.isError()) + { + return error; } ASSERT(srcTexture); @@ -508,17 +511,25 @@ gl::Error TextureStorage11::generateMipmap(const gl::ImageIndex &sourceIndex, { ASSERT(sourceIndex.layerIndex == destIndex.layerIndex); - markLevelDirty(destIndex.mipIndex); + invalidateSwizzleCacheLevel(destIndex.mipIndex); RenderTargetD3D *source = nullptr; - ANGLE_TRY(getRenderTarget(sourceIndex, &source)); + gl::Error error = getRenderTarget(sourceIndex, &source); + if (error.isError()) + { + return error; + } RenderTargetD3D *dest = nullptr; - ANGLE_TRY(getRenderTarget(destIndex, &dest)); + error = getRenderTarget(destIndex, &dest); + if (error.isError()) + { + return error; + } ID3D11ShaderResourceView *sourceSRV = GetAs<RenderTarget11>(source)->getBlitShaderResourceView(); - ID3D11RenderTargetView *destRTV = GetAs<RenderTarget11>(dest)->getRenderTargetView(); + ID3D11RenderTargetView *destRTV = GetAs<RenderTarget11>(dest)->getRenderTargetView(); gl::Box sourceArea(0, 0, 0, source->getWidth(), source->getHeight(), source->getDepth()); gl::Extents sourceSize(source->getWidth(), source->getHeight(), source->getDepth()); @@ -543,7 +554,7 @@ void TextureStorage11::verifySwizzleExists(const gl::SwizzleState &swizzleState) void TextureStorage11::clearSRVCache() { - markDirty(); + invalidateSwizzleCache(); auto iter = mSrvCache.begin(); while (iter != mSrvCache.end()) @@ -571,64 +582,72 @@ gl::Error TextureStorage11::copyToStorage(TextureStorage *destStorage) ASSERT(destStorage); ID3D11Resource *sourceResouce = nullptr; - ANGLE_TRY(getResource(&sourceResouce)); + gl::Error error = getResource(&sourceResouce); + if (error.isError()) + { + return error; + } TextureStorage11 *dest11 = GetAs<TextureStorage11>(destStorage); ID3D11Resource *destResource = nullptr; - ANGLE_TRY(dest11->getResource(&destResource)); + error = dest11->getResource(&destResource); + if (error.isError()) + { + return error; + } ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext(); immediateContext->CopyResource(destResource, sourceResouce); - dest11->markDirty(); + dest11->invalidateSwizzleCache(); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11::setData(const gl::ImageIndex &index, ImageD3D *image, const gl::Box *destBox, - GLenum inputType, + GLenum type, const gl::PixelUnpackState &unpack, const uint8_t *pixelData) { ASSERT(!image->isDirty()); - markLevelDirty(index.mipIndex); - ID3D11Resource *resource = nullptr; ANGLE_TRY(getResource(&resource)); ASSERT(resource); UINT destSubresource = getSubresourceIndex(index); - const auto sizedInputFormat = image->getSizedInputFormat(inputType); - const gl::InternalFormat &inputFormat = gl::GetInternalFormatInfo(sizedInputFormat); + const gl::InternalFormat &internalFormatInfo = + gl::GetInternalFormatInfo(image->getInternalFormat()); gl::Box levelBox(0, 0, 0, getLevelWidth(index.mipIndex), getLevelHeight(index.mipIndex), getLevelDepth(index.mipIndex)); bool fullUpdate = (destBox == nullptr || *destBox == levelBox); - ASSERT(inputFormat.depthBits == 0 || fullUpdate); + ASSERT(internalFormatInfo.depthBits == 0 || fullUpdate); // TODO(jmadill): Handle compressed formats // Compressed formats have different load syntax, so we'll have to handle them with slightly // different logic. Will implemnent this in a follow-up patch, and ensure we do not use SetData // with compressed formats in the calling logic. - ASSERT(!inputFormat.compressed); + ASSERT(!internalFormatInfo.compressed); - const int width = destBox ? destBox->width : static_cast<int>(image->getWidth()); - const int height = destBox ? destBox->height : static_cast<int>(image->getHeight()); - const int depth = destBox ? destBox->depth : static_cast<int>(image->getDepth()); + const int width = destBox ? destBox->width : static_cast<int>(image->getWidth()); + const int height = destBox ? destBox->height : static_cast<int>(image->getHeight()); + const int depth = destBox ? destBox->depth : static_cast<int>(image->getDepth()); GLuint srcRowPitch = 0; ANGLE_TRY_RESULT( - inputFormat.computeRowPitch(width, unpack.alignment, unpack.rowLength), + internalFormatInfo.computeRowPitch(type, width, unpack.alignment, unpack.rowLength), srcRowPitch); GLuint srcDepthPitch = 0; - ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(height, unpack.imageHeight, srcRowPitch), + ANGLE_TRY_RESULT(internalFormatInfo.computeDepthPitch(type, width, height, unpack.alignment, + unpack.rowLength, unpack.imageHeight), srcDepthPitch); GLuint srcSkipBytes = 0; ANGLE_TRY_RESULT( - inputFormat.computeSkipBytes(srcRowPitch, srcDepthPitch, unpack, index.is3D()), + internalFormatInfo.computeSkipBytes(srcRowPitch, srcDepthPitch, unpack.skipImages, + unpack.skipRows, unpack.skipPixels, index.is3D()), srcSkipBytes); const d3d11::Format &d3d11Format = @@ -645,7 +664,7 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, MemoryBuffer *conversionBuffer = nullptr; const uint8_t *data = nullptr; - LoadImageFunctionInfo loadFunctionInfo = d3d11Format.getLoadFunctions()(inputType); + LoadImageFunctionInfo loadFunctionInfo = d3d11Format.loadFunctions(type); if (loadFunctionInfo.requiresConversion) { ANGLE_TRY(mRenderer->getScratchMemoryBuffer(neededSize, &conversionBuffer)); @@ -687,12 +706,6 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, return gl::NoError(); } -gl::Error TextureStorage11::createDropStencilTexture() -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION, "Drop stencil texture not implemented."); -} - TextureStorage11_2D::TextureStorage11_2D(Renderer11 *renderer, SwapChain11 *swapchain) : TextureStorage11(renderer, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE, @@ -778,7 +791,6 @@ TextureStorage11_2D::~TextureStorage11_2D() if (error.isError()) { // TODO: Find a way to report this back to the context - ERR("Error initialization texture storage: %x", error.getCode()); } } } @@ -817,37 +829,63 @@ gl::Error TextureStorage11_2D::copyToStorage(TextureStorage *destStorage) // corresponding textures in destStorage. if (mTexture) { - ANGLE_TRY(dest11->useLevelZeroWorkaroundTexture(false)); + gl::Error error = dest11->useLevelZeroWorkaroundTexture(false); + if (error.isError()) + { + return error; + } ID3D11Resource *destResource = nullptr; - ANGLE_TRY(dest11->getResource(&destResource)); + error = dest11->getResource(&destResource); + if (error.isError()) + { + return error; + } immediateContext->CopyResource(destResource, mTexture); } if (mLevelZeroTexture) { - ANGLE_TRY(dest11->useLevelZeroWorkaroundTexture(true)); + gl::Error error = dest11->useLevelZeroWorkaroundTexture(true); + if (error.isError()) + { + return error; + } ID3D11Resource *destResource = nullptr; - ANGLE_TRY(dest11->getResource(&destResource)); + error = dest11->getResource(&destResource); + if (error.isError()) + { + return error; + } immediateContext->CopyResource(destResource, mLevelZeroTexture); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } + else + { + ID3D11Resource *sourceResouce = nullptr; + gl::Error error = getResource(&sourceResouce); + if (error.isError()) + { + return error; + } - ID3D11Resource *sourceResouce = nullptr; - ANGLE_TRY(getResource(&sourceResouce)); - - ID3D11Resource *destResource = nullptr; - ANGLE_TRY(dest11->getResource(&destResource)); + ID3D11Resource *destResource = nullptr; + error = dest11->getResource(&destResource); + if (error.isError()) + { + return error; + } - immediateContext->CopyResource(destResource, sourceResouce); - dest11->markDirty(); + immediateContext->CopyResource(destResource, sourceResouce); + dest11->invalidateSwizzleCache(); + } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11_2D::useLevelZeroWorkaroundTexture(bool useLevelZeroTexture) @@ -858,7 +896,11 @@ gl::Error TextureStorage11_2D::useLevelZeroWorkaroundTexture(bool useLevelZeroTe { if (!mUseLevelZeroTexture && mTexture) { - ANGLE_TRY(ensureTextureExists(1)); + gl::Error error = ensureTextureExists(1); + if (error.isError()) + { + return error; + } // Pull data back from the mipped texture if necessary. ASSERT(mLevelZeroTexture); @@ -872,7 +914,11 @@ gl::Error TextureStorage11_2D::useLevelZeroWorkaroundTexture(bool useLevelZeroTe { if (mUseLevelZeroTexture && mLevelZeroTexture) { - ANGLE_TRY(ensureTextureExists(mMipLevels)); + gl::Error error = ensureTextureExists(mMipLevels); + if (error.isError()) + { + return error; + } // Pull data back from the level zero texture if necessary. ASSERT(mTexture); @@ -899,7 +945,7 @@ gl::Error TextureStorage11_2D::useLevelZeroWorkaroundTexture(bool useLevelZeroTe } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void TextureStorage11_2D::associateImage(Image11 *image, const gl::ImageIndex &index) @@ -972,28 +1018,42 @@ gl::Error TextureStorage11_2D::releaseAssociatedImage(const gl::ImageIndex &inde { // Force the image to recover from storage before its data is overwritten. // This will reset mAssociatedImages[level] to nullptr too. - ANGLE_TRY(mAssociatedImages[level]->recoverFromAssociatedStorage()); + gl::Error error = mAssociatedImages[level]->recoverFromAssociatedStorage(); + if (error.isError()) + { + return error; + } } } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11_2D::getResource(ID3D11Resource **outResource) { if (mUseLevelZeroTexture && mMipLevels > 1) { - ANGLE_TRY(ensureTextureExists(1)); + gl::Error error = ensureTextureExists(1); + if (error.isError()) + { + return error; + } *outResource = mLevelZeroTexture; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } + else + { + gl::Error error = ensureTextureExists(mMipLevels); + if (error.isError()) + { + return error; + } - ANGLE_TRY(ensureTextureExists(mMipLevels)); - - *outResource = mTexture; - return gl::NoError(); + *outResource = mTexture; + return gl::Error(GL_NO_ERROR); + } } gl::Error TextureStorage11_2D::getMippedResource(ID3D11Resource **outResource) @@ -1001,10 +1061,14 @@ gl::Error TextureStorage11_2D::getMippedResource(ID3D11Resource **outResource) // This shouldn't be called unless the zero max LOD workaround is active. ASSERT(mRenderer->getWorkarounds().zeroMaxLodWorkaround); - ANGLE_TRY(ensureTextureExists(mMipLevels)); + gl::Error error = ensureTextureExists(mMipLevels); + if (error.isError()) + { + return error; + } *outResource = mTexture; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11_2D::ensureTextureExists(int mipLevels) @@ -1078,17 +1142,29 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend if (mRenderTarget[level]) { *outRT = mRenderTarget[level]; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } ID3D11Resource *texture = nullptr; - ANGLE_TRY(getResource(&texture)); + gl::Error error = getResource(&texture); + if (error.isError()) + { + return error; + } ID3D11ShaderResourceView *srv = nullptr; - ANGLE_TRY(getSRVLevel(level, false, &srv)); + error = getSRVLevel(level, false, &srv); + if (error.isError()) + { + return error; + } ID3D11ShaderResourceView *blitSRV = nullptr; - ANGLE_TRY(getSRVLevel(level, true, &blitSRV)); + error = getSRVLevel(level, true, &blitSRV); + if (error.isError()) + { + return error; + } ID3D11Device *device = mRenderer->getDevice(); @@ -1122,7 +1198,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend } *outRT = mLevelZeroRenderTarget; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } if (mFormatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN) @@ -1183,7 +1259,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend SafeRelease(dsv); *outRT = mRenderTarget[level]; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11_2D::createSRV(int baseLevel, @@ -1251,7 +1327,7 @@ gl::Error TextureStorage11_2D::getSwizzleTexture(ID3D11Resource **outTexture) desc.Height = mTextureHeight; desc.MipLevels = mMipLevels; desc.ArraySize = 1; - desc.Format = mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).texFormat; + desc.Format = mFormatInfo.swizzle.texFormat; desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; desc.Usage = D3D11_USAGE_DEFAULT; @@ -1283,13 +1359,16 @@ gl::Error TextureStorage11_2D::getSwizzleRenderTarget(int mipLevel, ID3D11Render if (!mSwizzleRenderTargets[mipLevel]) { ID3D11Resource *swizzleTexture = nullptr; - ANGLE_TRY(getSwizzleTexture(&swizzleTexture)); + gl::Error error = getSwizzleTexture(&swizzleTexture); + if (error.isError()) + { + return error; + } ID3D11Device *device = mRenderer->getDevice(); D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; - rtvDesc.Format = - mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).rtvFormat; + rtvDesc.Format = mFormatInfo.swizzle.rtvFormat; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel; @@ -1306,41 +1385,7 @@ gl::Error TextureStorage11_2D::getSwizzleRenderTarget(int mipLevel, ID3D11Render } *outRTV = mSwizzleRenderTargets[mipLevel]; - return gl::NoError(); -} - -gl::Error TextureStorage11_2D::createDropStencilTexture() -{ - if (mDropStencilTexture) - { - return gl::NoError(); - } - - D3D11_TEXTURE2D_DESC dropDesc = {}; - dropDesc.ArraySize = 1; - dropDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL; - dropDesc.CPUAccessFlags = 0; - dropDesc.Format = DXGI_FORMAT_R32_TYPELESS; - dropDesc.Height = mTextureHeight; - dropDesc.MipLevels = mMipLevels; - dropDesc.MiscFlags = 0; - dropDesc.SampleDesc.Count = 1; - dropDesc.SampleDesc.Quality = 0; - dropDesc.Usage = D3D11_USAGE_DEFAULT; - dropDesc.Width = mTextureWidth; - - ID3D11Device *device = mRenderer->getDevice(); - - HRESULT hr = device->CreateTexture2D(&dropDesc, nullptr, &mDropStencilTexture); - if (FAILED(hr)) - { - return gl::Error(GL_INVALID_OPERATION, "Error creating drop stencil texture."); - } - d3d11::SetDebugName(mDropStencilTexture, "TexStorage2D.DropStencil"); - - ANGLE_TRY(initDropStencilTexture(gl::ImageIndexIterator::Make2D(0, mMipLevels))); - - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } TextureStorage11_External::TextureStorage11_External( @@ -1352,15 +1397,15 @@ TextureStorage11_External::TextureStorage11_External( ASSERT(stream->getProducerType() == egl::Stream::ProducerType::D3D11TextureNV12); StreamProducerNV12 *producer = static_cast<StreamProducerNV12 *>(stream->getImplementation()); mTexture = producer->getD3DTexture(); - mSubresourceIndex = producer->getArraySlice(); + mSubresourceIndex = producer->getArraySlice(); mTexture->AddRef(); mMipLevels = 1; D3D11_TEXTURE2D_DESC desc; mTexture->GetDesc(&desc); - mTextureWidth = desc.Width; - mTextureHeight = desc.Height; - mTextureDepth = 1; + mTextureWidth = desc.Width; + mTextureHeight = desc.Height; + mTextureDepth = 1; mHasKeyedMutex = (desc.MiscFlags & D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX) != 0; } @@ -1504,10 +1549,10 @@ TextureStorage11_EGLImage::TextureStorage11_EGLImage(Renderer11 *renderer, { mCurrentRenderTarget = reinterpret_cast<uintptr_t>(renderTarget11); - mMipLevels = 1; - mTextureWidth = renderTarget11->getWidth(); - mTextureHeight = renderTarget11->getHeight(); - mTextureDepth = 1; + mMipLevels = 1; + mTextureWidth = renderTarget11->getWidth(); + mTextureHeight = renderTarget11->getHeight(); + mTextureDepth = 1; } TextureStorage11_EGLImage::~TextureStorage11_EGLImage() @@ -1549,8 +1594,13 @@ gl::Error TextureStorage11_EGLImage::getRenderTarget(const gl::ImageIndex &index { ASSERT(!index.hasLayer()); ASSERT(index.mipIndex == 0); + UNUSED_ASSERTION_VARIABLE(index); - ANGLE_TRY(checkForUpdatedRenderTarget()); + gl::Error error = checkForUpdatedRenderTarget(); + if (error.isError()) + { + return error; + } return mImage->getRenderTarget(outRT); } @@ -1558,19 +1608,27 @@ gl::Error TextureStorage11_EGLImage::getRenderTarget(const gl::ImageIndex &index gl::Error TextureStorage11_EGLImage::copyToStorage(TextureStorage *destStorage) { ID3D11Resource *sourceResouce = nullptr; - ANGLE_TRY(getResource(&sourceResouce)); + gl::Error error = getResource(&sourceResouce); + if (error.isError()) + { + return error; + } ASSERT(destStorage); TextureStorage11_2D *dest11 = GetAs<TextureStorage11_2D>(destStorage); ID3D11Resource *destResource = nullptr; - ANGLE_TRY(dest11->getResource(&destResource)); + error = dest11->getResource(&destResource); + if (error.isError()) + { + return error; + } ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext(); immediateContext->CopyResource(destResource, sourceResouce); - dest11->markDirty(); + dest11->invalidateSwizzleCache(); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void TextureStorage11_EGLImage::associateImage(Image11 *, const gl::ImageIndex &) @@ -1610,7 +1668,7 @@ gl::Error TextureStorage11_EGLImage::getSwizzleTexture(ID3D11Resource **outTextu desc.Height = mTextureHeight; desc.MipLevels = mMipLevels; desc.ArraySize = 1; - desc.Format = mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).texFormat; + desc.Format = mFormatInfo.swizzle.texFormat; desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; desc.Usage = D3D11_USAGE_DEFAULT; @@ -1643,13 +1701,16 @@ gl::Error TextureStorage11_EGLImage::getSwizzleRenderTarget(int mipLevel, if (!mSwizzleRenderTargets[mipLevel]) { ID3D11Resource *swizzleTexture = nullptr; - ANGLE_TRY(getSwizzleTexture(&swizzleTexture)); + gl::Error error = getSwizzleTexture(&swizzleTexture); + if (error.isError()) + { + return error; + } ID3D11Device *device = mRenderer->getDevice(); D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; - rtvDesc.Format = - mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).rtvFormat; + rtvDesc.Format = mFormatInfo.swizzle.rtvFormat; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel; @@ -1666,7 +1727,7 @@ gl::Error TextureStorage11_EGLImage::getSwizzleRenderTarget(int mipLevel, } *outRTV = mSwizzleRenderTargets[mipLevel]; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11_EGLImage::checkForUpdatedRenderTarget() @@ -1719,7 +1780,11 @@ gl::Error TextureStorage11_EGLImage::createSRV(int baseLevel, else { RenderTarget11 *renderTarget = nullptr; - ANGLE_TRY(getImageRenderTarget(&renderTarget)); + gl::Error error = getImageRenderTarget(&renderTarget); + if (error.isError()) + { + return error; + } ASSERT(texture == renderTarget->getTexture()); @@ -1860,20 +1925,36 @@ gl::Error TextureStorage11_Cube::copyToStorage(TextureStorage *destStorage) // corresponding textures in destStorage. if (mTexture) { - ANGLE_TRY(dest11->useLevelZeroWorkaroundTexture(false)); + gl::Error error = dest11->useLevelZeroWorkaroundTexture(false); + if (error.isError()) + { + return error; + } ID3D11Resource *destResource = nullptr; - ANGLE_TRY(dest11->getResource(&destResource)); + error = dest11->getResource(&destResource); + if (error.isError()) + { + return error; + } immediateContext->CopyResource(destResource, mTexture); } if (mLevelZeroTexture) { - ANGLE_TRY(dest11->useLevelZeroWorkaroundTexture(true)); + gl::Error error = dest11->useLevelZeroWorkaroundTexture(true); + if (error.isError()) + { + return error; + } ID3D11Resource *destResource = nullptr; - ANGLE_TRY(dest11->getResource(&destResource)); + error = dest11->getResource(&destResource); + if (error.isError()) + { + return error; + } immediateContext->CopyResource(destResource, mLevelZeroTexture); } @@ -1881,18 +1962,26 @@ gl::Error TextureStorage11_Cube::copyToStorage(TextureStorage *destStorage) else { ID3D11Resource *sourceResouce = nullptr; - ANGLE_TRY(getResource(&sourceResouce)); + gl::Error error = getResource(&sourceResouce); + if (error.isError()) + { + return error; + } ID3D11Resource *destResource = nullptr; - ANGLE_TRY(dest11->getResource(&destResource)); + error = dest11->getResource(&destResource); + if (error.isError()) + { + return error; + } ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext(); immediateContext->CopyResource(destResource, sourceResouce); } - dest11->markDirty(); + dest11->invalidateSwizzleCache(); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11_Cube::useLevelZeroWorkaroundTexture(bool useLevelZeroTexture) @@ -1901,7 +1990,11 @@ gl::Error TextureStorage11_Cube::useLevelZeroWorkaroundTexture(bool useLevelZero { if (!mUseLevelZeroTexture && mTexture) { - ANGLE_TRY(ensureTextureExists(1)); + gl::Error error = ensureTextureExists(1); + if (error.isError()) + { + return error; + } // Pull data back from the mipped texture if necessary. ASSERT(mLevelZeroTexture); @@ -1920,7 +2013,11 @@ gl::Error TextureStorage11_Cube::useLevelZeroWorkaroundTexture(bool useLevelZero { if (mUseLevelZeroTexture && mLevelZeroTexture) { - ANGLE_TRY(ensureTextureExists(mMipLevels)); + gl::Error error = ensureTextureExists(mMipLevels); + if (error.isError()) + { + return error; + } // Pull data back from the level zero texture if necessary. ASSERT(mTexture); @@ -1936,7 +2033,7 @@ gl::Error TextureStorage11_Cube::useLevelZeroWorkaroundTexture(bool useLevelZero mUseLevelZeroTexture = false; } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } void TextureStorage11_Cube::associateImage(Image11 *image, const gl::ImageIndex &index) @@ -2029,29 +2126,43 @@ gl::Error TextureStorage11_Cube::releaseAssociatedImage(const gl::ImageIndex &in { // Force the image to recover from storage before its data is overwritten. // This will reset mAssociatedImages[level] to nullptr too. - ANGLE_TRY( - mAssociatedImages[layerTarget][level]->recoverFromAssociatedStorage()); + gl::Error error = + mAssociatedImages[layerTarget][level]->recoverFromAssociatedStorage(); + if (error.isError()) + { + return error; + } } } } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11_Cube::getResource(ID3D11Resource **outResource) { if (mUseLevelZeroTexture && mMipLevels > 1) { - ANGLE_TRY(ensureTextureExists(1)); + gl::Error error = ensureTextureExists(1); + if (error.isError()) + { + return error; + } + *outResource = mLevelZeroTexture; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } else { - ANGLE_TRY(ensureTextureExists(mMipLevels)); + gl::Error error = ensureTextureExists(mMipLevels); + if (error.isError()) + { + return error; + } + *outResource = mTexture; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } } @@ -2060,9 +2171,14 @@ gl::Error TextureStorage11_Cube::getMippedResource(ID3D11Resource **outResource) // This shouldn't be called unless the zero max LOD workaround is active. ASSERT(mRenderer->getWorkarounds().zeroMaxLodWorkaround); - ANGLE_TRY(ensureTextureExists(mMipLevels)); + gl::Error error = ensureTextureExists(mMipLevels); + if (error.isError()) + { + return error; + } + *outResource = mTexture; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11_Cube::ensureTextureExists(int mipLevels) @@ -2113,7 +2229,7 @@ gl::Error TextureStorage11_Cube::ensureTextureExists(int mipLevels) d3d11::SetDebugName(*outputTexture, "TexStorageCube.Texture"); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11_Cube::createRenderTargetSRV(ID3D11Resource *texture, @@ -2167,7 +2283,11 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, HRESULT result; ID3D11Resource *texture = nullptr; - ANGLE_TRY(getResource(&texture)); + gl::Error error = getResource(&texture); + if (error.isError()) + { + return error; + } if (mUseLevelZeroTexture) { @@ -2206,12 +2326,15 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, } ID3D11ShaderResourceView *srv = nullptr; - ANGLE_TRY(createRenderTargetSRV(texture, index, mFormatInfo.srvFormat, &srv)); + error = createRenderTargetSRV(texture, index, mFormatInfo.srvFormat, &srv); + if (error.isError()) + { + return error; + } ID3D11ShaderResourceView *blitSRV = nullptr; if (mFormatInfo.blitSRVFormat != mFormatInfo.srvFormat) { - gl::Error error = - createRenderTargetSRV(texture, index, mFormatInfo.blitSRVFormat, &blitSRV); + error = createRenderTargetSRV(texture, index, mFormatInfo.blitSRVFormat, &blitSRV); if (error.isError()) { SafeRelease(srv); @@ -2319,8 +2442,8 @@ gl::Error TextureStorage11_Cube::createSRV(int baseLevel, // Unnormalized integer cube maps are not supported by DX11; we emulate them as an array of six // 2D textures - const GLenum componentType = d3d11::GetComponentType(format); - if (componentType == GL_INT || componentType == GL_UNSIGNED_INT) + const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(format); + if (dxgiFormatInfo.componentType == GL_INT || dxgiFormatInfo.componentType == GL_UNSIGNED_INT) { srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY; srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + baseLevel; @@ -2386,7 +2509,7 @@ gl::Error TextureStorage11_Cube::getSwizzleTexture(ID3D11Resource **outTexture) desc.Height = mTextureHeight; desc.MipLevels = mMipLevels; desc.ArraySize = CUBE_FACE_COUNT; - desc.Format = mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).texFormat; + desc.Format = mFormatInfo.swizzle.texFormat; desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; desc.Usage = D3D11_USAGE_DEFAULT; @@ -2419,13 +2542,16 @@ gl::Error TextureStorage11_Cube::getSwizzleRenderTarget(int mipLevel, if (!mSwizzleRenderTargets[mipLevel]) { ID3D11Resource *swizzleTexture = nullptr; - ANGLE_TRY(getSwizzleTexture(&swizzleTexture)); + gl::Error error = getSwizzleTexture(&swizzleTexture); + if (error.isError()) + { + return error; + } ID3D11Device *device = mRenderer->getDevice(); D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; - rtvDesc.Format = - mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).rtvFormat; + rtvDesc.Format = mFormatInfo.swizzle.rtvFormat; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture2DArray.FirstArraySlice = 0; @@ -2444,67 +2570,7 @@ gl::Error TextureStorage11_Cube::getSwizzleRenderTarget(int mipLevel, } *outRTV = mSwizzleRenderTargets[mipLevel]; - return gl::NoError(); -} - -gl::Error TextureStorage11::initDropStencilTexture(const gl::ImageIndexIterator &it) -{ - ID3D11Resource *resource = nullptr; - ANGLE_TRY(getResource(&resource)); - TextureHelper11 sourceTexture = TextureHelper11::MakeAndReference(resource, mFormatInfo); - TextureHelper11 destTexture = TextureHelper11::MakeAndReference( - mDropStencilTexture, - d3d11::Format::Get(GL_DEPTH_COMPONENT32F, mRenderer->getRenderer11DeviceCaps())); - - gl::ImageIndexIterator itCopy = it; - - while (itCopy.hasNext()) - { - gl::ImageIndex index = itCopy.next(); - gl::Box wholeArea(0, 0, 0, getLevelWidth(index.mipIndex), getLevelHeight(index.mipIndex), - 1); - gl::Extents wholeSize(wholeArea.width, wholeArea.height, 1); - UINT subresource = getSubresourceIndex(index); - ANGLE_TRY(mRenderer->getBlitter()->copyDepthStencil(sourceTexture, subresource, wholeArea, - wholeSize, destTexture, subresource, - wholeArea, wholeSize, nullptr)); - } - - return gl::NoError(); -} - -gl::Error TextureStorage11_Cube::createDropStencilTexture() -{ - if (mDropStencilTexture) - { - return gl::NoError(); - } - - D3D11_TEXTURE2D_DESC dropDesc = {}; - dropDesc.ArraySize = 6; - dropDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL; - dropDesc.CPUAccessFlags = 0; - dropDesc.Format = DXGI_FORMAT_R32_TYPELESS; - dropDesc.Height = mTextureHeight; - dropDesc.MipLevels = mMipLevels; - dropDesc.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE; - dropDesc.SampleDesc.Count = 1; - dropDesc.SampleDesc.Quality = 0; - dropDesc.Usage = D3D11_USAGE_DEFAULT; - dropDesc.Width = mTextureWidth; - - ID3D11Device *device = mRenderer->getDevice(); - - HRESULT hr = device->CreateTexture2D(&dropDesc, nullptr, &mDropStencilTexture); - if (FAILED(hr)) - { - return gl::Error(GL_INVALID_OPERATION, "Error creating drop stencil texture."); - } - d3d11::SetDebugName(mDropStencilTexture, "TexStorageCube.DropStencil"); - - ANGLE_TRY(initDropStencilTexture(gl::ImageIndexIterator::MakeCube(0, mMipLevels))); - - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } TextureStorage11_3D::TextureStorage11_3D(Renderer11 *renderer, @@ -2647,12 +2713,16 @@ gl::Error TextureStorage11_3D::releaseAssociatedImage(const gl::ImageIndex &inde { // Force the image to recover from storage before its data is overwritten. // This will reset mAssociatedImages[level] to nullptr too. - ANGLE_TRY(mAssociatedImages[level]->recoverFromAssociatedStorage()); + gl::Error error = mAssociatedImages[level]->recoverFromAssociatedStorage(); + if (error.isError()) + { + return error; + } } } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11_3D::getResource(ID3D11Resource **outResource) @@ -2740,13 +2810,25 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend if (!mLevelRenderTargets[mipLevel]) { ID3D11Resource *texture = nullptr; - ANGLE_TRY(getResource(&texture)); + gl::Error error = getResource(&texture); + if (error.isError()) + { + return error; + } ID3D11ShaderResourceView *srv = nullptr; - ANGLE_TRY(getSRVLevel(mipLevel, false, &srv)); + error = getSRVLevel(mipLevel, false, &srv); + if (error.isError()) + { + return error; + } ID3D11ShaderResourceView *blitSRV = nullptr; - ANGLE_TRY(getSRVLevel(mipLevel, true, &blitSRV)); + error = getSRVLevel(mipLevel, true, &blitSRV); + if (error.isError()) + { + return error; + } ID3D11Device *device = mRenderer->getDevice(); @@ -2796,10 +2878,14 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend HRESULT result; ID3D11Resource *texture = nullptr; - ANGLE_TRY(getResource(&texture)); + gl::Error error = getResource(&texture); + if (error.isError()) + { + return error; + } // TODO, what kind of SRV is expected here? - ID3D11ShaderResourceView *srv = nullptr; + ID3D11ShaderResourceView *srv = nullptr; ID3D11ShaderResourceView *blitSRV = nullptr; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; @@ -2836,7 +2922,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend ASSERT(outRT); *outRT = mLevelLayerRenderTargets[key]; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } } @@ -2853,7 +2939,7 @@ gl::Error TextureStorage11_3D::getSwizzleTexture(ID3D11Resource **outTexture) desc.Height = mTextureHeight; desc.Depth = mTextureDepth; desc.MipLevels = mMipLevels; - desc.Format = mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).texFormat; + desc.Format = mFormatInfo.swizzle.texFormat; desc.Usage = D3D11_USAGE_DEFAULT; desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; desc.CPUAccessFlags = 0; @@ -2883,13 +2969,16 @@ gl::Error TextureStorage11_3D::getSwizzleRenderTarget(int mipLevel, ID3D11Render if (!mSwizzleRenderTargets[mipLevel]) { ID3D11Resource *swizzleTexture = nullptr; - ANGLE_TRY(getSwizzleTexture(&swizzleTexture)); + gl::Error error = getSwizzleTexture(&swizzleTexture); + if (error.isError()) + { + return error; + } ID3D11Device *device = mRenderer->getDevice(); D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; - rtvDesc.Format = - mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).rtvFormat; + rtvDesc.Format = mFormatInfo.swizzle.rtvFormat; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D; rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture3D.FirstWSlice = 0; @@ -3052,12 +3141,16 @@ gl::Error TextureStorage11_2DArray::releaseAssociatedImage(const gl::ImageIndex { // Force the image to recover from storage before its data is overwritten. // This will reset mAssociatedImages[level] to nullptr too. - ANGLE_TRY(mAssociatedImages[key]->recoverFromAssociatedStorage()); + gl::Error error = mAssociatedImages[key]->recoverFromAssociatedStorage(); + if (error.isError()) + { + return error; + } } } } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11_2DArray::getResource(ID3D11Resource **outResource) @@ -3180,14 +3273,21 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index, HRESULT result; ID3D11Resource *texture = nullptr; - ANGLE_TRY(getResource(&texture)); + gl::Error error = getResource(&texture); + if (error.isError()) + { + return error; + } ID3D11ShaderResourceView *srv; - ANGLE_TRY(createRenderTargetSRV(texture, index, mFormatInfo.srvFormat, &srv)); + error = createRenderTargetSRV(texture, index, mFormatInfo.srvFormat, &srv); + if (error.isError()) + { + return error; + } ID3D11ShaderResourceView *blitSRV; if (mFormatInfo.blitSRVFormat != mFormatInfo.srvFormat) { - gl::Error error = - createRenderTargetSRV(texture, index, mFormatInfo.blitSRVFormat, &blitSRV); + error = createRenderTargetSRV(texture, index, mFormatInfo.blitSRVFormat, &blitSRV); if (error.isError()) { SafeRelease(srv); @@ -3275,7 +3375,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index, ASSERT(outRT); *outRT = mRenderTargets[key]; - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error TextureStorage11_2DArray::getSwizzleTexture(ID3D11Resource **outTexture) @@ -3289,7 +3389,7 @@ gl::Error TextureStorage11_2DArray::getSwizzleTexture(ID3D11Resource **outTextur desc.Height = mTextureHeight; desc.MipLevels = mMipLevels; desc.ArraySize = mTextureDepth; - desc.Format = mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).texFormat; + desc.Format = mFormatInfo.swizzle.texFormat; desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; desc.Usage = D3D11_USAGE_DEFAULT; @@ -3322,13 +3422,16 @@ gl::Error TextureStorage11_2DArray::getSwizzleRenderTarget(int mipLevel, if (!mSwizzleRenderTargets[mipLevel]) { ID3D11Resource *swizzleTexture = nullptr; - ANGLE_TRY(getSwizzleTexture(&swizzleTexture)); + gl::Error error = getSwizzleTexture(&swizzleTexture); + if (error.isError()) + { + return error; + } ID3D11Device *device = mRenderer->getDevice(); D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; - rtvDesc.Format = - mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).rtvFormat; + rtvDesc.Format = mFormatInfo.swizzle.rtvFormat; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture2DArray.FirstArraySlice = 0; @@ -3347,44 +3450,6 @@ gl::Error TextureStorage11_2DArray::getSwizzleRenderTarget(int mipLevel, } *outRTV = mSwizzleRenderTargets[mipLevel]; - return gl::NoError(); -} - -gl::Error TextureStorage11_2DArray::createDropStencilTexture() -{ - if (mDropStencilTexture) - { - return gl::NoError(); - } - - D3D11_TEXTURE2D_DESC dropDesc = {}; - dropDesc.ArraySize = mTextureDepth; - dropDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL; - dropDesc.CPUAccessFlags = 0; - dropDesc.Format = DXGI_FORMAT_R32_TYPELESS; - dropDesc.Height = mTextureHeight; - dropDesc.MipLevels = mMipLevels; - dropDesc.MiscFlags = 0; - dropDesc.SampleDesc.Count = 1; - dropDesc.SampleDesc.Quality = 0; - dropDesc.Usage = D3D11_USAGE_DEFAULT; - dropDesc.Width = mTextureWidth; - - ID3D11Device *device = mRenderer->getDevice(); - - HRESULT hr = device->CreateTexture2D(&dropDesc, nullptr, &mDropStencilTexture); - if (FAILED(hr)) - { - return gl::Error(GL_INVALID_OPERATION, "Error creating drop stencil texture."); - } - d3d11::SetDebugName(mDropStencilTexture, "TexStorage2DArray.DropStencil"); - - std::vector<GLsizei> layerCounts(mMipLevels, mTextureDepth); - - ANGLE_TRY(initDropStencilTexture( - gl::ImageIndexIterator::Make2DArray(0, mMipLevels, layerCounts.data()))); - - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } - } // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h index 46eb8458b..8d968adb0 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h @@ -59,8 +59,8 @@ class TextureStorage11 : public TextureStorage virtual UINT getSubresourceIndex(const gl::ImageIndex &index) const; gl::Error generateSwizzles(const gl::SwizzleState &swizzleTarget); - void markLevelDirty(int mipLevel); - void markDirty(); + void invalidateSwizzleCacheLevel(int mipLevel); + void invalidateSwizzleCache(); gl::Error updateSubresourceLevel(ID3D11Resource *texture, unsigned int sourceSubresource, const gl::ImageIndex &index, const gl::Box ©Area); @@ -94,10 +94,6 @@ class TextureStorage11 : public TextureStorage virtual gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV) = 0; gl::Error getSRVLevel(int mipLevel, bool blitSRV, ID3D11ShaderResourceView **outSRV); - // Get a version of a depth texture with only depth information, not stencil. - virtual gl::Error createDropStencilTexture(); - gl::Error initDropStencilTexture(const gl::ImageIndexIterator &it); - // The baseLevel parameter should *not* have mTopLevel applied. virtual gl::Error createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture, ID3D11ShaderResourceView **outSRV) const = 0; @@ -117,7 +113,6 @@ class TextureStorage11 : public TextureStorage unsigned int mTextureDepth; gl::SwizzleState mSwizzleCache[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; - ID3D11Texture2D *mDropStencilTexture; private: const UINT mBindFlags; @@ -125,14 +120,13 @@ class TextureStorage11 : public TextureStorage struct SRVKey { - SRVKey(int baseLevel, int mipLevels, bool swizzle, bool dropStencil); + SRVKey(int baseLevel = 0, int mipLevels = 0, bool swizzle = false); bool operator<(const SRVKey &rhs) const; - int baseLevel = 0; // Without mTopLevel applied. - int mipLevels = 0; - bool swizzle = false; - bool dropStencil = false; + int baseLevel; // Without mTopLevel applied. + int mipLevels; + bool swizzle; }; typedef std::map<SRVKey, ID3D11ShaderResourceView *> SRVCache; @@ -148,35 +142,30 @@ class TextureStorage11_2D : public TextureStorage11 public: TextureStorage11_2D(Renderer11 *renderer, SwapChain11 *swapchain); TextureStorage11_2D(Renderer11 *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels, bool hintLevelZeroOnly = false); - ~TextureStorage11_2D() override; + virtual ~TextureStorage11_2D(); - gl::Error getResource(ID3D11Resource **outResource) override; - gl::Error getMippedResource(ID3D11Resource **outResource) override; - gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT) override; + virtual gl::Error getResource(ID3D11Resource **outResource); + virtual gl::Error getMippedResource(ID3D11Resource **outResource); + virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT); - gl::Error copyToStorage(TextureStorage *destStorage) override; + virtual gl::Error copyToStorage(TextureStorage *destStorage); - void associateImage(Image11 *image, const gl::ImageIndex &index) override; - void disassociateImage(const gl::ImageIndex &index, Image11 *expectedImage) override; - bool isAssociatedImageValid(const gl::ImageIndex &index, Image11 *expectedImage) override; - gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11 *incomingImage) override; + virtual void associateImage(Image11* image, const gl::ImageIndex &index); + virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage); + virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage); + virtual gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage); - gl::Error useLevelZeroWorkaroundTexture(bool useLevelZeroTexture) override; + virtual gl::Error useLevelZeroWorkaroundTexture(bool useLevelZeroTexture); protected: - gl::Error getSwizzleTexture(ID3D11Resource **outTexture) override; - gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV) override; - - gl::Error createDropStencilTexture() override; + virtual gl::Error getSwizzleTexture(ID3D11Resource **outTexture); + virtual gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV); gl::Error ensureTextureExists(int mipLevels); private: - gl::Error createSRV(int baseLevel, - int mipLevels, - DXGI_FORMAT format, - ID3D11Resource *texture, - ID3D11ShaderResourceView **outSRV) const override; + virtual gl::Error createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture, + ID3D11ShaderResourceView **outSRV) const; ID3D11Texture2D *mTexture; RenderTarget11 *mRenderTarget[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; @@ -312,8 +301,6 @@ class TextureStorage11_Cube : public TextureStorage11 virtual gl::Error getSwizzleTexture(ID3D11Resource **outTexture); virtual gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV); - gl::Error createDropStencilTexture() override; - gl::Error ensureTextureExists(int mipLevels); private: @@ -397,8 +384,6 @@ class TextureStorage11_2DArray : public TextureStorage11 virtual gl::Error getSwizzleTexture(ID3D11Resource **outTexture); virtual gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV); - gl::Error createDropStencilTexture() override; - private: virtual gl::Error createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture, ID3D11ShaderResourceView **outSRV) const; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/VertexArray11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/VertexArray11.cpp index e06a6b22b..8f0fe8496 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/VertexArray11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/VertexArray11.cpp @@ -182,8 +182,12 @@ gl::Error VertexArray11::updateDirtyAndDynamicAttribs(VertexDataManager *vertexD break; case VertexStorageType::STATIC: { - ANGLE_TRY( - VertexDataManager::StoreStaticAttrib(translatedAttrib, count, instances)); + auto error = + VertexDataManager::StoreStaticAttrib(translatedAttrib, count, instances); + if (error.isError()) + { + return error; + } break; } case VertexStorageType::CURRENT_VALUE: diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.cpp index 6cd91bd35..8e2d119d2 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.cpp @@ -21,9 +21,9 @@ namespace rx VertexBuffer11::VertexBuffer11(Renderer11 *const renderer) : mRenderer(renderer) { - mBuffer = NULL; - mBufferSize = 0; - mDynamicUsage = false; + mBuffer = NULL; + mBufferSize = 0; + mDynamicUsage = false; mMappedResourceData = NULL; } @@ -41,21 +41,20 @@ gl::Error VertexBuffer11::initialize(unsigned int size, bool dynamicUsage) if (size > 0) { - ID3D11Device *dxDevice = mRenderer->getDevice(); + ID3D11Device* dxDevice = mRenderer->getDevice(); D3D11_BUFFER_DESC bufferDesc; - bufferDesc.ByteWidth = size; - bufferDesc.Usage = D3D11_USAGE_DYNAMIC; - bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; - bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - bufferDesc.MiscFlags = 0; + bufferDesc.ByteWidth = size; + bufferDesc.Usage = D3D11_USAGE_DYNAMIC; + bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + bufferDesc.MiscFlags = 0; bufferDesc.StructureByteStride = 0; HRESULT result = dxDevice->CreateBuffer(&bufferDesc, NULL, &mBuffer); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to allocate internal vertex buffer of size, %lu.", size); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal vertex buffer of size, %lu.", size); } if (dynamicUsage) @@ -68,7 +67,7 @@ gl::Error VertexBuffer11::initialize(unsigned int size, bool dynamicUsage) } } - mBufferSize = size; + mBufferSize = size; mDynamicUsage = dynamicUsage; return gl::Error(GL_NO_ERROR); @@ -82,15 +81,13 @@ gl::Error VertexBuffer11::mapResource() D3D11_MAPPED_SUBRESOURCE mappedResource; - HRESULT result = - dxContext->Map(mBuffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mappedResource); + HRESULT result = dxContext->Map(mBuffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mappedResource); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to map internal vertex buffer, HRESULT: 0x%08x.", result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal vertex buffer, HRESULT: 0x%08x.", result); } - mMappedResourceData = reinterpret_cast<uint8_t *>(mappedResource.pData); + mMappedResourceData = reinterpret_cast<uint8_t*>(mappedResource.pData); } return gl::Error(GL_NO_ERROR); @@ -123,7 +120,11 @@ gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attri int inputStride = static_cast<int>(ComputeVertexAttributeStride(attrib)); // This will map the resource if it isn't already mapped. - ANGLE_TRY(mapResource()); + gl::Error error = mapResource(); + if (error.isError()) + { + return error; + } uint8_t *output = mMappedResourceData + offset; @@ -135,13 +136,12 @@ gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attri } gl::VertexFormatType vertexFormatType = gl::GetVertexFormatType(attrib, currentValueType); - const D3D_FEATURE_LEVEL featureLevel = mRenderer->getRenderer11DeviceCaps().featureLevel; - const d3d11::VertexFormat &vertexFormatInfo = - d3d11::GetVertexFormatInfo(vertexFormatType, featureLevel); + const D3D_FEATURE_LEVEL featureLevel = mRenderer->getRenderer11DeviceCaps().featureLevel; + const d3d11::VertexFormat &vertexFormatInfo = d3d11::GetVertexFormatInfo(vertexFormatType, featureLevel); ASSERT(vertexFormatInfo.copyFunction != NULL); vertexFormatInfo.copyFunction(input, inputStride, count, output); - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } unsigned int VertexBuffer11::getBufferSize() const @@ -174,8 +174,7 @@ gl::Error VertexBuffer11::discard() HRESULT result = dxContext->Map(mBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); if (FAILED(result)) { - return gl::Error(GL_OUT_OF_MEMORY, - "Failed to map internal buffer for discarding, HRESULT: 0x%08x", result); + return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal buffer for discarding, HRESULT: 0x%08x", result); } dxContext->Unmap(mBuffer, 0); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json deleted file mode 100644 index 5b8d73568..000000000 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "UNKNOWN": "NONE", - "R32G32B32A32_TYPELESS": "", - "R32G32B32A32_FLOAT": "", - "R32G32B32A32_UINT": "", - "R32G32B32A32_SINT": "", - "R32G32B32_TYPELESS": "", - "R32G32B32_FLOAT": "", - "R32G32B32_UINT": "", - "R32G32B32_SINT": "", - "R16G16B16A16_TYPELESS": "", - "R16G16B16A16_FLOAT": "", - "R16G16B16A16_UNORM": "", - "R16G16B16A16_UINT": "", - "R16G16B16A16_SNORM": "", - "R16G16B16A16_SINT": "", - "R32G32_TYPELESS": "", - "R32G32_FLOAT": "", - "R32G32_UINT": "", - "R32G32_SINT": "", - "R32G8X24_TYPELESS": "", - "D32_FLOAT_S8X24_UINT": "", - "R32_FLOAT_X8X24_TYPELESS": "", - "X32_TYPELESS_G8X24_UINT": "", - "R10G10B10A2_TYPELESS": "", - "R10G10B10A2_UNORM": "", - "R10G10B10A2_UINT": "", - "R11G11B10_FLOAT": "", - "R8G8B8A8_TYPELESS": "", - "R8G8B8A8_UNORM": "", - "R8G8B8A8_UNORM_SRGB": "", - "R8G8B8A8_UINT": "", - "R8G8B8A8_SNORM": "", - "R8G8B8A8_SINT": "", - "R16G16_TYPELESS": "", - "R16G16_FLOAT": "", - "R16G16_UNORM": "", - "R16G16_UINT": "", - "R16G16_SNORM": "", - "R16G16_SINT": "", - "R32_TYPELESS": "", - "D32_FLOAT": "", - "R32_FLOAT": "", - "R32_UINT": "", - "R32_SINT": "", - "R24G8_TYPELESS": "", - "D24_UNORM_S8_UINT": "", - "R24_UNORM_X8_TYPELESS": "", - "X24_TYPELESS_G8_UINT": "", - "R8G8_TYPELESS": "", - "R8G8_UNORM": "", - "R8G8_UINT": "", - "R8G8_SNORM": "", - "R8G8_SINT": "", - "R16_TYPELESS": "", - "R16_FLOAT": "", - "D16_UNORM": "", - "R16_UNORM": "", - "R16_UINT": "", - "R16_SNORM": "", - "R16_SINT": "", - "R8_TYPELESS": "", - "R8_UNORM": "", - "R8_UINT": "", - "R8_SNORM": "", - "R8_SINT": "", - "A8_UNORM": "", - "R1_UNORM": "", - "R9G9B9E5_SHAREDEXP": "", - "R8G8_B8G8_UNORM": "", - "G8R8_G8B8_UNORM": "", - "BC1_TYPELESS": "", - "BC1_UNORM": "BC1_RGBA_UNORM_BLOCK", - "BC1_UNORM_SRGB": "", - "BC2_TYPELESS": "", - "BC2_UNORM": "BC2_RGBA_UNORM_BLOCK", - "BC2_UNORM_SRGB": "", - "BC3_TYPELESS": "", - "BC3_UNORM": "BC3_RGBA_UNORM_BLOCK", - "BC3_UNORM_SRGB": "", - "BC4_TYPELESS": "", - "BC4_UNORM": "", - "BC4_SNORM": "", - "BC5_TYPELESS": "", - "BC5_UNORM": "", - "BC5_SNORM": "", - "B5G6R5_UNORM": "", - "B5G5R5A1_UNORM": "", - "B8G8R8A8_UNORM": "", - "B8G8R8X8_UNORM": "", - "R10G10B10_XR_BIAS_A2_UNORM": "", - "B8G8R8A8_TYPELESS": "", - "B8G8R8A8_UNORM_SRGB": "", - "B8G8R8X8_TYPELESS": "", - "B8G8R8X8_UNORM_SRGB": "", - "BC6H_TYPELESS": "", - "BC6H_UF16": "", - "BC6H_SF16": "", - "BC7_TYPELESS": "", - "BC7_UNORM": "", - "BC7_UNORM_SRGB": "", - "AYUV": "", - "Y410": "", - "Y416": "", - "NV12": "", - "P010": "", - "P016": "", - "420_OPAQUE": "", - "YUY2": "", - "Y210": "", - "Y216": "", - "NV11": "", - "AI44": "", - "IA44": "", - "P8": "", - "A8P8": "", - "B4G4R4A4_UNORM": "" -} diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_format_map_autogen.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_format_map_autogen.cpp deleted file mode 100644 index 66610cac9..000000000 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_format_map_autogen.cpp +++ /dev/null @@ -1,516 +0,0 @@ -// GENERATED FILE - DO NOT EDIT. -// Generated by gen_dxgi_format_table.py using data from dxgi_format_data.json. -// -// Copyright 2016 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. -// -// DXGI format info: -// Determining metadata about a DXGI format. - -#include "libANGLE/renderer/Format.h" - -using namespace angle; - -namespace rx -{ - -namespace d3d11 -{ - -GLenum GetComponentType(DXGI_FORMAT dxgiFormat) -{ - switch (dxgiFormat) - { - case DXGI_FORMAT_420_OPAQUE: - break; - case DXGI_FORMAT_A8P8: - break; - case DXGI_FORMAT_A8_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_AI44: - break; - case DXGI_FORMAT_AYUV: - break; - case DXGI_FORMAT_B4G4R4A4_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_B5G5R5A1_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_B5G6R5_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - break; - case DXGI_FORMAT_B8G8R8A8_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - break; - case DXGI_FORMAT_B8G8R8X8_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_BC1_TYPELESS: - break; - case DXGI_FORMAT_BC1_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_BC1_UNORM_SRGB: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_BC2_TYPELESS: - break; - case DXGI_FORMAT_BC2_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_BC2_UNORM_SRGB: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_BC3_TYPELESS: - break; - case DXGI_FORMAT_BC3_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_BC3_UNORM_SRGB: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_BC4_SNORM: - return GL_SIGNED_NORMALIZED; - case DXGI_FORMAT_BC4_TYPELESS: - break; - case DXGI_FORMAT_BC4_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_BC5_SNORM: - return GL_SIGNED_NORMALIZED; - case DXGI_FORMAT_BC5_TYPELESS: - break; - case DXGI_FORMAT_BC5_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_BC6H_SF16: - break; - case DXGI_FORMAT_BC6H_TYPELESS: - break; - case DXGI_FORMAT_BC6H_UF16: - break; - case DXGI_FORMAT_BC7_TYPELESS: - break; - case DXGI_FORMAT_BC7_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_BC7_UNORM_SRGB: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_D16_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_D24_UNORM_S8_UINT: - break; - case DXGI_FORMAT_D32_FLOAT: - return GL_FLOAT; - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - break; - case DXGI_FORMAT_G8R8_G8B8_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_IA44: - break; - case DXGI_FORMAT_NV11: - break; - case DXGI_FORMAT_NV12: - break; - case DXGI_FORMAT_P010: - break; - case DXGI_FORMAT_P016: - break; - case DXGI_FORMAT_P8: - break; - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - break; - case DXGI_FORMAT_R10G10B10A2_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_R10G10B10A2_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_R11G11B10_FLOAT: - return GL_FLOAT; - case DXGI_FORMAT_R16G16B16A16_FLOAT: - return GL_FLOAT; - case DXGI_FORMAT_R16G16B16A16_SINT: - return GL_INT; - case DXGI_FORMAT_R16G16B16A16_SNORM: - return GL_SIGNED_NORMALIZED; - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - break; - case DXGI_FORMAT_R16G16B16A16_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_R16G16B16A16_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_R16G16_FLOAT: - return GL_FLOAT; - case DXGI_FORMAT_R16G16_SINT: - return GL_INT; - case DXGI_FORMAT_R16G16_SNORM: - return GL_SIGNED_NORMALIZED; - case DXGI_FORMAT_R16G16_TYPELESS: - break; - case DXGI_FORMAT_R16G16_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_R16G16_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_R16_FLOAT: - return GL_FLOAT; - case DXGI_FORMAT_R16_SINT: - return GL_INT; - case DXGI_FORMAT_R16_SNORM: - return GL_SIGNED_NORMALIZED; - case DXGI_FORMAT_R16_TYPELESS: - break; - case DXGI_FORMAT_R16_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_R16_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_R1_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_R24G8_TYPELESS: - break; - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_R32G32B32A32_FLOAT: - return GL_FLOAT; - case DXGI_FORMAT_R32G32B32A32_SINT: - return GL_INT; - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - break; - case DXGI_FORMAT_R32G32B32A32_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_R32G32B32_FLOAT: - return GL_FLOAT; - case DXGI_FORMAT_R32G32B32_SINT: - return GL_INT; - case DXGI_FORMAT_R32G32B32_TYPELESS: - break; - case DXGI_FORMAT_R32G32B32_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_R32G32_FLOAT: - return GL_FLOAT; - case DXGI_FORMAT_R32G32_SINT: - return GL_INT; - case DXGI_FORMAT_R32G32_TYPELESS: - break; - case DXGI_FORMAT_R32G32_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_R32G8X24_TYPELESS: - break; - case DXGI_FORMAT_R32_FLOAT: - return GL_FLOAT; - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - return GL_FLOAT; - case DXGI_FORMAT_R32_SINT: - return GL_INT; - case DXGI_FORMAT_R32_TYPELESS: - break; - case DXGI_FORMAT_R32_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_R8G8B8A8_SINT: - return GL_INT; - case DXGI_FORMAT_R8G8B8A8_SNORM: - return GL_SIGNED_NORMALIZED; - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - break; - case DXGI_FORMAT_R8G8B8A8_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_R8G8B8A8_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_R8G8_B8G8_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_R8G8_SINT: - return GL_INT; - case DXGI_FORMAT_R8G8_SNORM: - return GL_SIGNED_NORMALIZED; - case DXGI_FORMAT_R8G8_TYPELESS: - break; - case DXGI_FORMAT_R8G8_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_R8G8_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_R8_SINT: - return GL_INT; - case DXGI_FORMAT_R8_SNORM: - return GL_SIGNED_NORMALIZED; - case DXGI_FORMAT_R8_TYPELESS: - break; - case DXGI_FORMAT_R8_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_R8_UNORM: - return GL_UNSIGNED_NORMALIZED; - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - return GL_FLOAT; - case DXGI_FORMAT_UNKNOWN: - break; - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - return GL_UNSIGNED_INT; - case DXGI_FORMAT_Y210: - break; - case DXGI_FORMAT_Y216: - break; - case DXGI_FORMAT_Y410: - break; - case DXGI_FORMAT_Y416: - break; - case DXGI_FORMAT_YUY2: - break; - default: - break; - } - - UNREACHABLE(); - return GL_NONE; -} - -} // namespace d3d11 - -namespace d3d11_angle -{ - -const Format &GetFormat(DXGI_FORMAT dxgiFormat) -{ - switch (dxgiFormat) - { - case DXGI_FORMAT_420_OPAQUE: - break; - case DXGI_FORMAT_A8P8: - break; - case DXGI_FORMAT_A8_UNORM: - return Format::Get(Format::ID::A8_UNORM); - case DXGI_FORMAT_AI44: - break; - case DXGI_FORMAT_AYUV: - break; - case DXGI_FORMAT_B4G4R4A4_UNORM: - return Format::Get(Format::ID::B4G4R4A4_UNORM); - case DXGI_FORMAT_B5G5R5A1_UNORM: - return Format::Get(Format::ID::B5G5R5A1_UNORM); - case DXGI_FORMAT_B5G6R5_UNORM: - return Format::Get(Format::ID::B5G6R5_UNORM); - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - break; - case DXGI_FORMAT_B8G8R8A8_UNORM: - return Format::Get(Format::ID::B8G8R8A8_UNORM); - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - break; - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - break; - case DXGI_FORMAT_B8G8R8X8_UNORM: - return Format::Get(Format::ID::B8G8R8X8_UNORM); - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - break; - case DXGI_FORMAT_BC1_TYPELESS: - break; - case DXGI_FORMAT_BC1_UNORM: - return Format::Get(Format::ID::BC1_RGBA_UNORM_BLOCK); - case DXGI_FORMAT_BC1_UNORM_SRGB: - break; - case DXGI_FORMAT_BC2_TYPELESS: - break; - case DXGI_FORMAT_BC2_UNORM: - return Format::Get(Format::ID::BC2_RGBA_UNORM_BLOCK); - case DXGI_FORMAT_BC2_UNORM_SRGB: - break; - case DXGI_FORMAT_BC3_TYPELESS: - break; - case DXGI_FORMAT_BC3_UNORM: - return Format::Get(Format::ID::BC3_RGBA_UNORM_BLOCK); - case DXGI_FORMAT_BC3_UNORM_SRGB: - break; - case DXGI_FORMAT_BC4_SNORM: - break; - case DXGI_FORMAT_BC4_TYPELESS: - break; - case DXGI_FORMAT_BC4_UNORM: - break; - case DXGI_FORMAT_BC5_SNORM: - break; - case DXGI_FORMAT_BC5_TYPELESS: - break; - case DXGI_FORMAT_BC5_UNORM: - break; - case DXGI_FORMAT_BC6H_SF16: - break; - case DXGI_FORMAT_BC6H_TYPELESS: - break; - case DXGI_FORMAT_BC6H_UF16: - break; - case DXGI_FORMAT_BC7_TYPELESS: - break; - case DXGI_FORMAT_BC7_UNORM: - break; - case DXGI_FORMAT_BC7_UNORM_SRGB: - break; - case DXGI_FORMAT_D16_UNORM: - return Format::Get(Format::ID::D16_UNORM); - case DXGI_FORMAT_D24_UNORM_S8_UINT: - return Format::Get(Format::ID::D24_UNORM_S8_UINT); - case DXGI_FORMAT_D32_FLOAT: - return Format::Get(Format::ID::D32_FLOAT); - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - return Format::Get(Format::ID::D32_FLOAT_S8X24_UINT); - case DXGI_FORMAT_G8R8_G8B8_UNORM: - break; - case DXGI_FORMAT_IA44: - break; - case DXGI_FORMAT_NV11: - break; - case DXGI_FORMAT_NV12: - break; - case DXGI_FORMAT_P010: - break; - case DXGI_FORMAT_P016: - break; - case DXGI_FORMAT_P8: - break; - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - break; - case DXGI_FORMAT_R10G10B10A2_UINT: - return Format::Get(Format::ID::R10G10B10A2_UINT); - case DXGI_FORMAT_R10G10B10A2_UNORM: - return Format::Get(Format::ID::R10G10B10A2_UNORM); - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - break; - case DXGI_FORMAT_R11G11B10_FLOAT: - return Format::Get(Format::ID::R11G11B10_FLOAT); - case DXGI_FORMAT_R16G16B16A16_FLOAT: - return Format::Get(Format::ID::R16G16B16A16_FLOAT); - case DXGI_FORMAT_R16G16B16A16_SINT: - return Format::Get(Format::ID::R16G16B16A16_SINT); - case DXGI_FORMAT_R16G16B16A16_SNORM: - return Format::Get(Format::ID::R16G16B16A16_SNORM); - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - break; - case DXGI_FORMAT_R16G16B16A16_UINT: - return Format::Get(Format::ID::R16G16B16A16_UINT); - case DXGI_FORMAT_R16G16B16A16_UNORM: - return Format::Get(Format::ID::R16G16B16A16_UNORM); - case DXGI_FORMAT_R16G16_FLOAT: - return Format::Get(Format::ID::R16G16_FLOAT); - case DXGI_FORMAT_R16G16_SINT: - return Format::Get(Format::ID::R16G16_SINT); - case DXGI_FORMAT_R16G16_SNORM: - return Format::Get(Format::ID::R16G16_SNORM); - case DXGI_FORMAT_R16G16_TYPELESS: - break; - case DXGI_FORMAT_R16G16_UINT: - return Format::Get(Format::ID::R16G16_UINT); - case DXGI_FORMAT_R16G16_UNORM: - return Format::Get(Format::ID::R16G16_UNORM); - case DXGI_FORMAT_R16_FLOAT: - return Format::Get(Format::ID::R16_FLOAT); - case DXGI_FORMAT_R16_SINT: - return Format::Get(Format::ID::R16_SINT); - case DXGI_FORMAT_R16_SNORM: - return Format::Get(Format::ID::R16_SNORM); - case DXGI_FORMAT_R16_TYPELESS: - break; - case DXGI_FORMAT_R16_UINT: - return Format::Get(Format::ID::R16_UINT); - case DXGI_FORMAT_R16_UNORM: - return Format::Get(Format::ID::R16_UNORM); - case DXGI_FORMAT_R1_UNORM: - break; - case DXGI_FORMAT_R24G8_TYPELESS: - break; - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - break; - case DXGI_FORMAT_R32G32B32A32_FLOAT: - return Format::Get(Format::ID::R32G32B32A32_FLOAT); - case DXGI_FORMAT_R32G32B32A32_SINT: - return Format::Get(Format::ID::R32G32B32A32_SINT); - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - break; - case DXGI_FORMAT_R32G32B32A32_UINT: - return Format::Get(Format::ID::R32G32B32A32_UINT); - case DXGI_FORMAT_R32G32B32_FLOAT: - return Format::Get(Format::ID::R32G32B32_FLOAT); - case DXGI_FORMAT_R32G32B32_SINT: - return Format::Get(Format::ID::R32G32B32_SINT); - case DXGI_FORMAT_R32G32B32_TYPELESS: - break; - case DXGI_FORMAT_R32G32B32_UINT: - return Format::Get(Format::ID::R32G32B32_UINT); - case DXGI_FORMAT_R32G32_FLOAT: - return Format::Get(Format::ID::R32G32_FLOAT); - case DXGI_FORMAT_R32G32_SINT: - return Format::Get(Format::ID::R32G32_SINT); - case DXGI_FORMAT_R32G32_TYPELESS: - break; - case DXGI_FORMAT_R32G32_UINT: - return Format::Get(Format::ID::R32G32_UINT); - case DXGI_FORMAT_R32G8X24_TYPELESS: - break; - case DXGI_FORMAT_R32_FLOAT: - return Format::Get(Format::ID::R32_FLOAT); - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - break; - case DXGI_FORMAT_R32_SINT: - return Format::Get(Format::ID::R32_SINT); - case DXGI_FORMAT_R32_TYPELESS: - break; - case DXGI_FORMAT_R32_UINT: - return Format::Get(Format::ID::R32_UINT); - case DXGI_FORMAT_R8G8B8A8_SINT: - return Format::Get(Format::ID::R8G8B8A8_SINT); - case DXGI_FORMAT_R8G8B8A8_SNORM: - return Format::Get(Format::ID::R8G8B8A8_SNORM); - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - break; - case DXGI_FORMAT_R8G8B8A8_UINT: - return Format::Get(Format::ID::R8G8B8A8_UINT); - case DXGI_FORMAT_R8G8B8A8_UNORM: - return Format::Get(Format::ID::R8G8B8A8_UNORM); - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - return Format::Get(Format::ID::R8G8B8A8_UNORM_SRGB); - case DXGI_FORMAT_R8G8_B8G8_UNORM: - break; - case DXGI_FORMAT_R8G8_SINT: - return Format::Get(Format::ID::R8G8_SINT); - case DXGI_FORMAT_R8G8_SNORM: - return Format::Get(Format::ID::R8G8_SNORM); - case DXGI_FORMAT_R8G8_TYPELESS: - break; - case DXGI_FORMAT_R8G8_UINT: - return Format::Get(Format::ID::R8G8_UINT); - case DXGI_FORMAT_R8G8_UNORM: - return Format::Get(Format::ID::R8G8_UNORM); - case DXGI_FORMAT_R8_SINT: - return Format::Get(Format::ID::R8_SINT); - case DXGI_FORMAT_R8_SNORM: - return Format::Get(Format::ID::R8_SNORM); - case DXGI_FORMAT_R8_TYPELESS: - break; - case DXGI_FORMAT_R8_UINT: - return Format::Get(Format::ID::R8_UINT); - case DXGI_FORMAT_R8_UNORM: - return Format::Get(Format::ID::R8_UNORM); - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - return Format::Get(Format::ID::R9G9B9E5_SHAREDEXP); - case DXGI_FORMAT_UNKNOWN: - return Format::Get(Format::ID::NONE); - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - break; - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - break; - case DXGI_FORMAT_Y210: - break; - case DXGI_FORMAT_Y216: - break; - case DXGI_FORMAT_Y410: - break; - case DXGI_FORMAT_Y416: - break; - case DXGI_FORMAT_YUY2: - break; - default: - break; - } - - UNREACHABLE(); - return Format::Get(Format::ID::NONE); -} - -} // namespace d3d11_angle - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json index dce0997d9..e81b4deea 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json @@ -8,8 +8,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32G32B32A32_TYPELESS": { @@ -19,8 +18,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32G32B32A32_FLOAT": { @@ -30,30 +28,27 @@ "shaderSample": "10_0check10_1always", "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "always" + "depthStencil": "never" }, "DXGI_FORMAT_R32G32B32A32_UINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32G32B32A32_SINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32G32B32_TYPELESS": { @@ -63,8 +58,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32G32B32_FLOAT": { @@ -74,8 +68,7 @@ "shaderSample": "11_0check", "renderTarget": "check", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32G32B32_UINT": { @@ -85,8 +78,7 @@ "shaderSample": "never", "renderTarget": "check", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32G32B32_SINT": { @@ -96,8 +88,7 @@ "shaderSample": "never", "renderTarget": "check", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R16G16B16A16_TYPELESS": { @@ -107,63 +98,57 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R16G16B16A16_FLOAT": { "texture2D": "always", "texture3D": "always", "textureCube": "always", - "shaderSample": "9_3check_10_0always", + "shaderSample": "10_0", "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "always" + "depthStencil": "never" }, "DXGI_FORMAT_R16G16B16A16_UNORM": { "texture2D": "always", "texture3D": "always", "textureCube": "always", - "shaderSample": "always", + "shaderSample": "10_0", "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "always" + "depthStencil": "never" }, "DXGI_FORMAT_R16G16B16A16_UINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R16G16B16A16_SNORM": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "10_0", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R16G16B16A16_SINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32G32_TYPELESS": { @@ -173,8 +158,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32G32_FLOAT": { @@ -184,41 +168,37 @@ "shaderSample": "10_0check10_1always", "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R32G32_UINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32G32_SINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32G8X24_TYPELESS": { - "texture2D": "10_0", + "texture2D": "always", "texture3D": "never", - "textureCube": "10_0", + "textureCube": "always", "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_D32_FLOAT_S8X24_UINT": { @@ -228,8 +208,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "check", - "depthStencil": "10_0", - "mipAutoGen": "never" + "depthStencil": "always" }, "DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS": { @@ -239,8 +218,7 @@ "shaderSample": "10_0check10_1always", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_X32_TYPELESS_G8X24_UINT": { @@ -250,52 +228,47 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R10G10B10A2_TYPELESS": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R10G10B10A2_UNORM": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "10_0", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R10G10B10A2_UINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R11G11B10_FLOAT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "10_0", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R8G8B8A8_TYPELESS": { @@ -305,63 +278,57 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R8G8B8A8_UNORM": { "texture2D": "always", "texture3D": "always", "textureCube": "always", - "shaderSample": "always", + "shaderSample": "10_0", "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "always" + "depthStencil": "never" }, "DXGI_FORMAT_R8G8B8A8_UNORM_SRGB": { "texture2D": "always", "texture3D": "always", "textureCube": "always", - "shaderSample": "always", + "shaderSample": "10_0", "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "always" + "depthStencil": "never" }, "DXGI_FORMAT_R8G8B8A8_UINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R8G8B8A8_SNORM": { "texture2D": "always", "texture3D": "always", "textureCube": "always", - "shaderSample": "always", + "shaderSample": "10_0", "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R8G8B8A8_SINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R16G16_TYPELESS": { @@ -371,8 +338,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R16G16_FLOAT": { @@ -382,63 +348,57 @@ "shaderSample": "10_0", "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "always" + "depthStencil": "never" }, "DXGI_FORMAT_R16G16_UNORM": { "texture2D": "always", "texture3D": "always", "textureCube": "always", - "shaderSample": "always", + "shaderSample": "10_0", "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "always" + "depthStencil": "never" }, "DXGI_FORMAT_R16G16_UINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R16G16_SNORM": { "texture2D": "always", "texture3D": "always", "textureCube": "always", - "shaderSample": "always", + "shaderSample": "10_0", "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R16G16_SINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32_TYPELESS": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_D32_FLOAT": { @@ -448,8 +408,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "check", - "depthStencil": "10_0", - "mipAutoGen": "never" + "depthStencil": "always" }, "DXGI_FORMAT_R32_FLOAT": { @@ -459,30 +418,27 @@ "shaderSample": "10_0check10_1always", "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "always" + "depthStencil": "never" }, "DXGI_FORMAT_R32_UINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R32_SINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R24G8_TYPELESS": { @@ -492,8 +448,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_D24_UNORM_S8_UINT": { @@ -513,8 +468,7 @@ "shaderSample": "10_0check10_1always", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_X24_TYPELESS_G8_UINT": { @@ -524,8 +478,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R8G8_TYPELESS": { @@ -535,52 +488,47 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R8G8_UNORM": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", - "shaderSample": "9_3check_10_0always", - "renderTarget": "9_3check_10_0always", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", + "shaderSample": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R8G8_UINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R8G8_SNORM": { "texture2D": "always", - "texture3D": "10_0", - "textureCube": "10_0", - "shaderSample": "always", - "renderTarget": "10_0", + "texture3D": "always", + "textureCube": "always", + "shaderSample": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R8G8_SINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R16_TYPELESS": { @@ -590,19 +538,17 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R16_FLOAT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "10_0", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_D16_UNORM": { @@ -612,52 +558,47 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "check", - "depthStencil": "always", - "mipAutoGen": "never" + "depthStencil": "always" }, "DXGI_FORMAT_R16_UNORM": { "texture2D": "always", "texture3D": "always", "textureCube": "always", - "shaderSample": "always", - "renderTarget": "10_0", + "shaderSample": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R16_UINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R16_SNORM": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "10_0", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R16_SINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R8_TYPELESS": { @@ -667,52 +608,47 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R8_UNORM": { "texture2D": "always", "texture3D": "always", "textureCube": "always", - "shaderSample": "always", - "renderTarget": "9_3check_10_0always", + "shaderSample": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R8_UINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R8_SNORM": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "10_0", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R8_SINT": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "never", - "renderTarget": "10_0", + "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_A8_UNORM": { @@ -722,8 +658,7 @@ "shaderSample": "10_0", "renderTarget": "always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "10_0" + "depthStencil": "never" }, "DXGI_FORMAT_R1_UNORM": { @@ -733,19 +668,17 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R9G9B9E5_SHAREDEXP": { - "texture2D": "10_0", - "texture3D": "10_0", - "textureCube": "10_0", + "texture2D": "always", + "texture3D": "always", + "textureCube": "always", "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R8G8_B8G8_UNORM": { @@ -755,8 +688,7 @@ "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_G8R8_G8B8_UNORM": { @@ -766,8 +698,7 @@ "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC1_TYPELESS": { @@ -777,19 +708,17 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC1_UNORM": { "texture2D": "always", "texture3D": "always", "textureCube": "always", - "shaderSample": "always", + "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC1_UNORM_SRGB": { @@ -799,8 +728,7 @@ "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC2_TYPELESS": { @@ -810,19 +738,17 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC2_UNORM": { "texture2D": "always", "texture3D": "always", "textureCube": "always", - "shaderSample": "always", + "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC2_UNORM_SRGB": { @@ -832,8 +758,7 @@ "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC3_TYPELESS": { @@ -843,19 +768,17 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC3_UNORM": { "texture2D": "always", "texture3D": "always", "textureCube": "always", - "shaderSample": "always", + "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC3_UNORM_SRGB": { @@ -865,8 +788,7 @@ "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC4_TYPELESS": { @@ -876,8 +798,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC4_UNORM": { @@ -887,8 +808,7 @@ "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC4_SNORM": { @@ -898,8 +818,7 @@ "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC5_TYPELESS": { @@ -909,8 +828,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC5_UNORM": { @@ -920,8 +838,7 @@ "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC5_SNORM": { @@ -931,8 +848,7 @@ "shaderSample": "10_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_B5G6R5_UNORM": { @@ -942,8 +858,7 @@ "shaderSample": "dxgi1_2", "renderTarget": "dxgi1_2", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "dxgi1_2" + "depthStencil": "never" }, "DXGI_FORMAT_B5G5R5A1_UNORM": { @@ -953,19 +868,17 @@ "shaderSample": "dxgi1_2", "renderTarget": "check", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "dxgi1_2" + "depthStencil": "never" }, "DXGI_FORMAT_B8G8R8A8_UNORM": { "texture2D": "check", "texture3D": "check", "textureCube": "check", - "shaderSample": "9_3always_10_0check11_0always", - "renderTarget": "9_3always_10_0check11_0always", + "shaderSample": "10_0check11_0always", + "renderTarget": "10_0check11_0always", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "always" + "depthStencil": "never" }, "DXGI_FORMAT_B8G8R8X8_UNORM": { @@ -975,8 +888,7 @@ "shaderSample": "10_0check11_0always", "renderTarget": "11_0", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM": { @@ -986,8 +898,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_B8G8R8A8_TYPELESS": { @@ -997,8 +908,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_B8G8R8A8_UNORM_SRGB": { @@ -1008,8 +918,7 @@ "shaderSample": "10_0check11_0always", "renderTarget": "11_0", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_B8G8R8X8_TYPELESS": { @@ -1019,8 +928,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_B8G8R8X8_UNORM_SRGB": { @@ -1030,8 +938,7 @@ "shaderSample": "10_0check11_0always", "renderTarget": "11_0", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC6H_TYPELESS": { @@ -1041,8 +948,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC6H_UF16": { @@ -1052,8 +958,7 @@ "shaderSample": "11_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC6H_SF16": { @@ -1063,8 +968,7 @@ "shaderSample": "11_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC7_TYPELESS": { @@ -1074,8 +978,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC7_UNORM": { @@ -1085,8 +988,7 @@ "shaderSample": "11_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_BC7_UNORM_SRGB": { @@ -1096,8 +998,7 @@ "shaderSample": "11_0", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_AYUV": { @@ -1107,8 +1008,7 @@ "shaderSample": "11_1", "renderTarget": "11_1", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_Y410": { @@ -1118,8 +1018,7 @@ "shaderSample": "11_1", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_Y416": { @@ -1129,8 +1028,7 @@ "shaderSample": "11_1", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_NV12": { @@ -1140,8 +1038,7 @@ "shaderSample": "11_1", "renderTarget": "11_1", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_P010": { @@ -1151,8 +1048,7 @@ "shaderSample": "11_1", "renderTarget": "11_1", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_P016": { @@ -1162,8 +1058,7 @@ "shaderSample": "11_1", "renderTarget": "11_1", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_420_OPAQUE": { @@ -1173,8 +1068,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_YUY2": { @@ -1184,8 +1078,7 @@ "shaderSample": "11_1", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_Y210": { @@ -1195,8 +1088,7 @@ "shaderSample": "11_1", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_Y216": { @@ -1206,8 +1098,7 @@ "shaderSample": "11_1", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_NV11": { @@ -1217,8 +1108,7 @@ "shaderSample": "11_1", "renderTarget": "11_1", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_AI44": { @@ -1228,8 +1118,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_IA44": { @@ -1239,8 +1128,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_P8": { @@ -1250,8 +1138,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_A8P8": { @@ -1261,8 +1148,7 @@ "shaderSample": "never", "renderTarget": "never", "multisampleRT": "never", - "depthStencil": "never", - "mipAutoGen": "never" + "depthStencil": "never" }, "DXGI_FORMAT_B4G4R4A4_UNORM": { @@ -1272,8 +1158,7 @@ "shaderSample": "dxgi1_2", "renderTarget": "check", "multisampleRT": "check", - "depthStencil": "never", - "mipAutoGen": "dxgi1_2" + "depthStencil": "never" } } ] diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_support_table.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_support_table.cpp index d202ce130..cbc36445e 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_support_table.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/dxgi_support_table.cpp @@ -26,205 +26,205 @@ namespace d3d11 #define F_RT D3D11_FORMAT_SUPPORT_RENDER_TARGET #define F_MS D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET #define F_DS D3D11_FORMAT_SUPPORT_DEPTH_STENCIL -#define F_MIPGEN D3D11_FORMAT_SUPPORT_MIP_AUTOGEN namespace { const DXGISupport &GetDefaultSupport() { - static UINT AllSupportFlags = - D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_TEXTURE3D | - D3D11_FORMAT_SUPPORT_TEXTURECUBE | D3D11_FORMAT_SUPPORT_SHADER_SAMPLE | - D3D11_FORMAT_SUPPORT_RENDER_TARGET | D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET | - D3D11_FORMAT_SUPPORT_DEPTH_STENCIL | D3D11_FORMAT_SUPPORT_MIP_AUTOGEN; + static UINT AllSupportFlags = D3D11_FORMAT_SUPPORT_TEXTURE2D | + D3D11_FORMAT_SUPPORT_TEXTURE3D | + D3D11_FORMAT_SUPPORT_TEXTURECUBE | + D3D11_FORMAT_SUPPORT_SHADER_SAMPLE | + D3D11_FORMAT_SUPPORT_RENDER_TARGET | + D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET | + D3D11_FORMAT_SUPPORT_DEPTH_STENCIL; static const DXGISupport defaultSupport(0, 0, AllSupportFlags); return defaultSupport; } -const DXGISupport &GetDXGISupport_9_3(DXGI_FORMAT dxgiFormat) +const DXGISupport &GetDXGISupport_10_0(DXGI_FORMAT dxgiFormat) { - // clang-format off switch (dxgiFormat) { case DXGI_FORMAT_420_OPAQUE: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_A8P8: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_A8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_AI44: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_AYUV: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_B4G4R4A4_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_SAMPLE, F_DS, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS, F_MS | F_RT); return info; } case DXGI_FORMAT_B5G5R5A1_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_SAMPLE, F_DS, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS, F_MS | F_RT); return info; } case DXGI_FORMAT_B5G6R5_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_B8G8R8A8_TYPELESS: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); + static const DXGISupport info(0, F_DS | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); return info; } case DXGI_FORMAT_B8G8R8A8_UNORM: { - static const DXGISupport info(F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_2D | F_3D | F_CUBE | F_MS); + static const DXGISupport info(0, F_DS, F_2D | F_3D | F_CUBE | F_MS | F_RT | F_SAMPLE); return info; } case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: { - static const DXGISupport info(0, F_DS | F_MIPGEN, F_2D | F_3D | F_CUBE | F_MS); + static const DXGISupport info(0, F_DS, F_2D | F_3D | F_CUBE | F_MS | F_SAMPLE); return info; } case DXGI_FORMAT_B8G8R8X8_TYPELESS: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); + static const DXGISupport info(0, F_DS | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); return info; } case DXGI_FORMAT_B8G8R8X8_UNORM: { - static const DXGISupport info(0, F_DS | F_MIPGEN, F_2D | F_3D | F_CUBE | F_MS); + static const DXGISupport info(0, F_DS, F_2D | F_3D | F_CUBE | F_MS | F_SAMPLE); return info; } case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: { - static const DXGISupport info(0, F_DS | F_MIPGEN, F_2D | F_3D | F_CUBE | F_MS); + static const DXGISupport info(0, F_DS, F_2D | F_3D | F_CUBE | F_MS | F_SAMPLE); return info; } case DXGI_FORMAT_BC1_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC1_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC1_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC2_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC2_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC2_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC3_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC3_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC3_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC4_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC4_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC4_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC5_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC5_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC5_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC6H_SF16: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(0, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC6H_TYPELESS: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC6H_UF16: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(0, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC7_TYPELESS: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC7_UNORM: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(0, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC7_UNORM_SRGB: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(0, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_D16_UNORM: { - static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_D24_UNORM_S8_UINT: @@ -234,112 +234,112 @@ const DXGISupport &GetDXGISupport_9_3(DXGI_FORMAT dxgiFormat) } case DXGI_FORMAT_D32_FLOAT: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_G8R8_G8B8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_IA44: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_NV11: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_NV12: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_P010: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_P016: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_P8: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R10G10B10A2_TYPELESS: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R10G10B10A2_UINT: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R10G10B10A2_UNORM: { - static const DXGISupport info(0, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: { - static const DXGISupport info(0, F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, F_2D | F_3D); + static const DXGISupport info(0, F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, F_2D | F_3D); return info; } case DXGI_FORMAT_R11G11B10_FLOAT: { - static const DXGISupport info(0, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT, F_DS, F_MS | F_SAMPLE); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_SINT: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_SNORM: { - static const DXGISupport info(0, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R16G16B16A16_UINT: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16_SINT: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16G16_SNORM: @@ -349,875 +349,282 @@ const DXGISupport &GetDXGISupport_9_3(DXGI_FORMAT dxgiFormat) } case DXGI_FORMAT_R16G16_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R16G16_UINT: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16G16_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R16_FLOAT: - { - static const DXGISupport info(0, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R16_SINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R16_SNORM: - { - static const DXGISupport info(0, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R16_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R16_UINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R16_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R1_UNORM: - { - static const DXGISupport info(F_2D, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R24G8_TYPELESS: - { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_R32G32B32A32_FLOAT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R32G32B32A32_SINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R32G32B32A32_UINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R32G32B32_FLOAT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN, F_MS | F_RT); - return info; - } - case DXGI_FORMAT_R32G32B32_SINT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_SAMPLE, F_MS | F_RT); - return info; - } - case DXGI_FORMAT_R32G32B32_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R32G32B32_UINT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_SAMPLE, F_MS | F_RT); - return info; - } - case DXGI_FORMAT_R32G32_FLOAT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R32G32_SINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R32G32_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R32G32_UINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R32G8X24_TYPELESS: - { - static const DXGISupport info(0, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R32_FLOAT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_R32_SINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R32_TYPELESS: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R32_UINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R8G8B8A8_SINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R8G8B8A8_SNORM: - { static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R8G8B8A8_UINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R8G8B8A8_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R8G8_B8G8_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_R8G8_SINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R8G8_SNORM: - { - static const DXGISupport info(F_2D | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R8G8_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R8G8_UINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R8G8_UNORM: - { - static const DXGISupport info(0, F_DS, F_MS | F_RT | F_SAMPLE); - return info; - } - case DXGI_FORMAT_R8_SINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R8_SNORM: - { - static const DXGISupport info(0, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R8_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R8_UINT: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R8_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS, F_MS | F_RT); - return info; - } - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_UNKNOWN: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_Y210: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_Y216: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_Y410: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_Y416: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_YUY2: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - - default: - UNREACHABLE(); - return GetDefaultSupport(); - } - // clang-format on -} - -const DXGISupport &GetDXGISupport_10_0(DXGI_FORMAT dxgiFormat) -{ - // clang-format off - switch (dxgiFormat) - { - case DXGI_FORMAT_420_OPAQUE: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_A8P8: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_A8_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_AI44: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_AYUV: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_B4G4R4A4_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_SAMPLE, F_DS, F_MS | F_RT); - return info; - } - case DXGI_FORMAT_B5G5R5A1_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_SAMPLE, F_DS, F_MS | F_RT); - return info; - } - case DXGI_FORMAT_B5G6R5_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); - return info; - } - case DXGI_FORMAT_B8G8R8A8_UNORM: - { - static const DXGISupport info(F_MIPGEN, F_DS, F_2D | F_3D | F_CUBE | F_MS | F_RT | F_SAMPLE); - return info; - } - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - { - static const DXGISupport info(0, F_DS | F_MIPGEN, F_2D | F_3D | F_CUBE | F_MS | F_SAMPLE); - return info; - } - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); - return info; - } - case DXGI_FORMAT_B8G8R8X8_UNORM: - { - static const DXGISupport info(0, F_DS | F_MIPGEN, F_2D | F_3D | F_CUBE | F_MS | F_SAMPLE); - return info; - } - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - { - static const DXGISupport info(0, F_DS | F_MIPGEN, F_2D | F_3D | F_CUBE | F_MS | F_SAMPLE); - return info; - } - case DXGI_FORMAT_BC1_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_BC1_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC1_UNORM_SRGB: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC2_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_BC2_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC2_UNORM_SRGB: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC3_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_BC3_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC3_UNORM_SRGB: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC4_SNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC4_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_BC4_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC5_SNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC5_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_BC5_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC6H_SF16: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC6H_TYPELESS: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_BC6H_UF16: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC7_TYPELESS: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_BC7_UNORM: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_BC7_UNORM_SRGB: - { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_D16_UNORM: - { - static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_MIPGEN | F_RT | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_D24_UNORM_S8_UINT: - { - static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_RT | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_D32_FLOAT: - { - static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_MIPGEN | F_RT | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - { - static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_MIPGEN | F_RT | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_G8R8_G8B8_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); - return info; - } - case DXGI_FORMAT_IA44: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_NV11: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_NV12: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_P010: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_P016: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_P8: - { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R10G10B10A2_UINT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R10G10B10A2_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - { - static const DXGISupport info(0, F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, F_2D | F_3D); - return info; - } - case DXGI_FORMAT_R11G11B10_FLOAT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R16G16B16A16_FLOAT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R16G16B16A16_SINT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R16G16B16A16_SNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R16G16B16A16_UINT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R16G16B16A16_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R16G16_FLOAT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R16G16_SINT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R16G16_SNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } - case DXGI_FORMAT_R16G16_TYPELESS: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); - return info; - } - case DXGI_FORMAT_R16G16_UINT: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); - return info; - } - case DXGI_FORMAT_R16G16_UNORM: - { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); - return info; - } case DXGI_FORMAT_R16_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R16_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R1_UNORM: { - static const DXGISupport info(F_2D, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R24G8_TYPELESS: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT, F_SAMPLE); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT, F_SAMPLE); return info; } case DXGI_FORMAT_R32G32B32A32_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT, F_DS, F_MS | F_SAMPLE); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS, F_MS | F_SAMPLE); return info; } case DXGI_FORMAT_R32G32B32A32_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32G32B32A32_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32G32B32A32_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32G32B32_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS, F_MS | F_RT); return info; } case DXGI_FORMAT_R32G32B32_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_SAMPLE, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_SAMPLE, F_MS | F_RT); return info; } case DXGI_FORMAT_R32G32B32_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32G32B32_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_SAMPLE, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_SAMPLE, F_MS | F_RT); return info; } case DXGI_FORMAT_R32G32_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT, F_DS, F_MS | F_SAMPLE); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS, F_MS | F_SAMPLE); return info; } case DXGI_FORMAT_R32G32_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32G32_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32G32_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32G8X24_TYPELESS: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT, F_DS, F_MS | F_SAMPLE); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS, F_MS | F_SAMPLE); return info; } case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT, F_SAMPLE); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT, F_SAMPLE); return info; } case DXGI_FORMAT_R32_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R8G8B8A8_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8G8_B8G8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_R8G8_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8G8_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R8G8_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R8_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_UNKNOWN: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_X24_TYPELESS_G8_UINT: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_Y210: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_Y216: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_Y410: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_Y416: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_YUY2: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } @@ -1225,192 +632,190 @@ const DXGISupport &GetDXGISupport_10_0(DXGI_FORMAT dxgiFormat) UNREACHABLE(); return GetDefaultSupport(); } - // clang-format on } const DXGISupport &GetDXGISupport_10_1(DXGI_FORMAT dxgiFormat) { - // clang-format off switch (dxgiFormat) { case DXGI_FORMAT_420_OPAQUE: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_A8P8: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_A8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_AI44: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_AYUV: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_B4G4R4A4_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_SAMPLE, F_DS, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS, F_MS | F_RT); return info; } case DXGI_FORMAT_B5G5R5A1_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_SAMPLE, F_DS, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS, F_MS | F_RT); return info; } case DXGI_FORMAT_B5G6R5_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_B8G8R8A8_TYPELESS: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); + static const DXGISupport info(0, F_DS | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); return info; } case DXGI_FORMAT_B8G8R8A8_UNORM: { - static const DXGISupport info(F_MIPGEN, F_DS, F_2D | F_3D | F_CUBE | F_MS | F_RT | F_SAMPLE); + static const DXGISupport info(0, F_DS, F_2D | F_3D | F_CUBE | F_MS | F_RT | F_SAMPLE); return info; } case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: { - static const DXGISupport info(0, F_DS | F_MIPGEN, F_2D | F_3D | F_CUBE | F_MS | F_SAMPLE); + static const DXGISupport info(0, F_DS, F_2D | F_3D | F_CUBE | F_MS | F_SAMPLE); return info; } case DXGI_FORMAT_B8G8R8X8_TYPELESS: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); + static const DXGISupport info(0, F_DS | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); return info; } case DXGI_FORMAT_B8G8R8X8_UNORM: { - static const DXGISupport info(0, F_DS | F_MIPGEN, F_2D | F_3D | F_CUBE | F_MS | F_SAMPLE); + static const DXGISupport info(0, F_DS, F_2D | F_3D | F_CUBE | F_MS | F_SAMPLE); return info; } case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: { - static const DXGISupport info(0, F_DS | F_MIPGEN, F_2D | F_3D | F_CUBE | F_MS | F_SAMPLE); + static const DXGISupport info(0, F_DS, F_2D | F_3D | F_CUBE | F_MS | F_SAMPLE); return info; } case DXGI_FORMAT_BC1_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC1_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC1_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC2_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC2_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC2_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC3_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC3_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC3_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC4_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC4_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC4_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC5_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC5_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC5_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC6H_SF16: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(0, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC6H_TYPELESS: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC6H_UF16: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(0, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC7_TYPELESS: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC7_UNORM: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(0, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC7_UNORM_SRGB: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(0, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_D16_UNORM: { - static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_D24_UNORM_S8_UINT: @@ -1420,397 +825,397 @@ const DXGISupport &GetDXGISupport_10_1(DXGI_FORMAT dxgiFormat) } case DXGI_FORMAT_D32_FLOAT: { - static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: { - static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_G8R8_G8B8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_IA44: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_NV11: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_NV12: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_P010: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_P016: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_P8: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R10G10B10A2_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R10G10B10A2_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R10G10B10A2_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: { - static const DXGISupport info(0, F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, F_2D | F_3D); + static const DXGISupport info(0, F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, F_2D | F_3D); return info; } case DXGI_FORMAT_R11G11B10_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R16G16B16A16_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16G16_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R16G16_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16G16_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R16_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R1_UNORM: { - static const DXGISupport info(F_2D, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R24G8_TYPELESS: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: { - static const DXGISupport info(F_2D | F_CUBE | F_SAMPLE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_CUBE | F_SAMPLE, F_3D | F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_R32G32B32A32_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R32G32B32A32_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32G32B32A32_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32G32B32A32_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32G32B32_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS, F_MS | F_RT); return info; } case DXGI_FORMAT_R32G32B32_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_SAMPLE, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_SAMPLE, F_MS | F_RT); return info; } case DXGI_FORMAT_R32G32B32_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32G32B32_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_SAMPLE, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_SAMPLE, F_MS | F_RT); return info; } case DXGI_FORMAT_R32G32_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R32G32_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32G32_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32G32_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32G8X24_TYPELESS: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: { - static const DXGISupport info(F_2D | F_CUBE | F_SAMPLE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_CUBE | F_SAMPLE, F_3D | F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_R32_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R8G8B8A8_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8G8_B8G8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_R8G8_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8G8_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R8G8_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R8_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_UNKNOWN: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_X24_TYPELESS_G8_UINT: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_Y210: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_Y216: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_Y410: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_Y416: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_YUY2: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } @@ -1818,192 +1223,190 @@ const DXGISupport &GetDXGISupport_10_1(DXGI_FORMAT dxgiFormat) UNREACHABLE(); return GetDefaultSupport(); } - // clang-format on } const DXGISupport &GetDXGISupport_11_0(DXGI_FORMAT dxgiFormat) { - // clang-format off switch (dxgiFormat) { case DXGI_FORMAT_420_OPAQUE: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_A8P8: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_A8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_AI44: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_AYUV: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_B4G4R4A4_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_SAMPLE, F_DS, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS, F_MS | F_RT); return info; } case DXGI_FORMAT_B5G5R5A1_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_SAMPLE, F_DS, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS, F_MS | F_RT); return info; } case DXGI_FORMAT_B5G6R5_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_B8G8R8A8_TYPELESS: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); + static const DXGISupport info(0, F_DS | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); return info; } case DXGI_FORMAT_B8G8R8A8_UNORM: { - static const DXGISupport info(F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_2D | F_3D | F_CUBE | F_MS); + static const DXGISupport info(F_RT | F_SAMPLE, F_DS, F_2D | F_3D | F_CUBE | F_MS); return info; } case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: { - static const DXGISupport info(F_RT | F_SAMPLE, F_DS | F_MIPGEN, F_2D | F_3D | F_CUBE | F_MS); + static const DXGISupport info(F_RT | F_SAMPLE, F_DS, F_2D | F_3D | F_CUBE | F_MS); return info; } case DXGI_FORMAT_B8G8R8X8_TYPELESS: { - static const DXGISupport info(0, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); + static const DXGISupport info(0, F_DS | F_MS | F_RT | F_SAMPLE, F_2D | F_3D | F_CUBE); return info; } case DXGI_FORMAT_B8G8R8X8_UNORM: { - static const DXGISupport info(F_RT | F_SAMPLE, F_DS | F_MIPGEN, F_2D | F_3D | F_CUBE | F_MS); + static const DXGISupport info(F_RT | F_SAMPLE, F_DS, F_2D | F_3D | F_CUBE | F_MS); return info; } case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: { - static const DXGISupport info(F_RT | F_SAMPLE, F_DS | F_MIPGEN, F_2D | F_3D | F_CUBE | F_MS); + static const DXGISupport info(F_RT | F_SAMPLE, F_DS, F_2D | F_3D | F_CUBE | F_MS); return info; } case DXGI_FORMAT_BC1_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC1_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC1_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC2_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC2_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC2_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC3_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC3_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC3_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC4_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC4_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC4_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC5_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC5_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC5_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC6H_SF16: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC6H_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC6H_UF16: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC7_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_BC7_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_BC7_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_D16_UNORM: { - static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_D24_UNORM_S8_UINT: @@ -2013,397 +1416,397 @@ const DXGISupport &GetDXGISupport_11_0(DXGI_FORMAT dxgiFormat) } case DXGI_FORMAT_D32_FLOAT: { - static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: { - static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_CUBE | F_DS, F_3D | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_G8R8_G8B8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_IA44: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_NV11: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_NV12: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_P010: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_P016: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_RT | F_SAMPLE, F_MS); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_RT | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_P8: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R10G10B10A2_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R10G10B10A2_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R10G10B10A2_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: { - static const DXGISupport info(0, F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, F_2D | F_3D); + static const DXGISupport info(0, F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, F_2D | F_3D); return info; } case DXGI_FORMAT_R11G11B10_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R16G16B16A16_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16G16B16A16_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16G16_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16G16_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R16G16_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16G16_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R16_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R16_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R16_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R1_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R24G8_TYPELESS: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: { - static const DXGISupport info(F_2D | F_CUBE | F_SAMPLE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_CUBE | F_SAMPLE, F_3D | F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_R32G32B32A32_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R32G32B32A32_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32G32B32A32_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32G32B32A32_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32G32B32_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS, F_MS | F_RT); return info; } case DXGI_FORMAT_R32G32B32_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_SAMPLE, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_SAMPLE, F_MS | F_RT); return info; } case DXGI_FORMAT_R32G32B32_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32G32B32_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_SAMPLE, F_MS | F_RT); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_SAMPLE, F_MS | F_RT); return info; } case DXGI_FORMAT_R32G32_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R32G32_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32G32_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32G32_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32G8X24_TYPELESS: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32_FLOAT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: { - static const DXGISupport info(F_2D | F_CUBE | F_SAMPLE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_CUBE | F_SAMPLE, F_3D | F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_R32_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R32_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R32_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R8G8B8A8_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8G8_B8G8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_R8G8_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8G8_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R8G8_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8G8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8_SINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8_SNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R8_TYPELESS: { - static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_R8_UINT: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_MIPGEN | F_SAMPLE, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT, F_DS | F_SAMPLE, F_MS); return info; } case DXGI_FORMAT_R8_UNORM: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_MIPGEN | F_RT | F_SAMPLE, F_DS, F_MS); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_RT | F_SAMPLE, F_DS, F_MS); return info; } case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: { - static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0); + static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MS | F_RT, 0); return info; } case DXGI_FORMAT_UNKNOWN: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_X24_TYPELESS_G8_UINT: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: { - static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(F_2D | F_CUBE, F_3D | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_Y210: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_Y216: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_Y410: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_Y416: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } case DXGI_FORMAT_YUY2: { - static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MIPGEN | F_MS | F_RT | F_SAMPLE, 0); + static const DXGISupport info(0, F_2D | F_3D | F_CUBE | F_DS | F_MS | F_RT | F_SAMPLE, 0); return info; } @@ -2411,7 +1814,6 @@ const DXGISupport &GetDXGISupport_11_0(DXGI_FORMAT dxgiFormat) UNREACHABLE(); return GetDefaultSupport(); } - // clang-format on } } @@ -2423,14 +1825,11 @@ const DXGISupport &GetDXGISupport_11_0(DXGI_FORMAT dxgiFormat) #undef F_RT #undef F_MS #undef F_DS -#undef F_MIPGEN const DXGISupport &GetDXGISupport(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_9_3: - return GetDXGISupport_9_3(dxgiFormat); case D3D_FEATURE_LEVEL_10_0: return GetDXGISupport_10_0(dxgiFormat); case D3D_FEATURE_LEVEL_10_1: diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.cpp index 695ad468d..c4b3f3202 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.cpp @@ -15,7 +15,6 @@ #include "libANGLE/formatutils.h" #include "libANGLE/renderer/d3d/d3d11/copyvertex.h" -#include "libANGLE/renderer/d3d/d3d11/dxgi_support_table.h" #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #include "libANGLE/renderer/d3d/d3d11/Renderer11.h" @@ -25,11 +24,329 @@ namespace rx namespace d3d11 { -bool SupportsMipGen(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL featureLevel) +struct DXGIColorFormatInfo { - const auto &support = GetDXGISupport(dxgiFormat, featureLevel); - ASSERT((support.optionallySupportedFlags & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN) == 0); - return ((support.alwaysSupportedFlags & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN) != 0); + size_t redBits; + size_t greenBits; + size_t blueBits; + + size_t luminanceBits; + + size_t alphaBits; + size_t sharedBits; +}; + +typedef std::map<DXGI_FORMAT, DXGIColorFormatInfo> ColorFormatInfoMap; +typedef std::pair<DXGI_FORMAT, DXGIColorFormatInfo> ColorFormatInfoPair; + +static inline void InsertDXGIColorFormatInfo(ColorFormatInfoMap *map, DXGI_FORMAT format, size_t redBits, size_t greenBits, + size_t blueBits, size_t alphaBits, size_t sharedBits) +{ + DXGIColorFormatInfo info; + info.redBits = redBits; + info.greenBits = greenBits; + info.blueBits = blueBits; + info.alphaBits = alphaBits; + info.sharedBits = sharedBits; + + map->insert(std::make_pair(format, info)); +} + +static ColorFormatInfoMap BuildColorFormatInfoMap() +{ + ColorFormatInfoMap map; + + // clang-format off + // | DXGI format | R | G | B | A | S | + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_A8_UNORM, 0, 0, 0, 8, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8_UNORM, 8, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8_UNORM, 8, 8, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8B8A8_UNORM, 8, 8, 8, 8, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, 8, 8, 8, 8, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_B8G8R8A8_UNORM, 8, 8, 8, 8, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16_UNORM, 16, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16_UNORM, 16, 16, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16B16A16_UNORM, 16, 16, 16, 16, 0); + + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8_SNORM, 8, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8_SNORM, 8, 8, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8B8A8_SNORM, 8, 8, 8, 8, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16_SNORM, 16, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16_SNORM, 16, 16, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16B16A16_SNORM, 16, 16, 16, 16, 0); + + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8_UINT, 8, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16_UINT, 16, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32_UINT, 32, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8_UINT, 8, 8, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16_UINT, 16, 16, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32_UINT, 32, 32, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32_UINT, 32, 32, 32, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8B8A8_UINT, 8, 8, 8, 8, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16B16A16_UINT, 16, 16, 16, 16, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32A32_UINT, 32, 32, 32, 32, 0); + + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8_SINT, 8, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16_SINT, 16, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32_SINT, 32, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8_SINT, 8, 8, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16_SINT, 16, 16, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32_SINT, 32, 32, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32_SINT, 32, 32, 32, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8B8A8_SINT, 8, 8, 8, 8, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16B16A16_SINT, 16, 16, 16, 16, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32A32_SINT, 32, 32, 32, 32, 0); + + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R10G10B10A2_TYPELESS, 10, 10, 10, 2, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R10G10B10A2_UNORM, 10, 10, 10, 2, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R10G10B10A2_UINT, 10, 10, 10, 2, 0); + + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16_FLOAT, 16, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16_FLOAT, 16, 16, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16B16A16_FLOAT, 16, 16, 16, 16, 0); + + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32_FLOAT, 32, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32_FLOAT, 32, 32, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32_FLOAT, 32, 32, 32, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32A32_FLOAT, 32, 32, 32, 32, 0); + + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, 9, 9, 9, 0, 5); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R11G11B10_FLOAT, 11, 11, 10, 0, 0); + + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_B5G6R5_UNORM, 5, 6, 5, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_B4G4R4A4_UNORM, 4, 4, 4, 4, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_B5G5R5A1_UNORM, 5, 5, 5, 1, 0); + + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8_TYPELESS, 8, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16_TYPELESS, 16, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32_TYPELESS, 32, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8_TYPELESS, 8, 8, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16_TYPELESS, 16, 16, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32_TYPELESS, 32, 32, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32_TYPELESS, 32, 32, 32, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8B8A8_TYPELESS, 8, 8, 8, 8, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16B16A16_TYPELESS, 16, 16, 16, 16, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32A32_TYPELESS, 32, 32, 32, 32, 0); + + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R24G8_TYPELESS, 24, 8, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, 24, 0, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G8X24_TYPELESS, 32, 8, 0, 0, 0); + InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, 32, 0, 0, 0, 0); + // clang-format on + + return map; +} + +struct DXGIDepthStencilInfo +{ + unsigned int depthBits; + unsigned int stencilBits; +}; + +typedef std::map<DXGI_FORMAT, DXGIDepthStencilInfo> DepthStencilInfoMap; +typedef std::pair<DXGI_FORMAT, DXGIDepthStencilInfo> DepthStencilInfoPair; + +static inline void InsertDXGIDepthStencilInfo(DepthStencilInfoMap *map, + DXGI_FORMAT format, + unsigned int depthBits, + unsigned int stencilBits) +{ + DXGIDepthStencilInfo info; + info.depthBits = depthBits; + info.stencilBits = stencilBits; + + map->insert(std::make_pair(format, info)); +} + +static DepthStencilInfoMap BuildDepthStencilInfoMap() +{ + DepthStencilInfoMap map; + + // clang-format off + InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_D16_UNORM, 16, 0); + InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_D24_UNORM_S8_UINT, 24, 8); + InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_D32_FLOAT, 32, 0); + InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_D32_FLOAT_S8X24_UINT, 32, 8); + // clang-format on + + return map; +} + +typedef std::map<DXGI_FORMAT, DXGIFormat> DXGIFormatInfoMap; + +DXGIFormat::DXGIFormat() + : redBits(0), + greenBits(0), + blueBits(0), + alphaBits(0), + sharedBits(0), + depthBits(0), + stencilBits(0), + componentType(GL_NONE), + nativeMipmapSupport(NULL) +{ +} + +static bool NeverSupported(D3D_FEATURE_LEVEL) +{ + return false; +} + +template <D3D_FEATURE_LEVEL requiredFeatureLevel> +static bool RequiresFeatureLevel(D3D_FEATURE_LEVEL featureLevel) +{ + return featureLevel >= requiredFeatureLevel; +} + +void AddDXGIFormat(DXGIFormatInfoMap *map, + DXGI_FORMAT dxgiFormat, + GLenum componentType, + NativeMipmapGenerationSupportFunction nativeMipmapSupport) +{ + DXGIFormat info; + + static const ColorFormatInfoMap colorInfoMap = BuildColorFormatInfoMap(); + ColorFormatInfoMap::const_iterator colorInfoIter = colorInfoMap.find(dxgiFormat); + if (colorInfoIter != colorInfoMap.end()) + { + const DXGIColorFormatInfo &colorInfo = colorInfoIter->second; + info.redBits = static_cast<GLuint>(colorInfo.redBits); + info.greenBits = static_cast<GLuint>(colorInfo.greenBits); + info.blueBits = static_cast<GLuint>(colorInfo.blueBits); + info.alphaBits = static_cast<GLuint>(colorInfo.alphaBits); + info.sharedBits = static_cast<GLuint>(colorInfo.sharedBits); + } + + static const DepthStencilInfoMap dsInfoMap = BuildDepthStencilInfoMap(); + DepthStencilInfoMap::const_iterator dsInfoIter = dsInfoMap.find(dxgiFormat); + if (dsInfoIter != dsInfoMap.end()) + { + const DXGIDepthStencilInfo &dsInfo = dsInfoIter->second; + info.depthBits = dsInfo.depthBits; + info.stencilBits = dsInfo.stencilBits; + } + + info.componentType = componentType; + info.nativeMipmapSupport = nativeMipmapSupport; + + map->insert(std::make_pair(dxgiFormat, info)); +} + +// A map to determine the color read function and mipmap generation function of a given DXGI format +static DXGIFormatInfoMap BuildDXGIFormatInfoMap() +{ + DXGIFormatInfoMap map; + + // clang-format off + // | DXGI format | Component Type | Color read function | Native mipmap function + AddDXGIFormat(&map, DXGI_FORMAT_UNKNOWN, GL_NONE, NeverSupported); + + AddDXGIFormat(&map, DXGI_FORMAT_A8_UNORM, GL_UNSIGNED_NORMALIZED, RequiresFeatureLevel<D3D_FEATURE_LEVEL_10_0>); + AddDXGIFormat(&map, DXGI_FORMAT_R8_UNORM, GL_UNSIGNED_NORMALIZED, RequiresFeatureLevel<D3D_FEATURE_LEVEL_10_0>); + AddDXGIFormat(&map, DXGI_FORMAT_R16_UNORM, GL_UNSIGNED_NORMALIZED, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R8G8_UNORM, GL_UNSIGNED_NORMALIZED, RequiresFeatureLevel<D3D_FEATURE_LEVEL_10_0>); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16_UNORM, GL_UNSIGNED_NORMALIZED, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_UNORM, GL_UNSIGNED_NORMALIZED, RequiresFeatureLevel<D3D_FEATURE_LEVEL_9_1>); + AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, GL_UNSIGNED_NORMALIZED, RequiresFeatureLevel<D3D_FEATURE_LEVEL_9_1>); + AddDXGIFormat(&map, DXGI_FORMAT_B8G8R8A8_UNORM, GL_UNSIGNED_NORMALIZED, RequiresFeatureLevel<D3D_FEATURE_LEVEL_9_1>); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_UNORM, GL_UNSIGNED_NORMALIZED, NeverSupported); + + AddDXGIFormat(&map, DXGI_FORMAT_R8_SNORM, GL_SIGNED_NORMALIZED, RequiresFeatureLevel<D3D_FEATURE_LEVEL_10_0>); + AddDXGIFormat(&map, DXGI_FORMAT_R16_SNORM, GL_SIGNED_NORMALIZED, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R8G8_SNORM, GL_SIGNED_NORMALIZED, RequiresFeatureLevel<D3D_FEATURE_LEVEL_10_0>); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16_SNORM, GL_SIGNED_NORMALIZED, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_SNORM, GL_SIGNED_NORMALIZED, RequiresFeatureLevel<D3D_FEATURE_LEVEL_10_0>); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_SNORM, GL_SIGNED_NORMALIZED, NeverSupported); + + AddDXGIFormat(&map, DXGI_FORMAT_R8_UINT, GL_UNSIGNED_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R16_UINT, GL_UNSIGNED_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32_UINT, GL_UNSIGNED_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R8G8_UINT, GL_UNSIGNED_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16_UINT, GL_UNSIGNED_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32_UINT, GL_UNSIGNED_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32_UINT, GL_UNSIGNED_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_UINT, GL_UNSIGNED_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_UINT, GL_UNSIGNED_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32A32_UINT, GL_UNSIGNED_INT, NeverSupported); + + AddDXGIFormat(&map, DXGI_FORMAT_R8_SINT, GL_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R16_SINT, GL_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32_SINT, GL_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R8G8_SINT, GL_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16_SINT, GL_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32_SINT, GL_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32_SINT, GL_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_SINT, GL_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_SINT, GL_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32A32_SINT, GL_INT, NeverSupported); + + AddDXGIFormat(&map, DXGI_FORMAT_R10G10B10A2_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R10G10B10A2_UNORM, GL_UNSIGNED_NORMALIZED, RequiresFeatureLevel<D3D_FEATURE_LEVEL_10_0>); + AddDXGIFormat(&map, DXGI_FORMAT_R10G10B10A2_UINT, GL_UNSIGNED_INT, NeverSupported); + + AddDXGIFormat(&map, DXGI_FORMAT_R16_FLOAT, GL_FLOAT, RequiresFeatureLevel<D3D_FEATURE_LEVEL_10_0>); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16_FLOAT, GL_FLOAT, RequiresFeatureLevel<D3D_FEATURE_LEVEL_9_2>); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_FLOAT, GL_FLOAT, RequiresFeatureLevel<D3D_FEATURE_LEVEL_9_2>); + + AddDXGIFormat(&map, DXGI_FORMAT_R32_FLOAT, GL_FLOAT, RequiresFeatureLevel<D3D_FEATURE_LEVEL_9_2>); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32_FLOAT, GL_FLOAT, RequiresFeatureLevel<D3D_FEATURE_LEVEL_10_0>); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32_FLOAT, GL_FLOAT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32A32_FLOAT, GL_FLOAT, RequiresFeatureLevel<D3D_FEATURE_LEVEL_9_3>); + + AddDXGIFormat(&map, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, GL_FLOAT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R11G11B10_FLOAT, GL_FLOAT, RequiresFeatureLevel<D3D_FEATURE_LEVEL_10_0>); + + AddDXGIFormat(&map, DXGI_FORMAT_R8_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R16_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R8G8_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R8G8_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32A32_TYPELESS, GL_NONE, NeverSupported); + + AddDXGIFormat(&map, DXGI_FORMAT_R24G8_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32G8X24_TYPELESS, GL_NONE, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, GL_NONE, NeverSupported); + + AddDXGIFormat(&map, DXGI_FORMAT_D16_UNORM, GL_UNSIGNED_NORMALIZED, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_D24_UNORM_S8_UINT, GL_UNSIGNED_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_D32_FLOAT_S8X24_UINT, GL_UNSIGNED_INT, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_D32_FLOAT, GL_FLOAT, NeverSupported); + + AddDXGIFormat(&map, DXGI_FORMAT_BC1_UNORM, GL_UNSIGNED_NORMALIZED, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_BC2_UNORM, GL_UNSIGNED_NORMALIZED, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_BC3_UNORM, GL_UNSIGNED_NORMALIZED, NeverSupported); + + // B5G6R5 in D3D11 is treated the same as R5G6B5 in D3D9, so reuse the R5G6B5 functions used by the D3D9 renderer. + // The same applies to B4G4R4A4 and B5G5R5A1 with A4R4G4B4 and A1R5G5B5 respectively. + AddDXGIFormat(&map, DXGI_FORMAT_B5G6R5_UNORM, GL_UNSIGNED_NORMALIZED, RequiresFeatureLevel<D3D_FEATURE_LEVEL_9_1>); + AddDXGIFormat(&map, DXGI_FORMAT_B4G4R4A4_UNORM, GL_UNSIGNED_NORMALIZED, NeverSupported); + AddDXGIFormat(&map, DXGI_FORMAT_B5G5R5A1_UNORM, GL_UNSIGNED_NORMALIZED, NeverSupported); + // clang-format on + + return map; +} + +const DXGIFormat &GetDXGIFormatInfo(DXGI_FORMAT format) +{ + static const DXGIFormatInfoMap infoMap = BuildDXGIFormatInfoMap(); + DXGIFormatInfoMap::const_iterator iter = infoMap.find(format); + if (iter != infoMap.end()) + { + return iter->second; + } + else + { + static DXGIFormat defaultInfo; + return defaultInfo; + } } DXGIFormatSize::DXGIFormatSize(GLuint pixelBits, GLuint blockWidth, GLuint blockHeight) @@ -199,214 +516,117 @@ const DXGIFormatSize &GetDXGIFormatSizeInfo(DXGI_FORMAT format) } } -constexpr VertexFormat::VertexFormat() - : conversionType(VERTEX_CONVERT_NONE), nativeFormat(DXGI_FORMAT_UNKNOWN), copyFunction(NULL) +typedef std::map<gl::VertexFormatType, VertexFormat> D3D11VertexFormatInfoMap; +typedef std::pair<gl::VertexFormatType, VertexFormat> D3D11VertexFormatPair; + +VertexFormat::VertexFormat() + : conversionType(VERTEX_CONVERT_NONE), + nativeFormat(DXGI_FORMAT_UNKNOWN), + copyFunction(NULL) +{ +} + +VertexFormat::VertexFormat(VertexConversionType conversionTypeIn, + DXGI_FORMAT nativeFormatIn, + VertexCopyFunction copyFunctionIn) + : conversionType(conversionTypeIn), + nativeFormat(nativeFormatIn), + copyFunction(copyFunctionIn) { } -constexpr VertexFormat::VertexFormat(VertexConversionType conversionTypeIn, - DXGI_FORMAT nativeFormatIn, - VertexCopyFunction copyFunctionIn) - : conversionType(conversionTypeIn), nativeFormat(nativeFormatIn), copyFunction(copyFunctionIn) +static void AddVertexFormatInfo(D3D11VertexFormatInfoMap *map, + GLenum inputType, + GLboolean normalized, + GLuint componentCount, + VertexConversionType conversionType, + DXGI_FORMAT nativeFormat, + VertexCopyFunction copyFunction) { + gl::VertexFormatType formatType = gl::GetVertexFormatType(inputType, normalized, componentCount, false); + + VertexFormat info; + info.conversionType = conversionType; + info.nativeFormat = nativeFormat; + info.copyFunction = copyFunction; + + map->insert(D3D11VertexFormatPair(formatType, info)); } -const VertexFormat *GetVertexFormatInfo_FL_9_3(gl::VertexFormatType vertexFormatType) +static D3D11VertexFormatInfoMap BuildD3D11_FL9_3VertexFormatInfoOverrideMap() { - // D3D11 Feature Level 9_3 doesn't support as many formats for vertex buffer resource as Feature - // Level 10_0+. + // D3D11 Feature Level 9_3 doesn't support as many formats for vertex buffer resource as Feature Level 10_0+. // http://msdn.microsoft.com/en-us/library/windows/desktop/ff471324(v=vs.85).aspx - switch (vertexFormatType) - { - // GL_BYTE -- unnormalized - case gl::VERTEX_FORMAT_SBYTE1: - { - static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16_SINT, - &Copy8SintTo16SintVertexData<1, 2>); - return &info; - } - case gl::VERTEX_FORMAT_SBYTE2: - { - static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16_SINT, - &Copy8SintTo16SintVertexData<2, 2>); - return &info; - } - case gl::VERTEX_FORMAT_SBYTE3: - { - static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_SINT, - &Copy8SintTo16SintVertexData<3, 4>); - return &info; - } - case gl::VERTEX_FORMAT_SBYTE4: - { - static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_SINT, - &Copy8SintTo16SintVertexData<4, 4>); - return &info; - } + D3D11VertexFormatInfoMap map; - // GL_BYTE -- normalized - case gl::VERTEX_FORMAT_SBYTE1_NORM: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16_SNORM, - &Copy8SnormTo16SnormVertexData<1, 2>); - return &info; - } - case gl::VERTEX_FORMAT_SBYTE2_NORM: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16_SNORM, - &Copy8SnormTo16SnormVertexData<2, 2>); - return &info; - } - case gl::VERTEX_FORMAT_SBYTE3_NORM: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SNORM, - &Copy8SnormTo16SnormVertexData<3, 4>); - return &info; - } - case gl::VERTEX_FORMAT_SBYTE4_NORM: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SNORM, - &Copy8SnormTo16SnormVertexData<4, 4>); - return &info; - } + // GL_BYTE -- unnormalized + AddVertexFormatInfo(&map, GL_BYTE, GL_FALSE, 1, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16_SINT, &Copy8SintTo16SintVertexData<1, 2>); + AddVertexFormatInfo(&map, GL_BYTE, GL_FALSE, 2, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16_SINT, &Copy8SintTo16SintVertexData<2, 2>); + AddVertexFormatInfo(&map, GL_BYTE, GL_FALSE, 3, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_SINT, &Copy8SintTo16SintVertexData<3, 4>); + AddVertexFormatInfo(&map, GL_BYTE, GL_FALSE, 4, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_SINT, &Copy8SintTo16SintVertexData<4, 4>); - // GL_UNSIGNED_BYTE -- un-normalized - // NOTE: 3 and 4 component unnormalized GL_UNSIGNED_BYTE should use the default format - // table. - case gl::VERTEX_FORMAT_UBYTE1: - { - static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_UINT, - &CopyNativeVertexData<GLubyte, 1, 4, 1>); - return &info; - } - case gl::VERTEX_FORMAT_UBYTE2: - { - static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_UINT, - &CopyNativeVertexData<GLubyte, 2, 4, 1>); - return &info; - } + // GL_BYTE -- normalized + AddVertexFormatInfo(&map, GL_BYTE, GL_TRUE, 1, VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16_SNORM, &Copy8SnormTo16SnormVertexData<1, 2>); + AddVertexFormatInfo(&map, GL_BYTE, GL_TRUE, 2, VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16_SNORM, &Copy8SnormTo16SnormVertexData<2, 2>); + AddVertexFormatInfo(&map, GL_BYTE, GL_TRUE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SNORM, &Copy8SnormTo16SnormVertexData<3, 4>); + AddVertexFormatInfo(&map, GL_BYTE, GL_TRUE, 4, VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SNORM, &Copy8SnormTo16SnormVertexData<4, 4>); - // GL_UNSIGNED_BYTE -- normalized - // NOTE: 3 and 4 component normalized GL_UNSIGNED_BYTE should use the default format table. + // GL_UNSIGNED_BYTE -- unnormalized + AddVertexFormatInfo(&map, GL_UNSIGNED_BYTE, GL_FALSE, 1, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_UINT, &CopyNativeVertexData<GLubyte, 1, 4, 1>); + AddVertexFormatInfo(&map, GL_UNSIGNED_BYTE, GL_FALSE, 2, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_UINT, &CopyNativeVertexData<GLubyte, 2, 4, 1>); + // NOTE: 3 and 4 component unnormalized GL_UNSIGNED_BYTE should use the default format table. - // GL_UNSIGNED_BYTE -- normalized - case gl::VERTEX_FORMAT_UBYTE1_NORM: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UNORM, - &CopyNativeVertexData<GLubyte, 1, 4, UINT8_MAX>); - return &info; - } - case gl::VERTEX_FORMAT_UBYTE2_NORM: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UNORM, - &CopyNativeVertexData<GLubyte, 2, 4, UINT8_MAX>); - return &info; - } + // GL_UNSIGNED_BYTE -- normalized + AddVertexFormatInfo(&map, GL_UNSIGNED_BYTE, GL_TRUE, 1, VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UNORM, &CopyNativeVertexData<GLubyte, 1, 4, UINT8_MAX>); + AddVertexFormatInfo(&map, GL_UNSIGNED_BYTE, GL_TRUE, 2, VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UNORM, &CopyNativeVertexData<GLubyte, 2, 4, UINT8_MAX>); + // NOTE: 3 and 4 component normalized GL_UNSIGNED_BYTE should use the default format table. - // GL_SHORT -- un-normalized - // NOTE: 2, 3 and 4 component unnormalized GL_SHORT should use the default format table. - case gl::VERTEX_FORMAT_SSHORT1: - { - static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16_SINT, - &CopyNativeVertexData<GLshort, 1, 2, 0>); - return &info; - } + // GL_SHORT -- unnormalized + AddVertexFormatInfo(&map, GL_SHORT, GL_FALSE, 1, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16_SINT, &CopyNativeVertexData<GLshort, 1, 2, 0>); + // NOTE: 2, 3 and 4 component unnormalized GL_SHORT should use the default format table. - // GL_SHORT -- normalized - // NOTE: 2, 3 and 4 component normalized GL_SHORT should use the default format table. - case gl::VERTEX_FORMAT_SSHORT1_NORM: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16_SNORM, - &CopyNativeVertexData<GLshort, 1, 2, 0>); - return &info; - } + // GL_SHORT -- normalized + AddVertexFormatInfo(&map, GL_SHORT, GL_TRUE, 1, VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16_SNORM, &CopyNativeVertexData<GLshort, 1, 2, 0>); + // NOTE: 2, 3 and 4 component normalized GL_SHORT should use the default format table. - // GL_UNSIGNED_SHORT -- un-normalized - case gl::VERTEX_FORMAT_USHORT1: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, - &CopyTo32FVertexData<GLushort, 1, 2, false>); - return &info; - } - case gl::VERTEX_FORMAT_USHORT2: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, - &CopyTo32FVertexData<GLushort, 2, 2, false>); - return &info; - } - case gl::VERTEX_FORMAT_USHORT3: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, - &CopyTo32FVertexData<GLushort, 3, 3, false>); - return &info; - } - case gl::VERTEX_FORMAT_USHORT4: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, - &CopyTo32FVertexData<GLushort, 4, 4, false>); - return &info; - } + // GL_UNSIGNED_SHORT -- unnormalized + AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_FALSE, 1, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, &CopyTo32FVertexData<GLushort, 1, 2, false>); + AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_FALSE, 2, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, &CopyTo32FVertexData<GLushort, 2, 2, false>); + AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_FALSE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, &CopyTo32FVertexData<GLushort, 3, 3, false>); + AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_FALSE, 4, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyTo32FVertexData<GLushort, 4, 4, false>); - // GL_UNSIGNED_SHORT -- normalized - case gl::VERTEX_FORMAT_USHORT1_NORM: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, - &CopyTo32FVertexData<GLushort, 1, 2, true>); - return &info; - } - case gl::VERTEX_FORMAT_USHORT2_NORM: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, - &CopyTo32FVertexData<GLushort, 2, 2, true>); - return &info; - } - case gl::VERTEX_FORMAT_USHORT3_NORM: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, - &CopyTo32FVertexData<GLushort, 3, 3, true>); - return &info; - } - case gl::VERTEX_FORMAT_USHORT4_NORM: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, - &CopyTo32FVertexData<GLushort, 4, 4, true>); - return &info; - } + // GL_UNSIGNED_SHORT -- normalized + AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_TRUE, 1, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, &CopyTo32FVertexData<GLushort, 1, 2, true>); + AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_TRUE, 2, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, &CopyTo32FVertexData<GLushort, 2, 2, true>); + AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_TRUE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, &CopyTo32FVertexData<GLushort, 3, 3, true>); + AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_TRUE, 4, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyTo32FVertexData<GLushort, 4, 4, true>); - // GL_FIXED - // TODO: Add test to verify that this works correctly. - // NOTE: 2, 3 and 4 component GL_FIXED should use the default format table. - case gl::VERTEX_FORMAT_FIXED1: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, - &Copy32FixedTo32FVertexData<1, 2>); - return &info; - } + // GL_FIXED + // TODO: Add test to verify that this works correctly. + AddVertexFormatInfo(&map, GL_FIXED, GL_FALSE, 1, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, &Copy32FixedTo32FVertexData<1, 2>); + // NOTE: 2, 3 and 4 component GL_FIXED should use the default format table. - // GL_FLOAT - // TODO: Add test to verify that this works correctly. - // NOTE: 2, 3 and 4 component GL_FLOAT should use the default format table. - case gl::VERTEX_FORMAT_FLOAT1: - { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, - &CopyNativeVertexData<GLfloat, 1, 2, 0>); - return &info; - } + // GL_FLOAT + // TODO: Add test to verify that this works correctly. + AddVertexFormatInfo(&map, GL_FLOAT, GL_FALSE, 1, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, &CopyNativeVertexData<GLfloat, 1, 2, 0>); + // NOTE: 2, 3 and 4 component GL_FLOAT should use the default format table. - default: - return nullptr; - } + return map; } const VertexFormat &GetVertexFormatInfo(gl::VertexFormatType vertexFormatType, D3D_FEATURE_LEVEL featureLevel) { if (featureLevel == D3D_FEATURE_LEVEL_9_3) { - const VertexFormat *result = GetVertexFormatInfo_FL_9_3(vertexFormatType); - if (result) + static const D3D11VertexFormatInfoMap vertexFormatMapFL9_3Override = + BuildD3D11_FL9_3VertexFormatInfoOverrideMap(); + + // First see if the format has a special mapping for FL9_3 + auto iter = vertexFormatMapFL9_3Override.find(vertexFormatType); + if (iter != vertexFormatMapFL9_3Override.end()) { - return *result; + return iter->second; } } @@ -419,418 +639,357 @@ const VertexFormat &GetVertexFormatInfo(gl::VertexFormatType vertexFormatType, D // GL_BYTE -- un-normalized case gl::VERTEX_FORMAT_SBYTE1: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8_SINT, - &CopyNativeVertexData<GLbyte, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8_SINT, &CopyNativeVertexData<GLbyte, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_SBYTE2: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8_SINT, - &CopyNativeVertexData<GLbyte, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8_SINT, &CopyNativeVertexData<GLbyte, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_SBYTE3: { - static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_SINT, - &CopyNativeVertexData<GLbyte, 3, 4, 1>); + static const VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_SINT, &CopyNativeVertexData<GLbyte, 3, 4, 1>); return info; } case gl::VERTEX_FORMAT_SBYTE4: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8B8A8_SINT, - &CopyNativeVertexData<GLbyte, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8B8A8_SINT, &CopyNativeVertexData<GLbyte, 4, 4, 0>); return info; } // GL_BYTE -- normalized case gl::VERTEX_FORMAT_SBYTE1_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_SNORM, - &CopyNativeVertexData<GLbyte, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_SNORM, &CopyNativeVertexData<GLbyte, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_SBYTE2_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_SNORM, - &CopyNativeVertexData<GLbyte, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_SNORM, &CopyNativeVertexData<GLbyte, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_SBYTE3_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_SNORM, - &CopyNativeVertexData<GLbyte, 3, 4, INT8_MAX>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_SNORM, &CopyNativeVertexData<GLbyte, 3, 4, INT8_MAX>); return info; } case gl::VERTEX_FORMAT_SBYTE4_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_SNORM, - &CopyNativeVertexData<GLbyte, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_SNORM, &CopyNativeVertexData<GLbyte, 4, 4, 0>); return info; } // GL_UNSIGNED_BYTE -- un-normalized case gl::VERTEX_FORMAT_UBYTE1: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8_UINT, - &CopyNativeVertexData<GLubyte, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8_UINT, &CopyNativeVertexData<GLubyte, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_UBYTE2: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8_UINT, - &CopyNativeVertexData<GLubyte, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8_UINT, &CopyNativeVertexData<GLubyte, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_UBYTE3: { - static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_UINT, - &CopyNativeVertexData<GLubyte, 3, 4, 1>); + static const VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_UINT, &CopyNativeVertexData<GLubyte, 3, 4, 1>); return info; } case gl::VERTEX_FORMAT_UBYTE4: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8B8A8_UINT, - &CopyNativeVertexData<GLubyte, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8B8A8_UINT, &CopyNativeVertexData<GLubyte, 4, 4, 0>); return info; } // GL_UNSIGNED_BYTE -- normalized case gl::VERTEX_FORMAT_UBYTE1_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_UNORM, - &CopyNativeVertexData<GLubyte, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_UNORM, &CopyNativeVertexData<GLubyte, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_UBYTE2_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_UNORM, - &CopyNativeVertexData<GLubyte, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_UNORM, &CopyNativeVertexData<GLubyte, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_UBYTE3_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UNORM, - &CopyNativeVertexData<GLubyte, 3, 4, UINT8_MAX>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UNORM, &CopyNativeVertexData<GLubyte, 3, 4, UINT8_MAX>); return info; } case gl::VERTEX_FORMAT_UBYTE4_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_UNORM, - &CopyNativeVertexData<GLubyte, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_UNORM, &CopyNativeVertexData<GLubyte, 4, 4, 0>); return info; } // GL_SHORT -- un-normalized case gl::VERTEX_FORMAT_SSHORT1: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16_SINT, - &CopyNativeVertexData<GLshort, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16_SINT, &CopyNativeVertexData<GLshort, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_SSHORT2: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16_SINT, - &CopyNativeVertexData<GLshort, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16_SINT, &CopyNativeVertexData<GLshort, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_SSHORT3: { - static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_SINT, - &CopyNativeVertexData<GLshort, 3, 4, 1>); + static const VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_SINT, &CopyNativeVertexData<GLshort, 3, 4, 1>); return info; } case gl::VERTEX_FORMAT_SSHORT4: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16B16A16_SINT, - &CopyNativeVertexData<GLshort, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16B16A16_SINT, &CopyNativeVertexData<GLshort, 4, 4, 0>); return info; } // GL_SHORT -- normalized case gl::VERTEX_FORMAT_SSHORT1_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_SNORM, - &CopyNativeVertexData<GLshort, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_SNORM, &CopyNativeVertexData<GLshort, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_SSHORT2_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_SNORM, - &CopyNativeVertexData<GLshort, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_SNORM, &CopyNativeVertexData<GLshort, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_SSHORT3_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SNORM, - &CopyNativeVertexData<GLshort, 3, 4, INT16_MAX>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SNORM, &CopyNativeVertexData<GLshort, 3, 4, INT16_MAX>); return info; } case gl::VERTEX_FORMAT_SSHORT4_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_SNORM, - &CopyNativeVertexData<GLshort, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_SNORM, &CopyNativeVertexData<GLshort, 4, 4, 0>); return info; } // GL_UNSIGNED_SHORT -- un-normalized case gl::VERTEX_FORMAT_USHORT1: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16_UINT, - &CopyNativeVertexData<GLushort, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16_UINT, &CopyNativeVertexData<GLushort, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_USHORT2: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16_UINT, - &CopyNativeVertexData<GLushort, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16_UINT, &CopyNativeVertexData<GLushort, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_USHORT3: { - static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_UINT, - &CopyNativeVertexData<GLushort, 3, 4, 1>); + static const VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_UINT, &CopyNativeVertexData<GLushort, 3, 4, 1>); return info; } case gl::VERTEX_FORMAT_USHORT4: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16B16A16_UINT, - &CopyNativeVertexData<GLushort, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16B16A16_UINT, &CopyNativeVertexData<GLushort, 4, 4, 0>); return info; } // GL_UNSIGNED_SHORT -- normalized case gl::VERTEX_FORMAT_USHORT1_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_UNORM, - &CopyNativeVertexData<GLushort, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_UNORM, &CopyNativeVertexData<GLushort, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_USHORT2_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_UNORM, - &CopyNativeVertexData<GLushort, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_UNORM, &CopyNativeVertexData<GLushort, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_USHORT3_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_UNORM, - &CopyNativeVertexData<GLushort, 3, 4, UINT16_MAX>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_UNORM, &CopyNativeVertexData<GLushort, 3, 4, UINT16_MAX>); return info; } case gl::VERTEX_FORMAT_USHORT4_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_UNORM, - &CopyNativeVertexData<GLushort, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_UNORM, &CopyNativeVertexData<GLushort, 4, 4, 0>); return info; } // GL_INT -- un-normalized case gl::VERTEX_FORMAT_SINT1: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32_SINT, - &CopyNativeVertexData<GLint, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32_SINT, &CopyNativeVertexData<GLint, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_SINT2: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32_SINT, - &CopyNativeVertexData<GLint, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32_SINT, &CopyNativeVertexData<GLint, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_SINT3: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32_SINT, - &CopyNativeVertexData<GLint, 3, 3, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32_SINT, &CopyNativeVertexData<GLint, 3, 3, 0>); return info; } case gl::VERTEX_FORMAT_SINT4: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32A32_SINT, - &CopyNativeVertexData<GLint, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32A32_SINT, &CopyNativeVertexData<GLint, 4, 4, 0>); return info; } // GL_INT -- normalized case gl::VERTEX_FORMAT_SINT1_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32_FLOAT, - &CopyTo32FVertexData<GLint, 1, 1, true>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32_FLOAT, &CopyTo32FVertexData<GLint, 1, 1, true>); return info; } case gl::VERTEX_FORMAT_SINT2_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, - &CopyTo32FVertexData<GLint, 2, 2, true>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, &CopyTo32FVertexData<GLint, 2, 2, true>); return info; } case gl::VERTEX_FORMAT_SINT3_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, - &CopyTo32FVertexData<GLint, 3, 3, true>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, &CopyTo32FVertexData<GLint, 3, 3, true>); return info; } case gl::VERTEX_FORMAT_SINT4_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, - &CopyTo32FVertexData<GLint, 4, 4, true>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyTo32FVertexData<GLint, 4, 4, true>); return info; } // GL_UNSIGNED_INT -- un-normalized case gl::VERTEX_FORMAT_UINT1: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32_UINT, - &CopyNativeVertexData<GLuint, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32_UINT, &CopyNativeVertexData<GLuint, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_UINT2: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32_UINT, - &CopyNativeVertexData<GLuint, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32_UINT, &CopyNativeVertexData<GLuint, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_UINT3: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32_UINT, - &CopyNativeVertexData<GLuint, 3, 3, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32_UINT, &CopyNativeVertexData<GLuint, 3, 3, 0>); return info; } case gl::VERTEX_FORMAT_UINT4: { - static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32A32_UINT, - &CopyNativeVertexData<GLuint, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32A32_UINT, &CopyNativeVertexData<GLuint, 4, 4, 0>); return info; } // GL_UNSIGNED_INT -- normalized case gl::VERTEX_FORMAT_UINT1_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32_FLOAT, - &CopyTo32FVertexData<GLuint, 1, 1, true>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32_FLOAT, + &CopyTo32FVertexData<GLuint, 1, 1, true>); return info; } case gl::VERTEX_FORMAT_UINT2_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, - &CopyTo32FVertexData<GLuint, 2, 2, true>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, + &CopyTo32FVertexData<GLuint, 2, 2, true>); return info; } case gl::VERTEX_FORMAT_UINT3_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, - &CopyTo32FVertexData<GLuint, 3, 3, true>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, &CopyTo32FVertexData<GLuint, 3, 3, true>); return info; } case gl::VERTEX_FORMAT_UINT4_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, - &CopyTo32FVertexData<GLuint, 4, 4, true>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, + &CopyTo32FVertexData<GLuint, 4, 4, true>); return info; } // GL_FIXED case gl::VERTEX_FORMAT_FIXED1: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32_FLOAT, - &Copy32FixedTo32FVertexData<1, 1>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32_FLOAT, &Copy32FixedTo32FVertexData<1, 1>); return info; } case gl::VERTEX_FORMAT_FIXED2: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, - &Copy32FixedTo32FVertexData<2, 2>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, &Copy32FixedTo32FVertexData<2, 2>); return info; } case gl::VERTEX_FORMAT_FIXED3: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, - &Copy32FixedTo32FVertexData<3, 3>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, &Copy32FixedTo32FVertexData<3, 3>); return info; } case gl::VERTEX_FORMAT_FIXED4: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, - &Copy32FixedTo32FVertexData<4, 4>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, &Copy32FixedTo32FVertexData<4, 4>); return info; } // GL_HALF_FLOAT case gl::VERTEX_FORMAT_HALF1: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_FLOAT, - &CopyNativeVertexData<GLhalf, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_FLOAT, &CopyNativeVertexData<GLhalf, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_HALF2: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_FLOAT, - &CopyNativeVertexData<GLhalf, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_FLOAT, &CopyNativeVertexData<GLhalf, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_HALF3: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_FLOAT, - &CopyNativeVertexData<GLhalf, 3, 4, gl::Float16One>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_FLOAT, &CopyNativeVertexData<GLhalf, 3, 4, gl::Float16One>); return info; } case gl::VERTEX_FORMAT_HALF4: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_FLOAT, - &CopyNativeVertexData<GLhalf, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_FLOAT, &CopyNativeVertexData<GLhalf, 4, 4, 0>); return info; } // GL_FLOAT case gl::VERTEX_FORMAT_FLOAT1: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_FLOAT, - &CopyNativeVertexData<GLfloat, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_FLOAT, &CopyNativeVertexData<GLfloat, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_FLOAT2: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_FLOAT, - &CopyNativeVertexData<GLfloat, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_FLOAT, &CopyNativeVertexData<GLfloat, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_FLOAT3: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_FLOAT, - &CopyNativeVertexData<GLfloat, 3, 3, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_FLOAT, &CopyNativeVertexData<GLfloat, 3, 3, 0>); return info; } case gl::VERTEX_FORMAT_FLOAT4: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_FLOAT, - &CopyNativeVertexData<GLfloat, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyNativeVertexData<GLfloat, 4, 4, 0>); return info; } // GL_INT_2_10_10_10_REV case gl::VERTEX_FORMAT_SINT210: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, - &CopyXYZ10W2ToXYZW32FVertexData<true, false, true>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyXYZ10W2ToXYZW32FVertexData<true, false, true>); return info; } case gl::VERTEX_FORMAT_SINT210_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, - &CopyXYZ10W2ToXYZW32FVertexData<true, true, true>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyXYZ10W2ToXYZW32FVertexData<true, true, true>); return info; } // GL_UNSIGNED_INT_2_10_10_10_REV case gl::VERTEX_FORMAT_UINT210: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, - &CopyXYZ10W2ToXYZW32FVertexData<false, false, true>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyXYZ10W2ToXYZW32FVertexData<false, false, true>); return info; } case gl::VERTEX_FORMAT_UINT210_NORM: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R10G10B10A2_UNORM, - &CopyNativeVertexData<GLuint, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R10G10B10A2_UNORM, &CopyNativeVertexData<GLuint, 1, 1, 0>); return info; } @@ -841,183 +1000,157 @@ const VertexFormat &GetVertexFormatInfo(gl::VertexFormatType vertexFormatType, D // GL_BYTE case gl::VERTEX_FORMAT_SBYTE1_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_SINT, - &CopyNativeVertexData<GLbyte, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_SINT, &CopyNativeVertexData<GLbyte, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_SBYTE2_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_SINT, - &CopyNativeVertexData<GLbyte, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_SINT, &CopyNativeVertexData<GLbyte, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_SBYTE3_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_SINT, - &CopyNativeVertexData<GLbyte, 3, 4, 1>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_SINT, &CopyNativeVertexData<GLbyte, 3, 4, 1>); return info; } case gl::VERTEX_FORMAT_SBYTE4_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_SINT, - &CopyNativeVertexData<GLbyte, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_SINT, &CopyNativeVertexData<GLbyte, 4, 4, 0>); return info; } // GL_UNSIGNED_BYTE case gl::VERTEX_FORMAT_UBYTE1_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_UINT, - &CopyNativeVertexData<GLubyte, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_UINT, &CopyNativeVertexData<GLubyte, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_UBYTE2_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_UINT, - &CopyNativeVertexData<GLubyte, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_UINT, &CopyNativeVertexData<GLubyte, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_UBYTE3_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UINT, - &CopyNativeVertexData<GLubyte, 3, 4, 1>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UINT, &CopyNativeVertexData<GLubyte, 3, 4, 1>); return info; } case gl::VERTEX_FORMAT_UBYTE4_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_UINT, - &CopyNativeVertexData<GLubyte, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_UINT, &CopyNativeVertexData<GLubyte, 4, 4, 0>); return info; } // GL_SHORT case gl::VERTEX_FORMAT_SSHORT1_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_SINT, - &CopyNativeVertexData<GLshort, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_SINT, &CopyNativeVertexData<GLshort, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_SSHORT2_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_SINT, - &CopyNativeVertexData<GLshort, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_SINT, &CopyNativeVertexData<GLshort, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_SSHORT3_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SINT, - &CopyNativeVertexData<GLshort, 3, 4, 1>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SINT, &CopyNativeVertexData<GLshort, 3, 4, 1>); return info; } case gl::VERTEX_FORMAT_SSHORT4_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_SINT, - &CopyNativeVertexData<GLshort, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_SINT, &CopyNativeVertexData<GLshort, 4, 4, 0>); return info; } // GL_UNSIGNED_SHORT case gl::VERTEX_FORMAT_USHORT1_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_UINT, - &CopyNativeVertexData<GLushort, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_UINT, &CopyNativeVertexData<GLushort, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_USHORT2_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_UINT, - &CopyNativeVertexData<GLushort, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_UINT, &CopyNativeVertexData<GLushort, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_USHORT3_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_UINT, - &CopyNativeVertexData<GLushort, 3, 4, 1>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_UINT, &CopyNativeVertexData<GLushort, 3, 4, 1>); return info; } case gl::VERTEX_FORMAT_USHORT4_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_UINT, - &CopyNativeVertexData<GLushort, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_UINT, &CopyNativeVertexData<GLushort, 4, 4, 0>); return info; } // GL_INT case gl::VERTEX_FORMAT_SINT1_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_SINT, - &CopyNativeVertexData<GLint, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_SINT, &CopyNativeVertexData<GLint, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_SINT2_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_SINT, - &CopyNativeVertexData<GLint, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_SINT, &CopyNativeVertexData<GLint, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_SINT3_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_SINT, - &CopyNativeVertexData<GLint, 3, 3, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_SINT, &CopyNativeVertexData<GLint, 3, 3, 0>); return info; } case gl::VERTEX_FORMAT_SINT4_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_SINT, - &CopyNativeVertexData<GLint, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_SINT, &CopyNativeVertexData<GLint, 4, 4, 0>); return info; } // GL_UNSIGNED_INT case gl::VERTEX_FORMAT_UINT1_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_SINT, - &CopyNativeVertexData<GLuint, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_SINT, &CopyNativeVertexData<GLuint, 1, 1, 0>); return info; } case gl::VERTEX_FORMAT_UINT2_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_SINT, - &CopyNativeVertexData<GLuint, 2, 2, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_SINT, &CopyNativeVertexData<GLuint, 2, 2, 0>); return info; } case gl::VERTEX_FORMAT_UINT3_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_SINT, - &CopyNativeVertexData<GLuint, 3, 3, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_SINT, &CopyNativeVertexData<GLuint, 3, 3, 0>); return info; } case gl::VERTEX_FORMAT_UINT4_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_SINT, - &CopyNativeVertexData<GLuint, 4, 4, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_SINT, &CopyNativeVertexData<GLuint, 4, 4, 0>); return info; } // GL_INT_2_10_10_10_REV case gl::VERTEX_FORMAT_SINT210_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SINT, - &CopyXYZ10W2ToXYZW32FVertexData<true, true, false>); + static const VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SINT, &CopyXYZ10W2ToXYZW32FVertexData<true, true, false>); return info; } // GL_UNSIGNED_INT_2_10_10_10_REV case gl::VERTEX_FORMAT_UINT210_INT: { - static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R10G10B10A2_UINT, - &CopyNativeVertexData<GLuint, 1, 1, 0>); + static const VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R10G10B10A2_UINT, &CopyNativeVertexData<GLuint, 1, 1, 0>); return info; } default: { - static constexpr VertexFormat info; + static const VertexFormat info; return info; } } } -} // namespace d3d11 +} -} // namespace rx +} diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.h index 3a9fd63df..1aa5cc294 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.h @@ -25,11 +25,31 @@ struct Renderer11DeviceCaps; namespace d3d11 { -// A texture might be stored as DXGI_FORMAT_R16_TYPELESS but store integer components, +typedef bool (*NativeMipmapGenerationSupportFunction)(D3D_FEATURE_LEVEL); + +struct DXGIFormat +{ + DXGIFormat(); + + GLuint redBits; + GLuint greenBits; + GLuint blueBits; + GLuint alphaBits; + GLuint sharedBits; + + GLuint depthBits; + GLuint stencilBits; + + GLenum componentType; + + NativeMipmapGenerationSupportFunction nativeMipmapSupport; +}; + +// This structure is problematic because a resource is associated with multiple DXGI formats. +// For example, a texture might be stored as DXGI_FORMAT_R16_TYPELESS but store integer components, // which are accessed through an DXGI_FORMAT_R16_SINT view. It's easy to write code which queries // information about the wrong format. Therefore, use of this should be avoided where possible. - -bool SupportsMipGen(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL featureLevel); +const DXGIFormat &GetDXGIFormatInfo(DXGI_FORMAT format); struct DXGIFormatSize { @@ -41,31 +61,22 @@ struct DXGIFormatSize }; const DXGIFormatSize &GetDXGIFormatSizeInfo(DXGI_FORMAT format); -struct VertexFormat : angle::NonCopyable +struct VertexFormat { - constexpr VertexFormat(); - constexpr VertexFormat(VertexConversionType conversionType, - DXGI_FORMAT nativeFormat, - VertexCopyFunction copyFunction); + VertexFormat(); + VertexFormat(VertexConversionType conversionType, + DXGI_FORMAT nativeFormat, + VertexCopyFunction copyFunction); VertexConversionType conversionType; DXGI_FORMAT nativeFormat; VertexCopyFunction copyFunction; }; - const VertexFormat &GetVertexFormatInfo(gl::VertexFormatType vertexFormatType, D3D_FEATURE_LEVEL featureLevel); -// Auto-generated in dxgi_format_map_autogen.cpp. -GLenum GetComponentType(DXGI_FORMAT dxgiFormat); - } // namespace d3d11 -namespace d3d11_angle -{ -const angle::Format &GetFormat(DXGI_FORMAT dxgiFormat); -} - } // namespace rx #endif // LIBANGLE_RENDERER_D3D_D3D11_FORMATUTILS11_H_ diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/gen_dxgi_format_table.py b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/gen_dxgi_format_table.py deleted file mode 100644 index 6c6d1906a..000000000 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/gen_dxgi_format_table.py +++ /dev/null @@ -1,134 +0,0 @@ -#!/usr/bin/python -# Copyright 2016 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. -# -# gen_dxgi_format_table.py: -# Code generation for DXGI format map. - -from datetime import date -import sys - -sys.path.append('../..') -import angle_format - -template_cpp = """// GENERATED FILE - DO NOT EDIT. -// Generated by {script_name} using data from {data_source_name}. -// -// Copyright {copyright_year} 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. -// -// DXGI format info: -// Determining metadata about a DXGI format. - -#include "libANGLE/renderer/Format.h" - -using namespace angle; - -namespace rx -{{ - -namespace d3d11 -{{ - -GLenum GetComponentType(DXGI_FORMAT dxgiFormat) -{{ - switch (dxgiFormat) - {{ -{component_type_cases} default: - break; - }} - - UNREACHABLE(); - return GL_NONE; -}} - -}} // namespace d3d11 - -namespace d3d11_angle -{{ - -const Format &GetFormat(DXGI_FORMAT dxgiFormat) -{{ - switch (dxgiFormat) - {{ -{format_cases} default: - break; - }} - - UNREACHABLE(); - return Format::Get(Format::ID::NONE); -}} - -}} // namespace d3d11_angle - -}} // namespace rx -""" - -template_format_case = """ case DXGI_FORMAT_{dxgi_format}: - return {result}; -""" - -template_undefined_case = """ case DXGI_FORMAT_{dxgi_format}: - break; -""" - -def format_case(dxgi_format, result): - return template_format_case.format( - dxgi_format = dxgi_format, - result = result) - -def undefined_case(dxgi_format): - return template_undefined_case.format(dxgi_format = dxgi_format) - -component_cases = "" -format_cases = "" - -input_data = 'dxgi_format_data.json' - -dxgi_map = angle_format.load_json(input_data) - -types = { - 'SNORM': 'GL_SIGNED_NORMALIZED', - 'UNORM': 'GL_UNSIGNED_NORMALIZED', - 'SINT': 'GL_INT', - 'UINT': 'GL_UNSIGNED_INT', - 'FLOAT': 'GL_FLOAT', - 'SHAREDEXP': 'GL_FLOAT' -} - -angle_to_gl = angle_format.load_inverse_table('../../angle_format_map.json') -all_angle = angle_to_gl.keys() - -for dxgi_format, angle_format in sorted(dxgi_map.iteritems()): - - found = [ctype in dxgi_format for ctype in types.keys()] - count = reduce((lambda a, b: int(a) + int(b)), found) - - component_type = 'GL_NONE' - - if count == 1: - gltype = next(gltype for ctype, gltype in types.iteritems() if ctype in dxgi_format) - component_cases += format_case(dxgi_format, gltype) - else: - component_cases += undefined_case(dxgi_format) - - if angle_format == "": - angle_format = dxgi_format - - if angle_format in all_angle: - angle_format = "Format::Get(Format::ID::" + angle_format + ")" - format_cases += format_case(dxgi_format, angle_format) - else: - format_cases += undefined_case(dxgi_format) - -with open('dxgi_format_map_autogen.cpp', 'wt') as out_file: - output_cpp = template_cpp.format( - script_name = sys.argv[0], - data_source_name = input_data, - copyright_year = date.today().year, - component_type_cases = component_cases, - format_cases = format_cases) - out_file.write(output_cpp) - out_file.close() diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py index dba583f1e..21b22803b 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py @@ -46,38 +46,25 @@ namespace d3d11 #define {prefix}RT D3D11_FORMAT_SUPPORT_RENDER_TARGET #define {prefix}MS D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET #define {prefix}DS D3D11_FORMAT_SUPPORT_DEPTH_STENCIL -#define {prefix}MIPGEN D3D11_FORMAT_SUPPORT_MIP_AUTOGEN namespace {{ const DXGISupport &GetDefaultSupport() {{ - static UINT AllSupportFlags = - D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_TEXTURE3D | - D3D11_FORMAT_SUPPORT_TEXTURECUBE | D3D11_FORMAT_SUPPORT_SHADER_SAMPLE | - D3D11_FORMAT_SUPPORT_RENDER_TARGET | D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET | - D3D11_FORMAT_SUPPORT_DEPTH_STENCIL | D3D11_FORMAT_SUPPORT_MIP_AUTOGEN; + static UINT AllSupportFlags = D3D11_FORMAT_SUPPORT_TEXTURE2D | + D3D11_FORMAT_SUPPORT_TEXTURE3D | + D3D11_FORMAT_SUPPORT_TEXTURECUBE | + D3D11_FORMAT_SUPPORT_SHADER_SAMPLE | + D3D11_FORMAT_SUPPORT_RENDER_TARGET | + D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET | + D3D11_FORMAT_SUPPORT_DEPTH_STENCIL; static const DXGISupport defaultSupport(0, 0, AllSupportFlags); return defaultSupport; }} -const DXGISupport &GetDXGISupport_9_3(DXGI_FORMAT dxgiFormat) -{{ - // clang-format off - switch (dxgiFormat) - {{ -{table_data_9_3} - default: - UNREACHABLE(); - return GetDefaultSupport(); - }} - // clang-format on -}} - const DXGISupport &GetDXGISupport_10_0(DXGI_FORMAT dxgiFormat) {{ - // clang-format off switch (dxgiFormat) {{ {table_data_10_0} @@ -85,12 +72,10 @@ const DXGISupport &GetDXGISupport_10_0(DXGI_FORMAT dxgiFormat) UNREACHABLE(); return GetDefaultSupport(); }} - // clang-format on }} const DXGISupport &GetDXGISupport_10_1(DXGI_FORMAT dxgiFormat) {{ - // clang-format off switch (dxgiFormat) {{ {table_data_10_1} @@ -98,12 +83,10 @@ const DXGISupport &GetDXGISupport_10_1(DXGI_FORMAT dxgiFormat) UNREACHABLE(); return GetDefaultSupport(); }} - // clang-format on }} const DXGISupport &GetDXGISupport_11_0(DXGI_FORMAT dxgiFormat) {{ - // clang-format off switch (dxgiFormat) {{ {table_data_11_0} @@ -111,7 +94,6 @@ const DXGISupport &GetDXGISupport_11_0(DXGI_FORMAT dxgiFormat) UNREACHABLE(); return GetDefaultSupport(); }} - // clang-format on }} }} @@ -123,14 +105,11 @@ const DXGISupport &GetDXGISupport_11_0(DXGI_FORMAT dxgiFormat) #undef {prefix}RT #undef {prefix}MS #undef {prefix}DS -#undef {prefix}MIPGEN const DXGISupport &GetDXGISupport(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL featureLevel) {{ switch (featureLevel) {{ - case D3D_FEATURE_LEVEL_9_3: - return GetDXGISupport_9_3(dxgiFormat); case D3D_FEATURE_LEVEL_10_0: return GetDXGISupport_10_0(dxgiFormat); case D3D_FEATURE_LEVEL_10_1: @@ -150,7 +129,7 @@ const DXGISupport &GetDXGISupport(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL feat table_init = "" def do_format(format_data): - table_data = {'9_3': '', '10_0': '', '10_1': '', '11_0': ''} + table_data = {'10_0': '', '10_1': '', '11_0': ''} json_flag_to_d3d = { 'texture2D': macro_prefix + '2D', @@ -159,8 +138,7 @@ def do_format(format_data): 'shaderSample': macro_prefix + 'SAMPLE', 'renderTarget': macro_prefix + 'RT', 'multisampleRT': macro_prefix + 'MS', - 'depthStencil': macro_prefix + 'DS', - 'mipAutoGen': macro_prefix + 'MIPGEN' + 'depthStencil': macro_prefix + 'DS' } for format_name, format_support in sorted(format_data.iteritems()): @@ -168,9 +146,6 @@ def do_format(format_data): always_supported = set() never_supported = set() optionally_supported = set() - fl_9_3_supported = set() - fl_9_3_check = set() - fl_10_0_supported = set() fl_10_1_supported = set() fl_11_0_supported = set() fl_11_0_check = set() @@ -188,7 +163,8 @@ def do_format(format_data): elif support == 'never': never_supported.update(d3d_flag) elif support == '10_0': - fl_10_0_supported.update(d3d_flag) + # TODO(jmadill): FL 9_3 handling + always_supported.update(d3d_flag) elif support == '10_1': fl_10_1_supported.update(d3d_flag) elif support == '11_0': @@ -205,33 +181,21 @@ def do_format(format_data): fl_10_0_check_11_0_supported.update(d3d_flag) elif support == '11_0check': fl_11_0_check.update(d3d_flag) - elif support == '9_3always_10_0check11_0always': - fl_9_3_supported.update(d3d_flag) - fl_10_0_check_11_0_supported.update(d3d_flag) - elif support == '9_3check_10_0always': - fl_9_3_check.update(d3d_flag) - fl_10_0_supported.update(d3d_flag) else: print("Data specification error: " + support) sys.exit(1) - for feature_level in ['9_3', '10_0', '10_1', '11_0']: + for feature_level in ['10_0', '10_1', '11_0']: always_for_fl = always_supported optional_for_fl = optionally_supported - if feature_level == '9_3': - always_for_fl = fl_9_3_supported.union(always_for_fl) - optional_for_fl = fl_9_3_check.union(optional_for_fl) - elif feature_level == '10_0': - always_for_fl = fl_10_0_supported.union(always_for_fl) + if feature_level == '10_0': optional_for_fl = fl_10_0_check_10_1_supported.union(optional_for_fl) optional_for_fl = fl_10_0_check_11_0_supported.union(optional_for_fl) - elif feature_level == '10_1': - always_for_fl = fl_10_0_supported.union(always_for_fl) + if feature_level == '10_1': always_for_fl = fl_10_1_supported.union(always_for_fl) always_for_fl = fl_10_0_check_10_1_supported.union(always_for_fl) optional_for_fl = fl_10_0_check_11_0_supported.union(optional_for_fl) elif feature_level == '11_0': - always_for_fl = fl_10_0_supported.union(always_for_fl) always_for_fl = fl_10_0_check_10_1_supported.union(always_for_fl) always_for_fl = fl_10_0_check_11_0_supported.union(always_for_fl) always_for_fl = fl_10_1_supported.union(always_for_fl) @@ -254,8 +218,7 @@ def do_format(format_data): return table_data def join_table_data(table_data_1, table_data_2): - return {'9_3': table_data_1['9_3'] + table_data_2['9_3'], - '10_0': table_data_1['10_0'] + table_data_2['10_0'], + return {'10_0': table_data_1['10_0'] + table_data_2['10_0'], '10_1': table_data_1['10_1'] + table_data_2['10_1'], '11_0': table_data_1['11_0'] + table_data_2['11_0']} @@ -264,13 +227,12 @@ with open('dxgi_support_data.json') as dxgi_file: dxgi_file.close() json_data = json.loads(file_data) - table_data = {'9_3': '', '10_0': '', '10_1': '', '11_0': ''} + table_data = {'10_0': '', '10_1': '', '11_0': ''} for format_data in json_data: table_data = join_table_data(table_data, do_format(format_data)) out_data = template.format(prefix=macro_prefix, - table_data_9_3=table_data['9_3'], table_data_10_0=table_data['10_0'], table_data_10_1=table_data['10_1'], table_data_11_0=table_data['11_0']) diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py index 3c4b228e4..981a77f51 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py @@ -19,7 +19,7 @@ sys.path.append('../..') import angle_format template_texture_format_table_autogen_cpp = """// GENERATED FILE - DO NOT EDIT. -// Generated by {script_name} using data from {data_source_name} +// Generated by gen_texture_format_table.py using data from texture_format_data.json // // Copyright {copyright_year} The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be @@ -60,7 +60,7 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev // clang-format on UNREACHABLE(); - static constexpr Format defaultInfo; + static const Format defaultInfo; return defaultInfo; }} @@ -216,7 +216,23 @@ def get_blit_srv_format(angle_format): format_entry_template = """{space}{{ -{space} static constexpr Format info({internalFormat}, +{space} static const Format info({internalFormat}, +{space} angle::Format::ID::{formatName}, +{space} {texFormat}, +{space} {srvFormat}, +{space} {rtvFormat}, +{space} {dsvFormat}, +{space} {blitSRVFormat}, +{space} {swizzleFormat}, +{space} {initializer}, +{space} deviceCaps); +{space} return info; +{space}}} +""" + +split_format_entry_template = """{space} {condition} +{space} {{ +{space} static const Format info({internalFormat}, {space} angle::Format::ID::{formatName}, {space} {texFormat}, {space} {srvFormat}, @@ -224,22 +240,8 @@ format_entry_template = """{space}{{ {space} {dsvFormat}, {space} {blitSRVFormat}, {space} {swizzleFormat}, -{space} {initializer}); -{space} return info; -{space}}} -""" - -split_format_entry_template = """{space} {condition} -{space} {{ -{space} static constexpr Format info({internalFormat}, -{space} angle::Format::ID::{formatName}, -{space} {texFormat}, -{space} {srvFormat}, -{space} {rtvFormat}, -{space} {dsvFormat}, -{space} {blitSRVFormat}, -{space} {swizzleFormat}, -{space} {initializer}); +{space} {initializer}, +{space} deviceCaps); {space} return info; {space} }} """ @@ -342,19 +344,16 @@ def reject_duplicate_keys(pairs): return found_keys json_map = angle_format.load_with_override(os.path.abspath('texture_format_map.json')) -data_source_name = 'texture_format_data.json' -with open(data_source_name) as texture_format_json_file: +with open('texture_format_data.json') as texture_format_json_file: texture_format_data = texture_format_json_file.read() texture_format_json_file.close() json_data = json.loads(texture_format_data, object_pairs_hook=angle_format.reject_duplicate_keys) angle_format_cases = parse_json_into_switch_angle_format_string(json_map, json_data) output_cpp = template_texture_format_table_autogen_cpp.format( - script_name = sys.argv[0], - copyright_year = date.today().year, - angle_format_info_cases = angle_format_cases, - data_source_name = data_source_name) + copyright_year=date.today().year, + angle_format_info_cases=angle_format_cases) with open('texture_format_table_autogen.cpp', 'wt') as out_file: out_file.write(output_cpp) out_file.close() diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp index 5bb51feca..f7548c4ee 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp @@ -22,13 +22,219 @@ #include "libANGLE/renderer/d3d/d3d11/texture_format_table.h" #include "libANGLE/renderer/d3d/FramebufferD3D.h" #include "libANGLE/renderer/d3d/WorkaroundsD3D.h" -#include "libANGLE/renderer/driver_utils.h" namespace rx { +namespace gl_d3d11 +{ + +D3D11_BLEND ConvertBlendFunc(GLenum glBlend, bool isAlpha) +{ + D3D11_BLEND d3dBlend = D3D11_BLEND_ZERO; + + switch (glBlend) + { + case GL_ZERO: d3dBlend = D3D11_BLEND_ZERO; break; + case GL_ONE: d3dBlend = D3D11_BLEND_ONE; break; + case GL_SRC_COLOR: d3dBlend = (isAlpha ? D3D11_BLEND_SRC_ALPHA : D3D11_BLEND_SRC_COLOR); break; + case GL_ONE_MINUS_SRC_COLOR: d3dBlend = (isAlpha ? D3D11_BLEND_INV_SRC_ALPHA : D3D11_BLEND_INV_SRC_COLOR); break; + case GL_DST_COLOR: d3dBlend = (isAlpha ? D3D11_BLEND_DEST_ALPHA : D3D11_BLEND_DEST_COLOR); break; + case GL_ONE_MINUS_DST_COLOR: d3dBlend = (isAlpha ? D3D11_BLEND_INV_DEST_ALPHA : D3D11_BLEND_INV_DEST_COLOR); break; + case GL_SRC_ALPHA: d3dBlend = D3D11_BLEND_SRC_ALPHA; break; + case GL_ONE_MINUS_SRC_ALPHA: d3dBlend = D3D11_BLEND_INV_SRC_ALPHA; break; + case GL_DST_ALPHA: d3dBlend = D3D11_BLEND_DEST_ALPHA; break; + case GL_ONE_MINUS_DST_ALPHA: d3dBlend = D3D11_BLEND_INV_DEST_ALPHA; break; + case GL_CONSTANT_COLOR: d3dBlend = D3D11_BLEND_BLEND_FACTOR; break; + case GL_ONE_MINUS_CONSTANT_COLOR: d3dBlend = D3D11_BLEND_INV_BLEND_FACTOR; break; + case GL_CONSTANT_ALPHA: d3dBlend = D3D11_BLEND_BLEND_FACTOR; break; + case GL_ONE_MINUS_CONSTANT_ALPHA: d3dBlend = D3D11_BLEND_INV_BLEND_FACTOR; break; + case GL_SRC_ALPHA_SATURATE: d3dBlend = D3D11_BLEND_SRC_ALPHA_SAT; break; + default: UNREACHABLE(); + } + + return d3dBlend; +} + +D3D11_BLEND_OP ConvertBlendOp(GLenum glBlendOp) +{ + D3D11_BLEND_OP d3dBlendOp = D3D11_BLEND_OP_ADD; + + switch (glBlendOp) + { + case GL_FUNC_ADD: d3dBlendOp = D3D11_BLEND_OP_ADD; break; + case GL_FUNC_SUBTRACT: d3dBlendOp = D3D11_BLEND_OP_SUBTRACT; break; + case GL_FUNC_REVERSE_SUBTRACT: d3dBlendOp = D3D11_BLEND_OP_REV_SUBTRACT; break; + case GL_MIN: d3dBlendOp = D3D11_BLEND_OP_MIN; break; + case GL_MAX: d3dBlendOp = D3D11_BLEND_OP_MAX; break; + default: UNREACHABLE(); + } + + return d3dBlendOp; +} + +UINT8 ConvertColorMask(bool red, bool green, bool blue, bool alpha) +{ + UINT8 mask = 0; + if (red) + { + mask |= D3D11_COLOR_WRITE_ENABLE_RED; + } + if (green) + { + mask |= D3D11_COLOR_WRITE_ENABLE_GREEN; + } + if (blue) + { + mask |= D3D11_COLOR_WRITE_ENABLE_BLUE; + } + if (alpha) + { + mask |= D3D11_COLOR_WRITE_ENABLE_ALPHA; + } + return mask; +} + +D3D11_CULL_MODE ConvertCullMode(bool cullEnabled, GLenum cullMode) +{ + D3D11_CULL_MODE cull = D3D11_CULL_NONE; + + if (cullEnabled) + { + switch (cullMode) + { + case GL_FRONT: cull = D3D11_CULL_FRONT; break; + case GL_BACK: cull = D3D11_CULL_BACK; break; + case GL_FRONT_AND_BACK: cull = D3D11_CULL_NONE; break; + default: UNREACHABLE(); + } + } + else + { + cull = D3D11_CULL_NONE; + } + + return cull; +} + +D3D11_COMPARISON_FUNC ConvertComparison(GLenum comparison) +{ + D3D11_COMPARISON_FUNC d3dComp = D3D11_COMPARISON_NEVER; + switch (comparison) + { + case GL_NEVER: d3dComp = D3D11_COMPARISON_NEVER; break; + case GL_ALWAYS: d3dComp = D3D11_COMPARISON_ALWAYS; break; + case GL_LESS: d3dComp = D3D11_COMPARISON_LESS; break; + case GL_LEQUAL: d3dComp = D3D11_COMPARISON_LESS_EQUAL; break; + case GL_EQUAL: d3dComp = D3D11_COMPARISON_EQUAL; break; + case GL_GREATER: d3dComp = D3D11_COMPARISON_GREATER; break; + case GL_GEQUAL: d3dComp = D3D11_COMPARISON_GREATER_EQUAL; break; + case GL_NOTEQUAL: d3dComp = D3D11_COMPARISON_NOT_EQUAL; break; + default: UNREACHABLE(); + } + + return d3dComp; +} + +D3D11_DEPTH_WRITE_MASK ConvertDepthMask(bool depthWriteEnabled) +{ + return depthWriteEnabled ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; +} + +UINT8 ConvertStencilMask(GLuint stencilmask) +{ + return static_cast<UINT8>(stencilmask); +} + +D3D11_STENCIL_OP ConvertStencilOp(GLenum stencilOp) +{ + D3D11_STENCIL_OP d3dStencilOp = D3D11_STENCIL_OP_KEEP; + + switch (stencilOp) + { + case GL_ZERO: d3dStencilOp = D3D11_STENCIL_OP_ZERO; break; + case GL_KEEP: d3dStencilOp = D3D11_STENCIL_OP_KEEP; break; + case GL_REPLACE: d3dStencilOp = D3D11_STENCIL_OP_REPLACE; break; + case GL_INCR: d3dStencilOp = D3D11_STENCIL_OP_INCR_SAT; break; + case GL_DECR: d3dStencilOp = D3D11_STENCIL_OP_DECR_SAT; break; + case GL_INVERT: d3dStencilOp = D3D11_STENCIL_OP_INVERT; break; + case GL_INCR_WRAP: d3dStencilOp = D3D11_STENCIL_OP_INCR; break; + case GL_DECR_WRAP: d3dStencilOp = D3D11_STENCIL_OP_DECR; break; + default: UNREACHABLE(); + } + + return d3dStencilOp; +} + +D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy, GLenum comparisonMode) +{ + bool comparison = comparisonMode != GL_NONE; + + if (maxAnisotropy > 1.0f) + { + return D3D11_ENCODE_ANISOTROPIC_FILTER(static_cast<D3D11_COMPARISON_FUNC>(comparison)); + } + else + { + D3D11_FILTER_TYPE dxMin = D3D11_FILTER_TYPE_POINT; + D3D11_FILTER_TYPE dxMip = D3D11_FILTER_TYPE_POINT; + switch (minFilter) + { + case GL_NEAREST: dxMin = D3D11_FILTER_TYPE_POINT; dxMip = D3D11_FILTER_TYPE_POINT; break; + case GL_LINEAR: dxMin = D3D11_FILTER_TYPE_LINEAR; dxMip = D3D11_FILTER_TYPE_POINT; break; + case GL_NEAREST_MIPMAP_NEAREST: dxMin = D3D11_FILTER_TYPE_POINT; dxMip = D3D11_FILTER_TYPE_POINT; break; + case GL_LINEAR_MIPMAP_NEAREST: dxMin = D3D11_FILTER_TYPE_LINEAR; dxMip = D3D11_FILTER_TYPE_POINT; break; + case GL_NEAREST_MIPMAP_LINEAR: dxMin = D3D11_FILTER_TYPE_POINT; dxMip = D3D11_FILTER_TYPE_LINEAR; break; + case GL_LINEAR_MIPMAP_LINEAR: dxMin = D3D11_FILTER_TYPE_LINEAR; dxMip = D3D11_FILTER_TYPE_LINEAR; break; + default: UNREACHABLE(); + } + + D3D11_FILTER_TYPE dxMag = D3D11_FILTER_TYPE_POINT; + switch (magFilter) + { + case GL_NEAREST: dxMag = D3D11_FILTER_TYPE_POINT; break; + case GL_LINEAR: dxMag = D3D11_FILTER_TYPE_LINEAR; break; + default: UNREACHABLE(); + } + + return D3D11_ENCODE_BASIC_FILTER(dxMin, dxMag, dxMip, static_cast<D3D11_COMPARISON_FUNC>(comparison)); + } +} + +D3D11_TEXTURE_ADDRESS_MODE ConvertTextureWrap(GLenum wrap) +{ + switch (wrap) + { + case GL_REPEAT: return D3D11_TEXTURE_ADDRESS_WRAP; + case GL_CLAMP_TO_EDGE: return D3D11_TEXTURE_ADDRESS_CLAMP; + case GL_MIRRORED_REPEAT: return D3D11_TEXTURE_ADDRESS_MIRROR; + default: UNREACHABLE(); + } + + return D3D11_TEXTURE_ADDRESS_WRAP; +} + +D3D11_QUERY ConvertQueryType(GLenum queryType) +{ + switch (queryType) + { + case GL_ANY_SAMPLES_PASSED_EXT: + case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: return D3D11_QUERY_OCCLUSION; + case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: return D3D11_QUERY_SO_STATISTICS; + case GL_TIME_ELAPSED_EXT: + // Two internal queries are also created for begin/end timestamps + return D3D11_QUERY_TIMESTAMP_DISJOINT; + case GL_COMMANDS_COMPLETED_CHROMIUM: + return D3D11_QUERY_EVENT; + default: UNREACHABLE(); return D3D11_QUERY_EVENT; + } +} + +} // namespace gl_d3d11 + namespace d3d11_gl { + namespace { @@ -37,7 +243,8 @@ class DXGISupportHelper : angle::NonCopyable { public: DXGISupportHelper(ID3D11Device *device, D3D_FEATURE_LEVEL featureLevel) - : mDevice(device), mFeatureLevel(featureLevel) + : mDevice(device), + mFeatureLevel(featureLevel) { } @@ -72,10 +279,72 @@ class DXGISupportHelper : angle::NonCopyable D3D_FEATURE_LEVEL mFeatureLevel; }; -gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, - GLenum internalFormat, - ID3D11Device *device, - const Renderer11DeviceCaps &renderer11DeviceCaps) +} // anonymous namespace + +unsigned int GetReservedVertexUniformVectors(D3D_FEATURE_LEVEL featureLevel) +{ + switch (featureLevel) + { + 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 0; + + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: + return 3; // dx_ViewAdjust, dx_ViewCoords and dx_ViewScale + + default: + UNREACHABLE(); + return 0; + } +} + +unsigned int GetReservedFragmentUniformVectors(D3D_FEATURE_LEVEL featureLevel) +{ + switch (featureLevel) + { + 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 0; + + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: + return 3; + + default: + UNREACHABLE(); + return 0; + } +} + +GLint GetMaximumClientVersion(D3D_FEATURE_LEVEL featureLevel) +{ + switch (featureLevel) + { + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: + case D3D_FEATURE_LEVEL_10_1: + return 3; + + case D3D_FEATURE_LEVEL_10_0: + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: + return 2; + + default: + UNREACHABLE(); + return 0; + } +} + +static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum internalFormat, ID3D11Device *device, const Renderer11DeviceCaps &renderer11DeviceCaps) { gl::TextureCaps textureCaps; @@ -136,911 +405,661 @@ gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, return textureCaps; } -bool GetNPOTTextureSupport(D3D_FEATURE_LEVEL featureLevel) +static bool GetNPOTTextureSupport(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - 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_11_1: + case D3D_FEATURE_LEVEL_11_0: + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return true; // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876.aspx - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return false; + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return false; - default: - UNREACHABLE(); - return false; + default: UNREACHABLE(); return false; } } -float GetMaximumAnisotropy(D3D_FEATURE_LEVEL featureLevel) +static float GetMaximumAnisotropy(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_MAX_MAXANISOTROPY; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_MAX_MAXANISOTROPY; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_MAX_MAXANISOTROPY; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_MAX_MAXANISOTROPY; // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876.aspx - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - return 16; + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: return 16; - case D3D_FEATURE_LEVEL_9_1: - return D3D_FL9_1_DEFAULT_MAX_ANISOTROPY; + case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_DEFAULT_MAX_ANISOTROPY; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -bool GetOcclusionQuerySupport(D3D_FEATURE_LEVEL featureLevel) +static bool GetOcclusionQuerySupport(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - 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_11_1: + case D3D_FEATURE_LEVEL_11_0: + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return true; - // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx - // ID3D11Device::CreateQuery - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - return true; - case D3D_FEATURE_LEVEL_9_1: - return false; + // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx ID3D11Device::CreateQuery + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: return true; + case D3D_FEATURE_LEVEL_9_1: return false; - default: - UNREACHABLE(); - return false; + default: UNREACHABLE(); return false; } } -bool GetEventQuerySupport(D3D_FEATURE_LEVEL featureLevel) +static bool GetEventQuerySupport(D3D_FEATURE_LEVEL featureLevel) { - // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx - // ID3D11Device::CreateQuery + // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx ID3D11Device::CreateQuery switch (featureLevel) { - 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: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return true; + 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: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return true; - default: - UNREACHABLE(); - return false; + default: UNREACHABLE(); return false; } } -bool GetInstancingSupport(D3D_FEATURE_LEVEL featureLevel) +static bool GetInstancingSupport(D3D_FEATURE_LEVEL featureLevel) { - // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx - // ID3D11Device::CreateInputLayout + // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx ID3D11Device::CreateInputLayout switch (featureLevel) { - 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; - - // Feature Level 9_3 supports instancing, but slot 0 in the input layout must not be - // instanced. - // D3D9 has a similar restriction, where stream 0 must not be instanced. - // This restriction can be worked around by remapping any non-instanced slot to slot - // 0. - // This works because HLSL uses shader semantics to match the vertex inputs to the - // elements in the input layout, rather than the slots. - // Note that we only support instancing via ANGLE_instanced_array on 9_3, since 9_3 - // doesn't support OpenGL ES 3.0 - case D3D_FEATURE_LEVEL_9_3: - return true; + 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_2: - case D3D_FEATURE_LEVEL_9_1: - return false; + // Feature Level 9_3 supports instancing, but slot 0 in the input layout must not be instanced. + // D3D9 has a similar restriction, where stream 0 must not be instanced. + // This restriction can be worked around by remapping any non-instanced slot to slot 0. + // This works because HLSL uses shader semantics to match the vertex inputs to the elements in the input layout, rather than the slots. + // Note that we only support instancing via ANGLE_instanced_array on 9_3, since 9_3 doesn't support OpenGL ES 3.0 + case D3D_FEATURE_LEVEL_9_3: return true; - default: - UNREACHABLE(); - return false; + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return false; + + default: UNREACHABLE(); return false; } } -bool GetFramebufferMultisampleSupport(D3D_FEATURE_LEVEL featureLevel) +static bool GetFramebufferMultisampleSupport(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - 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_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: - case D3D_FEATURE_LEVEL_9_1: - return false; + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return false; - default: - UNREACHABLE(); - return false; + default: UNREACHABLE(); return false; } } -bool GetFramebufferBlitSupport(D3D_FEATURE_LEVEL featureLevel) +static bool GetFramebufferBlitSupport(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - 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_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: - case D3D_FEATURE_LEVEL_9_1: - return false; + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return false; - default: - UNREACHABLE(); - return false; + default: UNREACHABLE(); return false; } } -bool GetDerivativeInstructionSupport(D3D_FEATURE_LEVEL featureLevel) +static bool GetDerivativeInstructionSupport(D3D_FEATURE_LEVEL featureLevel) { - // http://msdn.microsoft.com/en-us/library/windows/desktop/bb509588.aspx states that - // shader model + // http://msdn.microsoft.com/en-us/library/windows/desktop/bb509588.aspx states that shader model // ps_2_x is required for the ddx (and other derivative functions). - // http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876.aspx states that - // feature level + // http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876.aspx states that feature level // 9.3 supports shader model ps_2_x. switch (featureLevel) { - 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; - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return false; + 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; + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return false; - default: - UNREACHABLE(); - return false; + default: UNREACHABLE(); return false; } } -bool GetShaderTextureLODSupport(D3D_FEATURE_LEVEL featureLevel) +static bool GetShaderTextureLODSupport(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - 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_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: - case D3D_FEATURE_LEVEL_9_1: - return false; + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return false; - default: - UNREACHABLE(); - return false; + default: UNREACHABLE(); return false; } } -size_t GetMaximumSimultaneousRenderTargets(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumSimultaneousRenderTargets(D3D_FEATURE_LEVEL featureLevel) { - // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx - // ID3D11Device::CreateInputLayout + // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx ID3D11Device::CreateInputLayout switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; - case D3D_FEATURE_LEVEL_9_3: - return D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT; - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return D3D_FL9_1_SIMULTANEOUS_RENDER_TARGET_COUNT; + case D3D_FEATURE_LEVEL_9_3: return D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT; + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_SIMULTANEOUS_RENDER_TARGET_COUNT; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximum2DTextureSize(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximum2DTextureSize(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION; - case D3D_FEATURE_LEVEL_9_3: - return D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION; - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION; + case D3D_FEATURE_LEVEL_9_3: return D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION; + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumCubeMapTextureSize(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumCubeMapTextureSize(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_REQ_TEXTURECUBE_DIMENSION; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURECUBE_DIMENSION; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_REQ_TEXTURECUBE_DIMENSION; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURECUBE_DIMENSION; - case D3D_FEATURE_LEVEL_9_3: - return D3D_FL9_3_REQ_TEXTURECUBE_DIMENSION; - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return D3D_FL9_1_REQ_TEXTURECUBE_DIMENSION; + case D3D_FEATURE_LEVEL_9_3: return D3D_FL9_3_REQ_TEXTURECUBE_DIMENSION; + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_REQ_TEXTURECUBE_DIMENSION; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximum2DTextureArraySize(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximum2DTextureArraySize(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION; - 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_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 0; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximum3DTextureSize(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximum3DTextureSize(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION; - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION; + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumViewportSize(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumViewportSize(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_VIEWPORT_BOUNDS_MAX; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_VIEWPORT_BOUNDS_MAX; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_VIEWPORT_BOUNDS_MAX; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_VIEWPORT_BOUNDS_MAX; - // No constants for D3D11 Feature Level 9 viewport size limits, use the maximum - // texture sizes - case D3D_FEATURE_LEVEL_9_3: - return D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION; - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION; + // No constants for D3D11 Feature Level 9 viewport size limits, use the maximum texture sizes + case D3D_FEATURE_LEVEL_9_3: return D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION; + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumDrawIndexedIndexCount(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumDrawIndexedIndexCount(D3D_FEATURE_LEVEL featureLevel) { - // D3D11 allows up to 2^32 elements, but we report max signed int for convenience since - // that's what's + // D3D11 allows up to 2^32 elements, but we report max signed int for convenience since that's what's // returned from glGetInteger - static_assert(D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP == 32, - "Unexpected D3D11 constant value."); - static_assert(D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP == 32, - "Unexpected D3D11 constant value."); + static_assert(D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP == 32, "Unexpected D3D11 constant value."); + static_assert(D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP == 32, "Unexpected D3D11 constant value."); switch (featureLevel) { - 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 std::numeric_limits<GLint>::max(); + 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 std::numeric_limits<GLint>::max(); - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - return D3D_FL9_2_IA_PRIMITIVE_MAX_COUNT; - case D3D_FEATURE_LEVEL_9_1: - return D3D_FL9_1_IA_PRIMITIVE_MAX_COUNT; + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: return D3D_FL9_2_IA_PRIMITIVE_MAX_COUNT; + case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_IA_PRIMITIVE_MAX_COUNT; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumDrawVertexCount(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumDrawVertexCount(D3D_FEATURE_LEVEL featureLevel) { - // D3D11 allows up to 2^32 elements, but we report max signed int for convenience since - // that's what's + // D3D11 allows up to 2^32 elements, but we report max signed int for convenience since that's what's // returned from glGetInteger static_assert(D3D11_REQ_DRAW_VERTEX_COUNT_2_TO_EXP == 32, "Unexpected D3D11 constant value."); static_assert(D3D10_REQ_DRAW_VERTEX_COUNT_2_TO_EXP == 32, "Unexpected D3D11 constant value."); switch (featureLevel) { - 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 std::numeric_limits<GLint>::max(); + 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 std::numeric_limits<GLint>::max(); - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - return D3D_FL9_2_IA_PRIMITIVE_MAX_COUNT; - case D3D_FEATURE_LEVEL_9_1: - return D3D_FL9_1_IA_PRIMITIVE_MAX_COUNT; + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: return D3D_FL9_2_IA_PRIMITIVE_MAX_COUNT; + case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_IA_PRIMITIVE_MAX_COUNT; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumVertexInputSlots(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumVertexInputSlots(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_STANDARD_VERTEX_ELEMENT_COUNT; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_STANDARD_VERTEX_ELEMENT_COUNT; - case D3D_FEATURE_LEVEL_10_1: - return D3D10_1_STANDARD_VERTEX_ELEMENT_COUNT; - case D3D_FEATURE_LEVEL_10_0: - return D3D10_STANDARD_VERTEX_ELEMENT_COUNT; + case D3D_FEATURE_LEVEL_10_1: return D3D10_1_STANDARD_VERTEX_ELEMENT_COUNT; + case D3D_FEATURE_LEVEL_10_0: return D3D10_STANDARD_VERTEX_ELEMENT_COUNT; - // From http://http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876.aspx - // "Max Input Slots" - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 16; + // From http://http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876.aspx "Max Input Slots" + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 16; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumVertexUniformVectors(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumVertexUniformVectors(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT; - // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476149.aspx - // ID3D11DeviceContext::VSSetConstantBuffers - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 255 - d3d11_gl::GetReservedVertexUniformVectors(featureLevel); + // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476149.aspx ID3D11DeviceContext::VSSetConstantBuffers + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: + return 255 - d3d11_gl::GetReservedVertexUniformVectors(featureLevel); - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumVertexUniformBlocks(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumVertexUniformBlocks(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - - d3d11::RESERVED_CONSTANT_BUFFER_SLOT_COUNT; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: + return D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - + d3d11::RESERVED_CONSTANT_BUFFER_SLOT_COUNT; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - - d3d11::RESERVED_CONSTANT_BUFFER_SLOT_COUNT; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: + return D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - + d3d11::RESERVED_CONSTANT_BUFFER_SLOT_COUNT; - // Uniform blocks not supported on D3D11 Feature Level 9 - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 0; + // Uniform blocks not supported on D3D11 Feature Level 9 + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 0; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetReservedVertexOutputVectors(D3D_FEATURE_LEVEL featureLevel) +static size_t GetReservedVertexOutputVectors(D3D_FEATURE_LEVEL featureLevel) { // According to The OpenGL ES Shading Language specifications // (Language Version 1.00 section 10.16, Language Version 3.10 section 12.21) // built-in special variables (e.g. gl_FragCoord, or gl_PointCoord) - // which are statically used in the shader should be included in the variable packing - // algorithm. + // which are statically used in the shader should be included in the variable packing algorithm. // Therefore, we should not reserve output vectors for them. switch (featureLevel) { - // We must reserve one output vector for dx_Position. - // We also reserve one for gl_Position, which we unconditionally output on Feature - // Levels 10_0+, - // even if it's unused in the shader (e.g. for transform feedback). TODO: This could - // be improved. - 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 2; + // We must reserve one output vector for dx_Position. + // We also reserve one for gl_Position, which we unconditionally output on Feature Levels 10_0+, + // even if it's unused in the shader (e.g. for transform feedback). TODO: This could be improved. + 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 2; - // Just reserve dx_Position on Feature Level 9, since we don't ever need to output - // gl_Position. - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 1; + // Just reserve dx_Position on Feature Level 9, since we don't ever need to output gl_Position. + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 1; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumVertexOutputVectors(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumVertexOutputVectors(D3D_FEATURE_LEVEL featureLevel) { - static_assert(gl::IMPLEMENTATION_MAX_VARYING_VECTORS == D3D11_VS_OUTPUT_REGISTER_COUNT, - "Unexpected D3D11 constant value."); + static_assert(gl::IMPLEMENTATION_MAX_VARYING_VECTORS == D3D11_VS_OUTPUT_REGISTER_COUNT, "Unexpected D3D11 constant value."); switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_VS_OUTPUT_REGISTER_COUNT - GetReservedVertexOutputVectors(featureLevel); + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_VS_OUTPUT_REGISTER_COUNT - GetReservedVertexOutputVectors(featureLevel); - case D3D_FEATURE_LEVEL_10_1: - return D3D10_1_VS_OUTPUT_REGISTER_COUNT - GetReservedVertexOutputVectors(featureLevel); - case D3D_FEATURE_LEVEL_10_0: - return D3D10_VS_OUTPUT_REGISTER_COUNT - GetReservedVertexOutputVectors(featureLevel); + case D3D_FEATURE_LEVEL_10_1: return D3D10_1_VS_OUTPUT_REGISTER_COUNT - GetReservedVertexOutputVectors(featureLevel); + case D3D_FEATURE_LEVEL_10_0: return D3D10_VS_OUTPUT_REGISTER_COUNT - GetReservedVertexOutputVectors(featureLevel); - // Use Shader Model 2.X limits - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 8 - GetReservedVertexOutputVectors(featureLevel); + // Use Shader Model 2.X limits + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 8 - GetReservedVertexOutputVectors(featureLevel); - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumVertexTextureUnits(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumVertexTextureUnits(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; - // Vertex textures not supported on D3D11 Feature Level 9 according to - // http://msdn.microsoft.com/en-us/library/windows/desktop/ff476149.aspx - // ID3D11DeviceContext::VSSetSamplers and ID3D11DeviceContext::VSSetShaderResources - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 0; + // Vertex textures not supported on D3D11 Feature Level 9 according to + // http://msdn.microsoft.com/en-us/library/windows/desktop/ff476149.aspx + // ID3D11DeviceContext::VSSetSamplers and ID3D11DeviceContext::VSSetShaderResources + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 0; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumPixelUniformVectors(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumPixelUniformVectors(D3D_FEATURE_LEVEL featureLevel) { // TODO(geofflang): Remove hard-coded limit once the gl-uniform-arrays test can pass switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return 1024; // D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return 1024; // D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return 1024; // D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return 1024; // D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT; - // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476149.aspx - // ID3D11DeviceContext::PSSetConstantBuffers - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 32 - d3d11_gl::GetReservedFragmentUniformVectors(featureLevel); + // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476149.aspx ID3D11DeviceContext::PSSetConstantBuffers + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: + return 32 - d3d11_gl::GetReservedFragmentUniformVectors(featureLevel); - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumPixelUniformBlocks(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumPixelUniformBlocks(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - - d3d11::RESERVED_CONSTANT_BUFFER_SLOT_COUNT; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: + return D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - + d3d11::RESERVED_CONSTANT_BUFFER_SLOT_COUNT; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - - d3d11::RESERVED_CONSTANT_BUFFER_SLOT_COUNT; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: + return D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - + d3d11::RESERVED_CONSTANT_BUFFER_SLOT_COUNT; - // Uniform blocks not supported on D3D11 Feature Level 9 - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 0; + // Uniform blocks not supported on D3D11 Feature Level 9 + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 0; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumPixelInputVectors(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumPixelInputVectors(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_PS_INPUT_REGISTER_COUNT - GetReservedVertexOutputVectors(featureLevel); + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_PS_INPUT_REGISTER_COUNT - GetReservedVertexOutputVectors(featureLevel); - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_PS_INPUT_REGISTER_COUNT - GetReservedVertexOutputVectors(featureLevel); + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_PS_INPUT_REGISTER_COUNT - GetReservedVertexOutputVectors(featureLevel); - // Use Shader Model 2.X limits - case D3D_FEATURE_LEVEL_9_3: - return 8 - GetReservedVertexOutputVectors(featureLevel); - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 8 - GetReservedVertexOutputVectors(featureLevel); + // Use Shader Model 2.X limits + case D3D_FEATURE_LEVEL_9_3: return 8 - GetReservedVertexOutputVectors(featureLevel); + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 8 - GetReservedVertexOutputVectors(featureLevel); - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumPixelTextureUnits(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumPixelTextureUnits(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; - // http://msdn.microsoft.com/en-us/library/windows/desktop/ff476149.aspx - // ID3D11DeviceContext::PSSetShaderResources - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 16; + // http://msdn.microsoft.com/en-us/library/windows/desktop/ff476149.aspx ID3D11DeviceContext::PSSetShaderResources + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 16; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -int GetMinimumTexelOffset(D3D_FEATURE_LEVEL featureLevel) +static int GetMinimumTexelOffset(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE; - // Sampling functions with offsets are not available below shader model 4.0. - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 0; + // Sampling functions with offsets are not available below shader model 4.0. + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 0; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -int GetMaximumTexelOffset(D3D_FEATURE_LEVEL featureLevel) +static int GetMaximumTexelOffset(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE; - // Sampling functions with offsets are not available below shader model 4.0. - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 0; + // Sampling functions with offsets are not available below shader model 4.0. + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 0; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumConstantBufferSize(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumConstantBufferSize(D3D_FEATURE_LEVEL featureLevel) { - // Returns a size_t despite the limit being a GLuint64 because size_t is the maximum - // size of + // Returns a size_t despite the limit being a GLuint64 because size_t is the maximum size of // any buffer that could be allocated. const size_t bytesPerComponent = 4 * sizeof(float); switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * bytesPerComponent; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * bytesPerComponent; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * bytesPerComponent; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * bytesPerComponent; - // Limits from http://msdn.microsoft.com/en-us/library/windows/desktop/ff476501.aspx - // remarks section - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 4096 * bytesPerComponent; + // Limits from http://msdn.microsoft.com/en-us/library/windows/desktop/ff476501.aspx remarks section + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 4096 * bytesPerComponent; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumStreamOutputBuffers(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumStreamOutputBuffers(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return D3D11_SO_BUFFER_SLOT_COUNT; + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return D3D11_SO_BUFFER_SLOT_COUNT; - case D3D_FEATURE_LEVEL_10_1: - return D3D10_1_SO_BUFFER_SLOT_COUNT; - case D3D_FEATURE_LEVEL_10_0: - return D3D10_SO_BUFFER_SLOT_COUNT; + case D3D_FEATURE_LEVEL_10_1: return D3D10_1_SO_BUFFER_SLOT_COUNT; + case D3D_FEATURE_LEVEL_10_0: return D3D10_SO_BUFFER_SLOT_COUNT; - 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_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 0; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumStreamOutputInterleavedComponents(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumStreamOutputInterleavedComponents(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: + 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 GetMaximumVertexOutputVectors(featureLevel) * 4; + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return GetMaximumVertexOutputVectors(featureLevel) * 4; - 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_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 0; - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } -size_t GetMaximumStreamOutputSeparateComponents(D3D_FEATURE_LEVEL featureLevel) +static size_t GetMaximumStreamOutputSeparateComponents(D3D_FEATURE_LEVEL featureLevel) { switch (featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return GetMaximumStreamOutputInterleavedComponents(featureLevel) / - GetMaximumStreamOutputBuffers(featureLevel); - - // D3D 10 and 10.1 only allow one output per output slot if an output slot other - // than zero is used. - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return 4; - - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 0; - - default: - UNREACHABLE(); - return 0; - } -} + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: return GetMaximumStreamOutputInterleavedComponents(featureLevel) / + GetMaximumStreamOutputBuffers(featureLevel); -} // anonymous namespace -unsigned int GetReservedVertexUniformVectors(D3D_FEATURE_LEVEL featureLevel) -{ - switch (featureLevel) - { - 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 0; + // D3D 10 and 10.1 only allow one output per output slot if an output slot other than zero is used. + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return 4; - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 3; // dx_ViewAdjust, dx_ViewCoords and dx_ViewScale + case D3D_FEATURE_LEVEL_9_3: + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: return 0; - default: - UNREACHABLE(); - return 0; - } -} - -unsigned int GetReservedFragmentUniformVectors(D3D_FEATURE_LEVEL featureLevel) -{ - switch (featureLevel) - { - 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 0; - - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 3; - - default: - UNREACHABLE(); - return 0; - } -} - -GLint GetMaximumClientVersion(D3D_FEATURE_LEVEL featureLevel) -{ - switch (featureLevel) - { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - case D3D_FEATURE_LEVEL_10_1: - return 3; - - case D3D_FEATURE_LEVEL_10_0: - case D3D_FEATURE_LEVEL_9_3: - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 2; - - default: - UNREACHABLE(); - return 0; + default: UNREACHABLE(); return 0; } } @@ -1220,7 +1239,6 @@ void GenerateCaps(ID3D11Device *device, ID3D11DeviceContext *deviceContext, cons extensions->lossyETCDecode = true; extensions->syncQuery = GetEventQuerySupport(featureLevel); extensions->copyTexture = true; - extensions->copyCompressedTexture = true; // D3D11 Feature Level 10_0+ uses SV_IsFrontFace in HLSL to emulate gl_FrontFacing. // D3D11 Feature Level 9_3 doesn't support SV_IsFrontFace, and has no equivalent, so can't support gl_FrontFacing. @@ -1252,336 +1270,6 @@ void GenerateCaps(ID3D11Device *device, ID3D11DeviceContext *deviceContext, cons } // namespace d3d11_gl -namespace gl_d3d11 -{ - -D3D11_BLEND ConvertBlendFunc(GLenum glBlend, bool isAlpha) -{ - D3D11_BLEND d3dBlend = D3D11_BLEND_ZERO; - - switch (glBlend) - { - case GL_ZERO: - d3dBlend = D3D11_BLEND_ZERO; - break; - case GL_ONE: - d3dBlend = D3D11_BLEND_ONE; - break; - case GL_SRC_COLOR: - d3dBlend = (isAlpha ? D3D11_BLEND_SRC_ALPHA : D3D11_BLEND_SRC_COLOR); - break; - case GL_ONE_MINUS_SRC_COLOR: - d3dBlend = (isAlpha ? D3D11_BLEND_INV_SRC_ALPHA : D3D11_BLEND_INV_SRC_COLOR); - break; - case GL_DST_COLOR: - d3dBlend = (isAlpha ? D3D11_BLEND_DEST_ALPHA : D3D11_BLEND_DEST_COLOR); - break; - case GL_ONE_MINUS_DST_COLOR: - d3dBlend = (isAlpha ? D3D11_BLEND_INV_DEST_ALPHA : D3D11_BLEND_INV_DEST_COLOR); - break; - case GL_SRC_ALPHA: - d3dBlend = D3D11_BLEND_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - d3dBlend = D3D11_BLEND_INV_SRC_ALPHA; - break; - case GL_DST_ALPHA: - d3dBlend = D3D11_BLEND_DEST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - d3dBlend = D3D11_BLEND_INV_DEST_ALPHA; - break; - case GL_CONSTANT_COLOR: - d3dBlend = D3D11_BLEND_BLEND_FACTOR; - break; - case GL_ONE_MINUS_CONSTANT_COLOR: - d3dBlend = D3D11_BLEND_INV_BLEND_FACTOR; - break; - case GL_CONSTANT_ALPHA: - d3dBlend = D3D11_BLEND_BLEND_FACTOR; - break; - case GL_ONE_MINUS_CONSTANT_ALPHA: - d3dBlend = D3D11_BLEND_INV_BLEND_FACTOR; - break; - case GL_SRC_ALPHA_SATURATE: - d3dBlend = D3D11_BLEND_SRC_ALPHA_SAT; - break; - default: - UNREACHABLE(); - } - - return d3dBlend; -} - -D3D11_BLEND_OP ConvertBlendOp(GLenum glBlendOp) -{ - D3D11_BLEND_OP d3dBlendOp = D3D11_BLEND_OP_ADD; - - switch (glBlendOp) - { - case GL_FUNC_ADD: - d3dBlendOp = D3D11_BLEND_OP_ADD; - break; - case GL_FUNC_SUBTRACT: - d3dBlendOp = D3D11_BLEND_OP_SUBTRACT; - break; - case GL_FUNC_REVERSE_SUBTRACT: - d3dBlendOp = D3D11_BLEND_OP_REV_SUBTRACT; - break; - case GL_MIN: - d3dBlendOp = D3D11_BLEND_OP_MIN; - break; - case GL_MAX: - d3dBlendOp = D3D11_BLEND_OP_MAX; - break; - default: - UNREACHABLE(); - } - - return d3dBlendOp; -} - -UINT8 ConvertColorMask(bool red, bool green, bool blue, bool alpha) -{ - UINT8 mask = 0; - if (red) - { - mask |= D3D11_COLOR_WRITE_ENABLE_RED; - } - if (green) - { - mask |= D3D11_COLOR_WRITE_ENABLE_GREEN; - } - if (blue) - { - mask |= D3D11_COLOR_WRITE_ENABLE_BLUE; - } - if (alpha) - { - mask |= D3D11_COLOR_WRITE_ENABLE_ALPHA; - } - return mask; -} - -D3D11_CULL_MODE ConvertCullMode(bool cullEnabled, GLenum cullMode) -{ - D3D11_CULL_MODE cull = D3D11_CULL_NONE; - - if (cullEnabled) - { - switch (cullMode) - { - case GL_FRONT: - cull = D3D11_CULL_FRONT; - break; - case GL_BACK: - cull = D3D11_CULL_BACK; - break; - case GL_FRONT_AND_BACK: - cull = D3D11_CULL_NONE; - break; - default: - UNREACHABLE(); - } - } - else - { - cull = D3D11_CULL_NONE; - } - - return cull; -} - -D3D11_COMPARISON_FUNC ConvertComparison(GLenum comparison) -{ - D3D11_COMPARISON_FUNC d3dComp = D3D11_COMPARISON_NEVER; - switch (comparison) - { - case GL_NEVER: - d3dComp = D3D11_COMPARISON_NEVER; - break; - case GL_ALWAYS: - d3dComp = D3D11_COMPARISON_ALWAYS; - break; - case GL_LESS: - d3dComp = D3D11_COMPARISON_LESS; - break; - case GL_LEQUAL: - d3dComp = D3D11_COMPARISON_LESS_EQUAL; - break; - case GL_EQUAL: - d3dComp = D3D11_COMPARISON_EQUAL; - break; - case GL_GREATER: - d3dComp = D3D11_COMPARISON_GREATER; - break; - case GL_GEQUAL: - d3dComp = D3D11_COMPARISON_GREATER_EQUAL; - break; - case GL_NOTEQUAL: - d3dComp = D3D11_COMPARISON_NOT_EQUAL; - break; - default: - UNREACHABLE(); - } - - return d3dComp; -} - -D3D11_DEPTH_WRITE_MASK ConvertDepthMask(bool depthWriteEnabled) -{ - return depthWriteEnabled ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; -} - -UINT8 ConvertStencilMask(GLuint stencilmask) -{ - return static_cast<UINT8>(stencilmask); -} - -D3D11_STENCIL_OP ConvertStencilOp(GLenum stencilOp) -{ - D3D11_STENCIL_OP d3dStencilOp = D3D11_STENCIL_OP_KEEP; - - switch (stencilOp) - { - case GL_ZERO: - d3dStencilOp = D3D11_STENCIL_OP_ZERO; - break; - case GL_KEEP: - d3dStencilOp = D3D11_STENCIL_OP_KEEP; - break; - case GL_REPLACE: - d3dStencilOp = D3D11_STENCIL_OP_REPLACE; - break; - case GL_INCR: - d3dStencilOp = D3D11_STENCIL_OP_INCR_SAT; - break; - case GL_DECR: - d3dStencilOp = D3D11_STENCIL_OP_DECR_SAT; - break; - case GL_INVERT: - d3dStencilOp = D3D11_STENCIL_OP_INVERT; - break; - case GL_INCR_WRAP: - d3dStencilOp = D3D11_STENCIL_OP_INCR; - break; - case GL_DECR_WRAP: - d3dStencilOp = D3D11_STENCIL_OP_DECR; - break; - default: - UNREACHABLE(); - } - - return d3dStencilOp; -} - -D3D11_FILTER ConvertFilter(GLenum minFilter, - GLenum magFilter, - float maxAnisotropy, - GLenum comparisonMode) -{ - bool comparison = comparisonMode != GL_NONE; - - if (maxAnisotropy > 1.0f) - { - return D3D11_ENCODE_ANISOTROPIC_FILTER(static_cast<D3D11_COMPARISON_FUNC>(comparison)); - } - else - { - D3D11_FILTER_TYPE dxMin = D3D11_FILTER_TYPE_POINT; - D3D11_FILTER_TYPE dxMip = D3D11_FILTER_TYPE_POINT; - switch (minFilter) - { - case GL_NEAREST: - dxMin = D3D11_FILTER_TYPE_POINT; - dxMip = D3D11_FILTER_TYPE_POINT; - break; - case GL_LINEAR: - dxMin = D3D11_FILTER_TYPE_LINEAR; - dxMip = D3D11_FILTER_TYPE_POINT; - break; - case GL_NEAREST_MIPMAP_NEAREST: - dxMin = D3D11_FILTER_TYPE_POINT; - dxMip = D3D11_FILTER_TYPE_POINT; - break; - case GL_LINEAR_MIPMAP_NEAREST: - dxMin = D3D11_FILTER_TYPE_LINEAR; - dxMip = D3D11_FILTER_TYPE_POINT; - break; - case GL_NEAREST_MIPMAP_LINEAR: - dxMin = D3D11_FILTER_TYPE_POINT; - dxMip = D3D11_FILTER_TYPE_LINEAR; - break; - case GL_LINEAR_MIPMAP_LINEAR: - dxMin = D3D11_FILTER_TYPE_LINEAR; - dxMip = D3D11_FILTER_TYPE_LINEAR; - break; - default: - UNREACHABLE(); - } - - D3D11_FILTER_TYPE dxMag = D3D11_FILTER_TYPE_POINT; - switch (magFilter) - { - case GL_NEAREST: - dxMag = D3D11_FILTER_TYPE_POINT; - break; - case GL_LINEAR: - dxMag = D3D11_FILTER_TYPE_LINEAR; - break; - default: - UNREACHABLE(); - } - - return D3D11_ENCODE_BASIC_FILTER(dxMin, dxMag, dxMip, - static_cast<D3D11_COMPARISON_FUNC>(comparison)); - } -} - -D3D11_TEXTURE_ADDRESS_MODE ConvertTextureWrap(GLenum wrap) -{ - switch (wrap) - { - case GL_REPEAT: - return D3D11_TEXTURE_ADDRESS_WRAP; - case GL_CLAMP_TO_EDGE: - return D3D11_TEXTURE_ADDRESS_CLAMP; - case GL_MIRRORED_REPEAT: - return D3D11_TEXTURE_ADDRESS_MIRROR; - default: - UNREACHABLE(); - } - - return D3D11_TEXTURE_ADDRESS_WRAP; -} - -UINT ConvertMaxAnisotropy(float maxAnisotropy, D3D_FEATURE_LEVEL featureLevel) -{ - return static_cast<UINT>(std::min(maxAnisotropy, d3d11_gl::GetMaximumAnisotropy(featureLevel))); -} - -D3D11_QUERY ConvertQueryType(GLenum queryType) -{ - switch (queryType) - { - case GL_ANY_SAMPLES_PASSED_EXT: - case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: - return D3D11_QUERY_OCCLUSION; - case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: - return D3D11_QUERY_SO_STATISTICS; - case GL_TIME_ELAPSED_EXT: - // Two internal queries are also created for begin/end timestamps - return D3D11_QUERY_TIMESTAMP_DISJOINT; - case GL_COMMANDS_COMPLETED_CHROMIUM: - return D3D11_QUERY_EVENT; - default: - UNREACHABLE(); - return D3D11_QUERY_EVENT; - } -} - -} // namespace gl_d3d11 - namespace d3d11 { @@ -1791,6 +1479,7 @@ ID3D11InputLayout *LazyInputLayout::resolve(ID3D11Device *device) device->CreateInputLayout(&mInputDesc[0], static_cast<UINT>(mInputDesc.size()), mByteCode, mByteCodeLen, &mResource); ASSERT(SUCCEEDED(result)); + UNUSED_ASSERTION_VARIABLE(result); d3d11::SetDebugName(mResource, mDebugName); } @@ -1810,6 +1499,7 @@ ID3D11BlendState *LazyBlendState::resolve(ID3D11Device *device) { HRESULT result = device->CreateBlendState(&mDesc, &mResource); ASSERT(SUCCEEDED(result)); + UNUSED_ASSERTION_VARIABLE(result); d3d11::SetDebugName(mResource, mDebugName); } @@ -1828,7 +1518,7 @@ WorkaroundsD3D GenerateWorkarounds(const Renderer11DeviceCaps &deviceCaps, workarounds.useInstancedPointSpriteEmulation = is9_3; // TODO(jmadill): Narrow problematic driver range. - if (IsNvidia(adapterDesc.VendorId)) + if (adapterDesc.VendorId == VENDOR_ID_NVIDIA) { if (deviceCaps.driverVersion.valid()) { @@ -1847,32 +1537,11 @@ WorkaroundsD3D GenerateWorkarounds(const Renderer11DeviceCaps &deviceCaps, // TODO(jmadill): Disable workaround when we have a fixed compiler DLL. workarounds.expandIntegerPowExpressions = true; - workarounds.flushAfterEndingTransformFeedback = IsNvidia(adapterDesc.VendorId); - workarounds.getDimensionsIgnoresBaseLevel = IsNvidia(adapterDesc.VendorId); - - workarounds.preAddTexelFetchOffsets = IsIntel(adapterDesc.VendorId); - workarounds.disableB5G6R5Support = IsIntel(adapterDesc.VendorId); - workarounds.rewriteUnaryMinusOperator = - IsIntel(adapterDesc.VendorId) && - (IsBroadwell(adapterDesc.DeviceId) || IsHaswell(adapterDesc.DeviceId)); - workarounds.emulateIsnanFloat = - IsIntel(adapterDesc.VendorId) && IsSkylake(adapterDesc.DeviceId); - workarounds.callClearTwice = - IsIntel(adapterDesc.VendorId) && IsSkylake(adapterDesc.DeviceId); - - // TODO(jmadill): Disable when we have a fixed driver version. - workarounds.emulateTinyStencilTextures = IsAMD(adapterDesc.VendorId); - - // The tiny stencil texture workaround involves using CopySubresource or UpdateSubresource on a - // depth stencil texture. This is not allowed until feature level 10.1 but since it is not - // possible to support ES3 on these devices, there is no need for the workaround to begin with - // (anglebug.com/1572). - if (deviceCaps.featureLevel < D3D_FEATURE_LEVEL_10_1) - { - workarounds.emulateTinyStencilTextures = false; - } + workarounds.flushAfterEndingTransformFeedback = (adapterDesc.VendorId == VENDOR_ID_NVIDIA); + workarounds.getDimensionsIgnoresBaseLevel = (adapterDesc.VendorId == VENDOR_ID_NVIDIA); - workarounds.useSystemMemoryForConstantBuffers = IsIntel(adapterDesc.VendorId); + workarounds.preAddTexelFetchOffsets = (adapterDesc.VendorId == VENDOR_ID_INTEL); + workarounds.disableB5G6R5Support = (adapterDesc.VendorId == VENDOR_ID_INTEL); return workarounds; } diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.h index 463571cf9..2690fc6f5 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.h @@ -52,7 +52,6 @@ D3D11_STENCIL_OP ConvertStencilOp(GLenum stencilOp); D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy, GLenum comparisonMode); D3D11_TEXTURE_ADDRESS_MODE ConvertTextureWrap(GLenum wrap); -UINT ConvertMaxAnisotropy(float maxAnisotropy, D3D_FEATURE_LEVEL featureLevel); D3D11_QUERY ConvertQueryType(GLenum queryType); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/texture_format_table.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/texture_format_table.cpp index a9dfec56b..6697a1177 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/texture_format_table.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/texture_format_table.cpp @@ -15,19 +15,40 @@ namespace rx namespace d3d11 { -const Format &Format::getSwizzleFormat(const Renderer11DeviceCaps &deviceCaps) const +Format::Format() + : internalFormat(GL_NONE), + format(angle::Format::Get(angle::Format::ID::NONE)), + texFormat(DXGI_FORMAT_UNKNOWN), + srvFormat(DXGI_FORMAT_UNKNOWN), + rtvFormat(DXGI_FORMAT_UNKNOWN), + dsvFormat(DXGI_FORMAT_UNKNOWN), + blitSRVFormat(DXGI_FORMAT_UNKNOWN), + swizzle(*this), + dataInitializerFunction(nullptr) { - return (swizzleFormat == internalFormat ? *this : Format::Get(swizzleFormat, deviceCaps)); } -LoadFunctionMap Format::getLoadFunctions() const +Format::Format(GLenum internalFormat, + angle::Format::ID formatID, + DXGI_FORMAT texFormat, + DXGI_FORMAT srvFormat, + DXGI_FORMAT rtvFormat, + DXGI_FORMAT dsvFormat, + DXGI_FORMAT blitSRVFormat, + GLenum swizzleFormat, + InitializeTextureDataFunction internalFormatInitializer, + const Renderer11DeviceCaps &deviceCaps) + : internalFormat(internalFormat), + format(angle::Format::Get(formatID)), + texFormat(texFormat), + srvFormat(srvFormat), + rtvFormat(rtvFormat), + dsvFormat(dsvFormat), + blitSRVFormat(blitSRVFormat), + swizzle(swizzleFormat == internalFormat ? *this : Format::Get(swizzleFormat, deviceCaps)), + dataInitializerFunction(internalFormatInitializer), + loadFunctions(GetLoadFunctionsMap(internalFormat, formatID)) { - return GetLoadFunctionsMap(internalFormat, formatID); -} - -const angle::Format &Format::format() const -{ - return angle::Format::Get(formatID); } } // namespace d3d11 diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/texture_format_table.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/texture_format_table.h index 3be759f19..8e05a2eb8 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/texture_format_table.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/texture_format_table.h @@ -32,25 +32,22 @@ namespace d3d11 // DSVs given a GL internal format. struct Format final : angle::NonCopyable { - constexpr Format(); - constexpr Format(GLenum internalFormat, - angle::Format::ID formatID, - DXGI_FORMAT texFormat, - DXGI_FORMAT srvFormat, - DXGI_FORMAT rtvFormat, - DXGI_FORMAT dsvFormat, - DXGI_FORMAT blitSRVFormat, - GLenum swizzleFormat, - InitializeTextureDataFunction internalFormatInitializer); + Format(); + Format(GLenum internalFormat, + angle::Format::ID formatID, + DXGI_FORMAT texFormat, + DXGI_FORMAT srvFormat, + DXGI_FORMAT rtvFormat, + DXGI_FORMAT dsvFormat, + DXGI_FORMAT blitSRVFormat, + GLenum swizzleFormat, + InitializeTextureDataFunction internalFormatInitializer, + const Renderer11DeviceCaps &deviceCaps); static const Format &Get(GLenum internalFormat, const Renderer11DeviceCaps &deviceCaps); - const Format &getSwizzleFormat(const Renderer11DeviceCaps &deviceCaps) const; - LoadFunctionMap getLoadFunctions() const; - const angle::Format &format() const; - GLenum internalFormat; - angle::Format::ID formatID; + const angle::Format &format; DXGI_FORMAT texFormat; DXGI_FORMAT srvFormat; @@ -59,44 +56,12 @@ struct Format final : angle::NonCopyable DXGI_FORMAT blitSRVFormat; - GLenum swizzleFormat; + const Format &swizzle; InitializeTextureDataFunction dataInitializerFunction; -}; -constexpr Format::Format() - : internalFormat(GL_NONE), - formatID(angle::Format::ID::NONE), - texFormat(DXGI_FORMAT_UNKNOWN), - srvFormat(DXGI_FORMAT_UNKNOWN), - rtvFormat(DXGI_FORMAT_UNKNOWN), - dsvFormat(DXGI_FORMAT_UNKNOWN), - blitSRVFormat(DXGI_FORMAT_UNKNOWN), - swizzleFormat(GL_NONE), - dataInitializerFunction(nullptr) -{ -} - -constexpr Format::Format(GLenum internalFormat, - angle::Format::ID formatID, - DXGI_FORMAT texFormat, - DXGI_FORMAT srvFormat, - DXGI_FORMAT rtvFormat, - DXGI_FORMAT dsvFormat, - DXGI_FORMAT blitSRVFormat, - GLenum swizzleFormat, - InitializeTextureDataFunction internalFormatInitializer) - : internalFormat(internalFormat), - formatID(formatID), - texFormat(texFormat), - srvFormat(srvFormat), - rtvFormat(rtvFormat), - dsvFormat(dsvFormat), - blitSRVFormat(blitSRVFormat), - swizzleFormat(swizzleFormat), - dataInitializerFunction(internalFormatInitializer) -{ -} + LoadFunctionMap loadFunctions; +}; } // namespace d3d11 diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp index dd9c8757f..d5eab7bc1 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp @@ -35,56 +35,60 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev { case GL_ALPHA16F_EXT: { - static constexpr Format info(GL_ALPHA16F_EXT, - angle::Format::ID::R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_FLOAT, - GL_RGBA16F, - nullptr); + static const Format info(GL_ALPHA16F_EXT, + angle::Format::ID::R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_FLOAT, + GL_RGBA16F, + nullptr, + deviceCaps); return info; } case GL_ALPHA32F_EXT: { - static constexpr Format info(GL_ALPHA32F_EXT, - angle::Format::ID::R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32B32A32_FLOAT, - GL_RGBA32F, - nullptr); + static const Format info(GL_ALPHA32F_EXT, + angle::Format::ID::R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32B32A32_FLOAT, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } case GL_ALPHA8_EXT: { if (OnlyFL10Plus(deviceCaps)) { - static constexpr Format info(GL_ALPHA8_EXT, - angle::Format::ID::A8_UNORM, - DXGI_FORMAT_A8_UNORM, - DXGI_FORMAT_A8_UNORM, - DXGI_FORMAT_A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_A8_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_ALPHA8_EXT, + angle::Format::ID::A8_UNORM, + DXGI_FORMAT_A8_UNORM, + DXGI_FORMAT_A8_UNORM, + DXGI_FORMAT_A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_A8_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } else { - static constexpr Format info(GL_ALPHA8_EXT, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_ALPHA8_EXT, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } } @@ -92,684 +96,736 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev { if (SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps)) { - static constexpr Format info(GL_BGR565_ANGLEX, - angle::Format::ID::B5G6R5_UNORM, - DXGI_FORMAT_B5G6R5_UNORM, - DXGI_FORMAT_B5G6R5_UNORM, - DXGI_FORMAT_B5G6R5_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_B5G6R5_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_BGR565_ANGLEX, + angle::Format::ID::B5G6R5_UNORM, + DXGI_FORMAT_B5G6R5_UNORM, + DXGI_FORMAT_B5G6R5_UNORM, + DXGI_FORMAT_B5G6R5_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_B5G6R5_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } else { - static constexpr Format info(GL_BGR565_ANGLEX, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_BGR565_ANGLEX, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } } case GL_BGR5_A1_ANGLEX: { - static constexpr Format info(GL_BGR5_A1_ANGLEX, - angle::Format::ID::B8G8R8A8_UNORM, - DXGI_FORMAT_B8G8R8A8_UNORM, - DXGI_FORMAT_B8G8R8A8_UNORM, - DXGI_FORMAT_B8G8R8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_B8G8R8A8_UNORM, - GL_BGRA8_EXT, - nullptr); + static const Format info(GL_BGR5_A1_ANGLEX, + angle::Format::ID::B8G8R8A8_UNORM, + DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_B8G8R8A8_UNORM, + GL_BGRA8_EXT, + nullptr, + deviceCaps); return info; } case GL_BGRA4_ANGLEX: { - static constexpr Format info(GL_BGRA4_ANGLEX, - angle::Format::ID::B8G8R8A8_UNORM, - DXGI_FORMAT_B8G8R8A8_UNORM, - DXGI_FORMAT_B8G8R8A8_UNORM, - DXGI_FORMAT_B8G8R8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_B8G8R8A8_UNORM, - GL_BGRA8_EXT, - nullptr); + static const Format info(GL_BGRA4_ANGLEX, + angle::Format::ID::B8G8R8A8_UNORM, + DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_B8G8R8A8_UNORM, + GL_BGRA8_EXT, + nullptr, + deviceCaps); return info; } case GL_BGRA8_EXT: { - static constexpr Format info(GL_BGRA8_EXT, - angle::Format::ID::B8G8R8A8_UNORM, - DXGI_FORMAT_B8G8R8A8_UNORM, - DXGI_FORMAT_B8G8R8A8_UNORM, - DXGI_FORMAT_B8G8R8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_B8G8R8A8_UNORM, - GL_BGRA8_EXT, - nullptr); + static const Format info(GL_BGRA8_EXT, + angle::Format::ID::B8G8R8A8_UNORM, + DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_B8G8R8A8_UNORM, + GL_BGRA8_EXT, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_R11_EAC: { - static constexpr Format info(GL_COMPRESSED_R11_EAC, - angle::Format::ID::R8_UNORM, - DXGI_FORMAT_R8_UNORM, - DXGI_FORMAT_R8_UNORM, - DXGI_FORMAT_R8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_COMPRESSED_R11_EAC, + angle::Format::ID::R8_UNORM, + DXGI_FORMAT_R8_UNORM, + DXGI_FORMAT_R8_UNORM, + DXGI_FORMAT_R8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RG11_EAC: { - static constexpr Format info(GL_COMPRESSED_RG11_EAC, - angle::Format::ID::R8G8_UNORM, - DXGI_FORMAT_R8G8_UNORM, - DXGI_FORMAT_R8G8_UNORM, - DXGI_FORMAT_R8G8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_COMPRESSED_RG11_EAC, + angle::Format::ID::R8G8_UNORM, + DXGI_FORMAT_R8G8_UNORM, + DXGI_FORMAT_R8G8_UNORM, + DXGI_FORMAT_R8G8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGB8_ETC2: { - static constexpr Format info(GL_COMPRESSED_RGB8_ETC2, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>); + static const Format info(GL_COMPRESSED_RGB8_ETC2, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>, + deviceCaps); return info; } case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: { - static constexpr Format info(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>); + static const Format info(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>, + deviceCaps); return info; } case GL_COMPRESSED_RGBA8_ETC2_EAC: { - static constexpr Format info(GL_COMPRESSED_RGBA8_ETC2_EAC, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_COMPRESSED_RGBA8_ETC2_EAC, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_10x10_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_10x10_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_10x5_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_10x5_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_10x6_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_10x6_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_10x8_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_10x8_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_12x10_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_12x10_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_12x12_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_12x12_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_4x4_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_4x4_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_5x4_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_5x4_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_5x5_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_5x5_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_6x5_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_6x5_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_6x6_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_6x6_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_8x5_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_8x5_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_8x6_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_8x6_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: { - static constexpr Format info(GL_COMPRESSED_RGBA_ASTC_8x8_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_ASTC_8x8_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: { - static constexpr Format info(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, - angle::Format::ID::BC1_RGBA_UNORM_BLOCK, - DXGI_FORMAT_BC1_UNORM, - DXGI_FORMAT_BC1_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_BC1_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + angle::Format::ID::BC1_RGBA_UNORM_BLOCK, + DXGI_FORMAT_BC1_UNORM, + DXGI_FORMAT_BC1_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_BC1_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: { - static constexpr Format info(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, - angle::Format::ID::BC2_RGBA_UNORM_BLOCK, - DXGI_FORMAT_BC2_UNORM, - DXGI_FORMAT_BC2_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_BC2_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, + angle::Format::ID::BC2_RGBA_UNORM_BLOCK, + DXGI_FORMAT_BC2_UNORM, + DXGI_FORMAT_BC2_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_BC2_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: { - static constexpr Format info(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, - angle::Format::ID::BC3_RGBA_UNORM_BLOCK, - DXGI_FORMAT_BC3_UNORM, - DXGI_FORMAT_BC3_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_BC3_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, + angle::Format::ID::BC3_RGBA_UNORM_BLOCK, + DXGI_FORMAT_BC3_UNORM, + DXGI_FORMAT_BC3_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_BC3_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: { - static constexpr Format info(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, - angle::Format::ID::BC1_RGB_UNORM_BLOCK, - DXGI_FORMAT_BC1_UNORM, - DXGI_FORMAT_BC1_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_BC1_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + angle::Format::ID::BC1_RGB_UNORM_BLOCK, + DXGI_FORMAT_BC1_UNORM, + DXGI_FORMAT_BC1_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_BC1_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SIGNED_R11_EAC: { - static constexpr Format info(GL_COMPRESSED_SIGNED_R11_EAC, - angle::Format::ID::R8_SNORM, - DXGI_FORMAT_R8_SNORM, - DXGI_FORMAT_R8_SNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8_SNORM, - GL_RGBA8_SNORM, - nullptr); + static const Format info(GL_COMPRESSED_SIGNED_R11_EAC, + angle::Format::ID::R8_SNORM, + DXGI_FORMAT_R8_SNORM, + DXGI_FORMAT_R8_SNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8_SNORM, + GL_RGBA8_SNORM, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SIGNED_RG11_EAC: { - static constexpr Format info(GL_COMPRESSED_SIGNED_RG11_EAC, - angle::Format::ID::R8G8_SNORM, - DXGI_FORMAT_R8G8_SNORM, - DXGI_FORMAT_R8G8_SNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8_SNORM, - GL_RGBA8_SNORM, - nullptr); + static const Format info(GL_COMPRESSED_SIGNED_RG11_EAC, + angle::Format::ID::R8G8_SNORM, + DXGI_FORMAT_R8G8_SNORM, + DXGI_FORMAT_R8G8_SNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8_SNORM, + GL_RGBA8_SNORM, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, - angle::Format::ID::R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - GL_SRGB8_ALPHA8, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, + angle::Format::ID::R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + GL_SRGB8_ALPHA8, + nullptr, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_ETC2: { - static constexpr Format info(GL_COMPRESSED_SRGB8_ETC2, - angle::Format::ID::R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - GL_SRGB8_ALPHA8, - Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>); + static const Format info(GL_COMPRESSED_SRGB8_ETC2, + angle::Format::ID::R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + GL_SRGB8_ALPHA8, + Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>, + deviceCaps); return info; } case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: { - static constexpr Format info(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, - angle::Format::ID::R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - GL_SRGB8_ALPHA8, - nullptr); + static const Format info(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, + angle::Format::ID::R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + GL_SRGB8_ALPHA8, + nullptr, + deviceCaps); return info; } case GL_DEPTH24_STENCIL8: { if (OnlyFL10Plus(deviceCaps)) { - static constexpr Format info(GL_DEPTH24_STENCIL8, - angle::Format::ID::D24_UNORM_S8_UINT, - DXGI_FORMAT_R24G8_TYPELESS, - DXGI_FORMAT_R24_UNORM_X8_TYPELESS, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_D24_UNORM_S8_UINT, - DXGI_FORMAT_R24_UNORM_X8_TYPELESS, - GL_RGBA32F, - nullptr); + static const Format info(GL_DEPTH24_STENCIL8, + angle::Format::ID::D24_UNORM_S8_UINT, + DXGI_FORMAT_R24G8_TYPELESS, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } else { - static constexpr Format info(GL_DEPTH24_STENCIL8, - angle::Format::ID::D24_UNORM_S8_UINT, - DXGI_FORMAT_D24_UNORM_S8_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_D24_UNORM_S8_UINT, - DXGI_FORMAT_UNKNOWN, - GL_RGBA32F, - nullptr); + static const Format info(GL_DEPTH24_STENCIL8, + angle::Format::ID::D24_UNORM_S8_UINT, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_UNKNOWN, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } } case GL_DEPTH32F_STENCIL8: { - static constexpr Format info(GL_DEPTH32F_STENCIL8, - angle::Format::ID::D32_FLOAT_S8X24_UINT, - DXGI_FORMAT_R32G8X24_TYPELESS, - DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_D32_FLOAT_S8X24_UINT, - DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, - GL_RGBA32F, - nullptr); + static const Format info(GL_DEPTH32F_STENCIL8, + angle::Format::ID::D32_FLOAT_S8X24_UINT, + DXGI_FORMAT_R32G8X24_TYPELESS, + DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_D32_FLOAT_S8X24_UINT, + DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } case GL_DEPTH_COMPONENT16: { if (OnlyFL10Plus(deviceCaps)) { - static constexpr Format info(GL_DEPTH_COMPONENT16, - angle::Format::ID::D16_UNORM, - DXGI_FORMAT_R16_TYPELESS, - DXGI_FORMAT_R16_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_D16_UNORM, - DXGI_FORMAT_R16_UNORM, - GL_RGBA16_EXT, - nullptr); + static const Format info(GL_DEPTH_COMPONENT16, + angle::Format::ID::D16_UNORM, + DXGI_FORMAT_R16_TYPELESS, + DXGI_FORMAT_R16_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_D16_UNORM, + DXGI_FORMAT_R16_UNORM, + GL_RGBA16_EXT, + nullptr, + deviceCaps); return info; } else { - static constexpr Format info(GL_DEPTH_COMPONENT16, - angle::Format::ID::D16_UNORM, - DXGI_FORMAT_D16_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_D16_UNORM, - DXGI_FORMAT_UNKNOWN, - GL_RGBA16_EXT, - nullptr); + static const Format info(GL_DEPTH_COMPONENT16, + angle::Format::ID::D16_UNORM, + DXGI_FORMAT_D16_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_D16_UNORM, + DXGI_FORMAT_UNKNOWN, + GL_RGBA16_EXT, + nullptr, + deviceCaps); return info; } } @@ -777,684 +833,736 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev { if (OnlyFL10Plus(deviceCaps)) { - static constexpr Format info(GL_DEPTH_COMPONENT24, - angle::Format::ID::D24_UNORM_S8_UINT, - DXGI_FORMAT_R24G8_TYPELESS, - DXGI_FORMAT_R24_UNORM_X8_TYPELESS, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_D24_UNORM_S8_UINT, - DXGI_FORMAT_R24_UNORM_X8_TYPELESS, - GL_RGBA32F, - nullptr); + static const Format info(GL_DEPTH_COMPONENT24, + angle::Format::ID::D24_UNORM_S8_UINT, + DXGI_FORMAT_R24G8_TYPELESS, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } else { - static constexpr Format info(GL_DEPTH_COMPONENT24, - angle::Format::ID::D24_UNORM_S8_UINT, - DXGI_FORMAT_D24_UNORM_S8_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_D24_UNORM_S8_UINT, - DXGI_FORMAT_UNKNOWN, - GL_RGBA32F, - nullptr); + static const Format info(GL_DEPTH_COMPONENT24, + angle::Format::ID::D24_UNORM_S8_UINT, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_UNKNOWN, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } } case GL_DEPTH_COMPONENT32F: { - static constexpr Format info(GL_DEPTH_COMPONENT32F, - angle::Format::ID::D32_FLOAT, - DXGI_FORMAT_R32_TYPELESS, - DXGI_FORMAT_R32_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_D32_FLOAT, - DXGI_FORMAT_R32_FLOAT, - GL_RGBA32F, - nullptr); + static const Format info(GL_DEPTH_COMPONENT32F, + angle::Format::ID::D32_FLOAT, + DXGI_FORMAT_R32_TYPELESS, + DXGI_FORMAT_R32_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_D32_FLOAT, + DXGI_FORMAT_R32_FLOAT, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } case GL_DEPTH_COMPONENT32_OES: { if (OnlyFL10Plus(deviceCaps)) { - static constexpr Format info(GL_DEPTH_COMPONENT32_OES, - angle::Format::ID::D24_UNORM_S8_UINT, - DXGI_FORMAT_R24G8_TYPELESS, - DXGI_FORMAT_R24_UNORM_X8_TYPELESS, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_D24_UNORM_S8_UINT, - DXGI_FORMAT_R24_UNORM_X8_TYPELESS, - GL_RGBA32F, - nullptr); + static const Format info(GL_DEPTH_COMPONENT32_OES, + angle::Format::ID::D24_UNORM_S8_UINT, + DXGI_FORMAT_R24G8_TYPELESS, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } else { - static constexpr Format info(GL_DEPTH_COMPONENT32_OES, - angle::Format::ID::D24_UNORM_S8_UINT, - DXGI_FORMAT_D24_UNORM_S8_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_D24_UNORM_S8_UINT, - DXGI_FORMAT_UNKNOWN, - GL_RGBA32F, - nullptr); + static const Format info(GL_DEPTH_COMPONENT32_OES, + angle::Format::ID::D24_UNORM_S8_UINT, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_UNKNOWN, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } } case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE: { - static constexpr Format info(GL_ETC1_RGB8_LOSSY_DECODE_ANGLE, - angle::Format::ID::BC1_RGB_UNORM_BLOCK, - DXGI_FORMAT_BC1_UNORM, - DXGI_FORMAT_BC1_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_BC1_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_ETC1_RGB8_LOSSY_DECODE_ANGLE, + angle::Format::ID::BC1_RGB_UNORM_BLOCK, + DXGI_FORMAT_BC1_UNORM, + DXGI_FORMAT_BC1_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_BC1_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_ETC1_RGB8_OES: { - static constexpr Format info(GL_ETC1_RGB8_OES, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>); + static const Format info(GL_ETC1_RGB8_OES, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>, + deviceCaps); return info; } case GL_LUMINANCE16F_EXT: { - static constexpr Format info(GL_LUMINANCE16F_EXT, - angle::Format::ID::R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_FLOAT, - GL_RGBA16F, - Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>); + static const Format info(GL_LUMINANCE16F_EXT, + angle::Format::ID::R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_FLOAT, + GL_RGBA16F, + Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>, + deviceCaps); return info; } case GL_LUMINANCE32F_EXT: { - static constexpr Format info(GL_LUMINANCE32F_EXT, - angle::Format::ID::R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32B32A32_FLOAT, - GL_RGBA32F, - Initialize4ComponentData<GLfloat, 0x00000000, 0x00000000, 0x00000000, gl::Float32One>); + static const Format info(GL_LUMINANCE32F_EXT, + angle::Format::ID::R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32B32A32_FLOAT, + GL_RGBA32F, + Initialize4ComponentData<GLfloat, 0x00000000, 0x00000000, 0x00000000, gl::Float32One>, + deviceCaps); return info; } case GL_LUMINANCE8_ALPHA8_EXT: { - static constexpr Format info(GL_LUMINANCE8_ALPHA8_EXT, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_LUMINANCE8_ALPHA8_EXT, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_LUMINANCE8_EXT: { - static constexpr Format info(GL_LUMINANCE8_EXT, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>); + static const Format info(GL_LUMINANCE8_EXT, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>, + deviceCaps); return info; } case GL_LUMINANCE_ALPHA16F_EXT: { - static constexpr Format info(GL_LUMINANCE_ALPHA16F_EXT, - angle::Format::ID::R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_FLOAT, - GL_RGBA16F, - nullptr); + static const Format info(GL_LUMINANCE_ALPHA16F_EXT, + angle::Format::ID::R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_FLOAT, + GL_RGBA16F, + nullptr, + deviceCaps); return info; } case GL_LUMINANCE_ALPHA32F_EXT: { - static constexpr Format info(GL_LUMINANCE_ALPHA32F_EXT, - angle::Format::ID::R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32B32A32_FLOAT, - GL_RGBA32F, - nullptr); + static const Format info(GL_LUMINANCE_ALPHA32F_EXT, + angle::Format::ID::R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32B32A32_FLOAT, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } case GL_NONE: { - static constexpr Format info(GL_NONE, - angle::Format::ID::NONE, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - GL_NONE, - nullptr); + static const Format info(GL_NONE, + angle::Format::ID::NONE, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + GL_NONE, + nullptr, + deviceCaps); return info; } case GL_R11F_G11F_B10F: { - static constexpr Format info(GL_R11F_G11F_B10F, - angle::Format::ID::R11G11B10_FLOAT, - DXGI_FORMAT_R11G11B10_FLOAT, - DXGI_FORMAT_R11G11B10_FLOAT, - DXGI_FORMAT_R11G11B10_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R11G11B10_FLOAT, - GL_RGBA16F_EXT, - nullptr); + static const Format info(GL_R11F_G11F_B10F, + angle::Format::ID::R11G11B10_FLOAT, + DXGI_FORMAT_R11G11B10_FLOAT, + DXGI_FORMAT_R11G11B10_FLOAT, + DXGI_FORMAT_R11G11B10_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R11G11B10_FLOAT, + GL_RGBA16F_EXT, + nullptr, + deviceCaps); return info; } case GL_R16F: { - static constexpr Format info(GL_R16F, - angle::Format::ID::R16_FLOAT, - DXGI_FORMAT_R16_FLOAT, - DXGI_FORMAT_R16_FLOAT, - DXGI_FORMAT_R16_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16_FLOAT, - GL_RGBA16F_EXT, - nullptr); + static const Format info(GL_R16F, + angle::Format::ID::R16_FLOAT, + DXGI_FORMAT_R16_FLOAT, + DXGI_FORMAT_R16_FLOAT, + DXGI_FORMAT_R16_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16_FLOAT, + GL_RGBA16F_EXT, + nullptr, + deviceCaps); return info; } case GL_R16I: { - static constexpr Format info(GL_R16I, - angle::Format::ID::R16_SINT, - DXGI_FORMAT_R16_SINT, - DXGI_FORMAT_R16_SINT, - DXGI_FORMAT_R16_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16_SINT, - GL_RGBA16I, - nullptr); + static const Format info(GL_R16I, + angle::Format::ID::R16_SINT, + DXGI_FORMAT_R16_SINT, + DXGI_FORMAT_R16_SINT, + DXGI_FORMAT_R16_SINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16_SINT, + GL_RGBA16I, + nullptr, + deviceCaps); return info; } case GL_R16UI: { - static constexpr Format info(GL_R16UI, - angle::Format::ID::R16_UINT, - DXGI_FORMAT_R16_UINT, - DXGI_FORMAT_R16_UINT, - DXGI_FORMAT_R16_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16_UINT, - GL_RGBA16I, - nullptr); + static const Format info(GL_R16UI, + angle::Format::ID::R16_UINT, + DXGI_FORMAT_R16_UINT, + DXGI_FORMAT_R16_UINT, + DXGI_FORMAT_R16_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16_UINT, + GL_RGBA16I, + nullptr, + deviceCaps); return info; } case GL_R16_EXT: { - static constexpr Format info(GL_R16_EXT, - angle::Format::ID::R16_UNORM, - DXGI_FORMAT_R16_UNORM, - DXGI_FORMAT_R16_UNORM, - DXGI_FORMAT_R16_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16_UNORM, - GL_RGBA16_EXT, - nullptr); + static const Format info(GL_R16_EXT, + angle::Format::ID::R16_UNORM, + DXGI_FORMAT_R16_UNORM, + DXGI_FORMAT_R16_UNORM, + DXGI_FORMAT_R16_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16_UNORM, + GL_RGBA16_EXT, + nullptr, + deviceCaps); return info; } case GL_R16_SNORM_EXT: { - static constexpr Format info(GL_R16_SNORM_EXT, - angle::Format::ID::R16_SNORM, - DXGI_FORMAT_R16_SNORM, - DXGI_FORMAT_R16_SNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16_SNORM, - GL_RGBA16_SNORM_EXT, - nullptr); + static const Format info(GL_R16_SNORM_EXT, + angle::Format::ID::R16_SNORM, + DXGI_FORMAT_R16_SNORM, + DXGI_FORMAT_R16_SNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16_SNORM, + GL_RGBA16_SNORM_EXT, + nullptr, + deviceCaps); return info; } case GL_R32F: { - static constexpr Format info(GL_R32F, - angle::Format::ID::R32_FLOAT, - DXGI_FORMAT_R32_FLOAT, - DXGI_FORMAT_R32_FLOAT, - DXGI_FORMAT_R32_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32_FLOAT, - GL_RGBA32F, - nullptr); + static const Format info(GL_R32F, + angle::Format::ID::R32_FLOAT, + DXGI_FORMAT_R32_FLOAT, + DXGI_FORMAT_R32_FLOAT, + DXGI_FORMAT_R32_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32_FLOAT, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } case GL_R32I: { - static constexpr Format info(GL_R32I, - angle::Format::ID::R32_SINT, - DXGI_FORMAT_R32_SINT, - DXGI_FORMAT_R32_SINT, - DXGI_FORMAT_R32_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32_SINT, - GL_RGBA32I, - nullptr); + static const Format info(GL_R32I, + angle::Format::ID::R32_SINT, + DXGI_FORMAT_R32_SINT, + DXGI_FORMAT_R32_SINT, + DXGI_FORMAT_R32_SINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32_SINT, + GL_RGBA32I, + nullptr, + deviceCaps); return info; } case GL_R32UI: { - static constexpr Format info(GL_R32UI, - angle::Format::ID::R32_UINT, - DXGI_FORMAT_R32_UINT, - DXGI_FORMAT_R32_UINT, - DXGI_FORMAT_R32_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32_UINT, - GL_RGBA32I, - nullptr); + static const Format info(GL_R32UI, + angle::Format::ID::R32_UINT, + DXGI_FORMAT_R32_UINT, + DXGI_FORMAT_R32_UINT, + DXGI_FORMAT_R32_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32_UINT, + GL_RGBA32I, + nullptr, + deviceCaps); return info; } case GL_R8: { - static constexpr Format info(GL_R8, - angle::Format::ID::R8_UNORM, - DXGI_FORMAT_R8_UNORM, - DXGI_FORMAT_R8_UNORM, - DXGI_FORMAT_R8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_R8, + angle::Format::ID::R8_UNORM, + DXGI_FORMAT_R8_UNORM, + DXGI_FORMAT_R8_UNORM, + DXGI_FORMAT_R8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_R8I: { - static constexpr Format info(GL_R8I, - angle::Format::ID::R8_SINT, - DXGI_FORMAT_R8_SINT, - DXGI_FORMAT_R8_SINT, - DXGI_FORMAT_R8_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8_SINT, - GL_RGBA8I, - nullptr); + static const Format info(GL_R8I, + angle::Format::ID::R8_SINT, + DXGI_FORMAT_R8_SINT, + DXGI_FORMAT_R8_SINT, + DXGI_FORMAT_R8_SINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8_SINT, + GL_RGBA8I, + nullptr, + deviceCaps); return info; } case GL_R8UI: { - static constexpr Format info(GL_R8UI, - angle::Format::ID::R8_UINT, - DXGI_FORMAT_R8_UINT, - DXGI_FORMAT_R8_UINT, - DXGI_FORMAT_R8_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8_UINT, - GL_RGBA8I, - nullptr); + static const Format info(GL_R8UI, + angle::Format::ID::R8_UINT, + DXGI_FORMAT_R8_UINT, + DXGI_FORMAT_R8_UINT, + DXGI_FORMAT_R8_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8_UINT, + GL_RGBA8I, + nullptr, + deviceCaps); return info; } case GL_R8_SNORM: { - static constexpr Format info(GL_R8_SNORM, - angle::Format::ID::R8_SNORM, - DXGI_FORMAT_R8_SNORM, - DXGI_FORMAT_R8_SNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8_SNORM, - GL_RGBA8_SNORM, - nullptr); + static const Format info(GL_R8_SNORM, + angle::Format::ID::R8_SNORM, + DXGI_FORMAT_R8_SNORM, + DXGI_FORMAT_R8_SNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8_SNORM, + GL_RGBA8_SNORM, + nullptr, + deviceCaps); return info; } case GL_RG16F: { - static constexpr Format info(GL_RG16F, - angle::Format::ID::R16G16_FLOAT, - DXGI_FORMAT_R16G16_FLOAT, - DXGI_FORMAT_R16G16_FLOAT, - DXGI_FORMAT_R16G16_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16_FLOAT, - GL_RGBA16F_EXT, - nullptr); + static const Format info(GL_RG16F, + angle::Format::ID::R16G16_FLOAT, + DXGI_FORMAT_R16G16_FLOAT, + DXGI_FORMAT_R16G16_FLOAT, + DXGI_FORMAT_R16G16_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16_FLOAT, + GL_RGBA16F_EXT, + nullptr, + deviceCaps); return info; } case GL_RG16I: { - static constexpr Format info(GL_RG16I, - angle::Format::ID::R16G16_SINT, - DXGI_FORMAT_R16G16_SINT, - DXGI_FORMAT_R16G16_SINT, - DXGI_FORMAT_R16G16_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16_SINT, - GL_RGBA16I, - nullptr); + static const Format info(GL_RG16I, + angle::Format::ID::R16G16_SINT, + DXGI_FORMAT_R16G16_SINT, + DXGI_FORMAT_R16G16_SINT, + DXGI_FORMAT_R16G16_SINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16_SINT, + GL_RGBA16I, + nullptr, + deviceCaps); return info; } case GL_RG16UI: { - static constexpr Format info(GL_RG16UI, - angle::Format::ID::R16G16_UINT, - DXGI_FORMAT_R16G16_UINT, - DXGI_FORMAT_R16G16_UINT, - DXGI_FORMAT_R16G16_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16_UINT, - GL_RGBA16I, - nullptr); + static const Format info(GL_RG16UI, + angle::Format::ID::R16G16_UINT, + DXGI_FORMAT_R16G16_UINT, + DXGI_FORMAT_R16G16_UINT, + DXGI_FORMAT_R16G16_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16_UINT, + GL_RGBA16I, + nullptr, + deviceCaps); return info; } case GL_RG16_EXT: { - static constexpr Format info(GL_RG16_EXT, - angle::Format::ID::R16G16_UNORM, - DXGI_FORMAT_R16G16_UNORM, - DXGI_FORMAT_R16G16_UNORM, - DXGI_FORMAT_R16G16_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16_UNORM, - GL_RGBA16_EXT, - nullptr); + static const Format info(GL_RG16_EXT, + angle::Format::ID::R16G16_UNORM, + DXGI_FORMAT_R16G16_UNORM, + DXGI_FORMAT_R16G16_UNORM, + DXGI_FORMAT_R16G16_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16_UNORM, + GL_RGBA16_EXT, + nullptr, + deviceCaps); return info; } case GL_RG16_SNORM_EXT: { - static constexpr Format info(GL_RG16_SNORM_EXT, - angle::Format::ID::R16G16_SNORM, - DXGI_FORMAT_R16G16_SNORM, - DXGI_FORMAT_R16G16_SNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16_SNORM, - GL_RGBA16_SNORM_EXT, - nullptr); + static const Format info(GL_RG16_SNORM_EXT, + angle::Format::ID::R16G16_SNORM, + DXGI_FORMAT_R16G16_SNORM, + DXGI_FORMAT_R16G16_SNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16_SNORM, + GL_RGBA16_SNORM_EXT, + nullptr, + deviceCaps); return info; } case GL_RG32F: { - static constexpr Format info(GL_RG32F, - angle::Format::ID::R32G32_FLOAT, - DXGI_FORMAT_R32G32_FLOAT, - DXGI_FORMAT_R32G32_FLOAT, - DXGI_FORMAT_R32G32_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32_FLOAT, - GL_RGBA32F, - nullptr); + static const Format info(GL_RG32F, + angle::Format::ID::R32G32_FLOAT, + DXGI_FORMAT_R32G32_FLOAT, + DXGI_FORMAT_R32G32_FLOAT, + DXGI_FORMAT_R32G32_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32_FLOAT, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } case GL_RG32I: { - static constexpr Format info(GL_RG32I, - angle::Format::ID::R32G32_SINT, - DXGI_FORMAT_R32G32_SINT, - DXGI_FORMAT_R32G32_SINT, - DXGI_FORMAT_R32G32_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32_SINT, - GL_RGBA32I, - nullptr); + static const Format info(GL_RG32I, + angle::Format::ID::R32G32_SINT, + DXGI_FORMAT_R32G32_SINT, + DXGI_FORMAT_R32G32_SINT, + DXGI_FORMAT_R32G32_SINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32_SINT, + GL_RGBA32I, + nullptr, + deviceCaps); return info; } case GL_RG32UI: { - static constexpr Format info(GL_RG32UI, - angle::Format::ID::R32G32_UINT, - DXGI_FORMAT_R32G32_UINT, - DXGI_FORMAT_R32G32_UINT, - DXGI_FORMAT_R32G32_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32_UINT, - GL_RGBA32I, - nullptr); + static const Format info(GL_RG32UI, + angle::Format::ID::R32G32_UINT, + DXGI_FORMAT_R32G32_UINT, + DXGI_FORMAT_R32G32_UINT, + DXGI_FORMAT_R32G32_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32_UINT, + GL_RGBA32I, + nullptr, + deviceCaps); return info; } case GL_RG8: { - static constexpr Format info(GL_RG8, - angle::Format::ID::R8G8_UNORM, - DXGI_FORMAT_R8G8_UNORM, - DXGI_FORMAT_R8G8_UNORM, - DXGI_FORMAT_R8G8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_RG8, + angle::Format::ID::R8G8_UNORM, + DXGI_FORMAT_R8G8_UNORM, + DXGI_FORMAT_R8G8_UNORM, + DXGI_FORMAT_R8G8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_RG8I: { - static constexpr Format info(GL_RG8I, - angle::Format::ID::R8G8_SINT, - DXGI_FORMAT_R8G8_SINT, - DXGI_FORMAT_R8G8_SINT, - DXGI_FORMAT_R8G8_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8_SINT, - GL_RGBA8I, - nullptr); + static const Format info(GL_RG8I, + angle::Format::ID::R8G8_SINT, + DXGI_FORMAT_R8G8_SINT, + DXGI_FORMAT_R8G8_SINT, + DXGI_FORMAT_R8G8_SINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8_SINT, + GL_RGBA8I, + nullptr, + deviceCaps); return info; } case GL_RG8UI: { - static constexpr Format info(GL_RG8UI, - angle::Format::ID::R8G8_UINT, - DXGI_FORMAT_R8G8_UINT, - DXGI_FORMAT_R8G8_UINT, - DXGI_FORMAT_R8G8_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8_UINT, - GL_RGBA8I, - nullptr); + static const Format info(GL_RG8UI, + angle::Format::ID::R8G8_UINT, + DXGI_FORMAT_R8G8_UINT, + DXGI_FORMAT_R8G8_UINT, + DXGI_FORMAT_R8G8_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8_UINT, + GL_RGBA8I, + nullptr, + deviceCaps); return info; } case GL_RG8_SNORM: { - static constexpr Format info(GL_RG8_SNORM, - angle::Format::ID::R8G8_SNORM, - DXGI_FORMAT_R8G8_SNORM, - DXGI_FORMAT_R8G8_SNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8_SNORM, - GL_RGBA8_SNORM, - nullptr); + static const Format info(GL_RG8_SNORM, + angle::Format::ID::R8G8_SNORM, + DXGI_FORMAT_R8G8_SNORM, + DXGI_FORMAT_R8G8_SNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8_SNORM, + GL_RGBA8_SNORM, + nullptr, + deviceCaps); return info; } case GL_RGB: { - static constexpr Format info(GL_RGB, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>); + static const Format info(GL_RGB, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>, + deviceCaps); return info; } case GL_RGB10_A2: { - static constexpr Format info(GL_RGB10_A2, - angle::Format::ID::R10G10B10A2_UNORM, - DXGI_FORMAT_R10G10B10A2_UNORM, - DXGI_FORMAT_R10G10B10A2_UNORM, - DXGI_FORMAT_R10G10B10A2_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R10G10B10A2_UNORM, - GL_RGBA16_EXT, - nullptr); + static const Format info(GL_RGB10_A2, + angle::Format::ID::R10G10B10A2_UNORM, + DXGI_FORMAT_R10G10B10A2_UNORM, + DXGI_FORMAT_R10G10B10A2_UNORM, + DXGI_FORMAT_R10G10B10A2_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R10G10B10A2_UNORM, + GL_RGBA16_EXT, + nullptr, + deviceCaps); return info; } case GL_RGB10_A2UI: { - static constexpr Format info(GL_RGB10_A2UI, - angle::Format::ID::R10G10B10A2_UINT, - DXGI_FORMAT_R10G10B10A2_UINT, - DXGI_FORMAT_R10G10B10A2_UINT, - DXGI_FORMAT_R10G10B10A2_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R10G10B10A2_UINT, - GL_RGBA16I, - nullptr); + static const Format info(GL_RGB10_A2UI, + angle::Format::ID::R10G10B10A2_UINT, + DXGI_FORMAT_R10G10B10A2_UINT, + DXGI_FORMAT_R10G10B10A2_UINT, + DXGI_FORMAT_R10G10B10A2_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R10G10B10A2_UINT, + GL_RGBA16I, + nullptr, + deviceCaps); return info; } case GL_RGB16F: { - static constexpr Format info(GL_RGB16F, - angle::Format::ID::R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_FLOAT, - GL_RGBA16F, - Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>); + static const Format info(GL_RGB16F, + angle::Format::ID::R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_FLOAT, + GL_RGBA16F, + Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>, + deviceCaps); return info; } case GL_RGB16I: { - static constexpr Format info(GL_RGB16I, - angle::Format::ID::R16G16B16A16_SINT, - DXGI_FORMAT_R16G16B16A16_SINT, - DXGI_FORMAT_R16G16B16A16_SINT, - DXGI_FORMAT_R16G16B16A16_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_SINT, - GL_RGBA16I, - Initialize4ComponentData<GLshort, 0x0000, 0x0000, 0x0000, 0x0001>); + static const Format info(GL_RGB16I, + angle::Format::ID::R16G16B16A16_SINT, + DXGI_FORMAT_R16G16B16A16_SINT, + DXGI_FORMAT_R16G16B16A16_SINT, + DXGI_FORMAT_R16G16B16A16_SINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_SINT, + GL_RGBA16I, + Initialize4ComponentData<GLshort, 0x0000, 0x0000, 0x0000, 0x0001>, + deviceCaps); return info; } case GL_RGB16UI: { - static constexpr Format info(GL_RGB16UI, - angle::Format::ID::R16G16B16A16_UINT, - DXGI_FORMAT_R16G16B16A16_UINT, - DXGI_FORMAT_R16G16B16A16_UINT, - DXGI_FORMAT_R16G16B16A16_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_UINT, - GL_RGBA16UI, - Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0x0001>); + static const Format info(GL_RGB16UI, + angle::Format::ID::R16G16B16A16_UINT, + DXGI_FORMAT_R16G16B16A16_UINT, + DXGI_FORMAT_R16G16B16A16_UINT, + DXGI_FORMAT_R16G16B16A16_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_UINT, + GL_RGBA16UI, + Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0x0001>, + deviceCaps); return info; } case GL_RGB16_EXT: { - static constexpr Format info(GL_RGB16_EXT, - angle::Format::ID::R16G16B16A16_UNORM, - DXGI_FORMAT_R16G16B16A16_UNORM, - DXGI_FORMAT_R16G16B16A16_UNORM, - DXGI_FORMAT_R16G16B16A16_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_UNORM, - GL_RGBA16_EXT, - Initialize4ComponentData<GLubyte, 0x0000, 0x0000, 0x0000, 0xFFFF>); + static const Format info(GL_RGB16_EXT, + angle::Format::ID::R16G16B16A16_UNORM, + DXGI_FORMAT_R16G16B16A16_UNORM, + DXGI_FORMAT_R16G16B16A16_UNORM, + DXGI_FORMAT_R16G16B16A16_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_UNORM, + GL_RGBA16_EXT, + Initialize4ComponentData<GLubyte, 0x0000, 0x0000, 0x0000, 0xFFFF>, + deviceCaps); return info; } case GL_RGB16_SNORM_EXT: { - static constexpr Format info(GL_RGB16_SNORM_EXT, - angle::Format::ID::R16G16B16A16_SNORM, - DXGI_FORMAT_R16G16B16A16_SNORM, - DXGI_FORMAT_R16G16B16A16_SNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_SNORM, - GL_RGBA16_SNORM_EXT, - Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0x7FFF>); + static const Format info(GL_RGB16_SNORM_EXT, + angle::Format::ID::R16G16B16A16_SNORM, + DXGI_FORMAT_R16G16B16A16_SNORM, + DXGI_FORMAT_R16G16B16A16_SNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_SNORM, + GL_RGBA16_SNORM_EXT, + Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0x7FFF>, + deviceCaps); return info; } case GL_RGB32F: { - static constexpr Format info(GL_RGB32F, - angle::Format::ID::R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32B32A32_FLOAT, - GL_RGBA32F, - Initialize4ComponentData<GLfloat, 0x00000000, 0x00000000, 0x00000000, gl::Float32One>); + static const Format info(GL_RGB32F, + angle::Format::ID::R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32B32A32_FLOAT, + GL_RGBA32F, + Initialize4ComponentData<GLfloat, 0x00000000, 0x00000000, 0x00000000, gl::Float32One>, + deviceCaps); return info; } case GL_RGB32I: { - static constexpr Format info(GL_RGB32I, - angle::Format::ID::R32G32B32A32_SINT, - DXGI_FORMAT_R32G32B32A32_SINT, - DXGI_FORMAT_R32G32B32A32_SINT, - DXGI_FORMAT_R32G32B32A32_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32B32A32_SINT, - GL_RGBA32I, - Initialize4ComponentData<GLint, 0x00000000, 0x00000000, 0x00000000, 0x00000001>); + static const Format info(GL_RGB32I, + angle::Format::ID::R32G32B32A32_SINT, + DXGI_FORMAT_R32G32B32A32_SINT, + DXGI_FORMAT_R32G32B32A32_SINT, + DXGI_FORMAT_R32G32B32A32_SINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32B32A32_SINT, + GL_RGBA32I, + Initialize4ComponentData<GLint, 0x00000000, 0x00000000, 0x00000000, 0x00000001>, + deviceCaps); return info; } case GL_RGB32UI: { - static constexpr Format info(GL_RGB32UI, - angle::Format::ID::R32G32B32A32_UINT, - DXGI_FORMAT_R32G32B32A32_UINT, - DXGI_FORMAT_R32G32B32A32_UINT, - DXGI_FORMAT_R32G32B32A32_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32B32A32_UINT, - GL_RGBA32UI, - Initialize4ComponentData<GLuint, 0x00000000, 0x00000000, 0x00000000, 0x00000001>); + static const Format info(GL_RGB32UI, + angle::Format::ID::R32G32B32A32_UINT, + DXGI_FORMAT_R32G32B32A32_UINT, + DXGI_FORMAT_R32G32B32A32_UINT, + DXGI_FORMAT_R32G32B32A32_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32B32A32_UINT, + GL_RGBA32UI, + Initialize4ComponentData<GLuint, 0x00000000, 0x00000000, 0x00000000, 0x00000001>, + deviceCaps); return info; } case GL_RGB565: { if (SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps)) { - static constexpr Format info(GL_RGB565, - angle::Format::ID::B5G6R5_UNORM, - DXGI_FORMAT_B5G6R5_UNORM, - DXGI_FORMAT_B5G6R5_UNORM, - DXGI_FORMAT_B5G6R5_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_B5G6R5_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_RGB565, + angle::Format::ID::B5G6R5_UNORM, + DXGI_FORMAT_B5G6R5_UNORM, + DXGI_FORMAT_B5G6R5_UNORM, + DXGI_FORMAT_B5G6R5_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_B5G6R5_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } else { - static constexpr Format info(GL_RGB565, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>); + static const Format info(GL_RGB565, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>, + deviceCaps); return info; } } @@ -1462,34 +1570,21 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev { if (SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps)) { - static constexpr Format info(GL_RGB5_A1, - angle::Format::ID::B5G5R5A1_UNORM, - DXGI_FORMAT_B5G5R5A1_UNORM, - DXGI_FORMAT_B5G5R5A1_UNORM, - DXGI_FORMAT_B5G5R5A1_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_B5G5R5A1_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_RGB5_A1, + angle::Format::ID::B5G5R5A1_UNORM, + DXGI_FORMAT_B5G5R5A1_UNORM, + DXGI_FORMAT_B5G5R5A1_UNORM, + DXGI_FORMAT_B5G5R5A1_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_B5G5R5A1_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } else { - static constexpr Format info(GL_RGB5_A1, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - nullptr); - return info; - } - } - case GL_RGB8: - { - static constexpr Format info(GL_RGB8, + static const Format info(GL_RGB5_A1, angle::Format::ID::R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, @@ -1497,210 +1592,226 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_R8G8B8A8_UNORM, GL_RGBA8, - Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>); + nullptr, + deviceCaps); + return info; + } + } + case GL_RGB8: + { + static const Format info(GL_RGB8, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>, + deviceCaps); return info; } case GL_RGB8I: { - static constexpr Format info(GL_RGB8I, - angle::Format::ID::R8G8B8A8_SINT, - DXGI_FORMAT_R8G8B8A8_SINT, - DXGI_FORMAT_R8G8B8A8_SINT, - DXGI_FORMAT_R8G8B8A8_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_SINT, - GL_RGBA8I, - Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x01>); + static const Format info(GL_RGB8I, + angle::Format::ID::R8G8B8A8_SINT, + DXGI_FORMAT_R8G8B8A8_SINT, + DXGI_FORMAT_R8G8B8A8_SINT, + DXGI_FORMAT_R8G8B8A8_SINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_SINT, + GL_RGBA8I, + Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x01>, + deviceCaps); return info; } case GL_RGB8UI: { - static constexpr Format info(GL_RGB8UI, - angle::Format::ID::R8G8B8A8_UINT, - DXGI_FORMAT_R8G8B8A8_UINT, - DXGI_FORMAT_R8G8B8A8_UINT, - DXGI_FORMAT_R8G8B8A8_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UINT, - GL_RGBA8UI, - Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0x01>); + static const Format info(GL_RGB8UI, + angle::Format::ID::R8G8B8A8_UINT, + DXGI_FORMAT_R8G8B8A8_UINT, + DXGI_FORMAT_R8G8B8A8_UINT, + DXGI_FORMAT_R8G8B8A8_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UINT, + GL_RGBA8UI, + Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0x01>, + deviceCaps); return info; } case GL_RGB8_SNORM: { - static constexpr Format info(GL_RGB8_SNORM, - angle::Format::ID::R8G8B8A8_SNORM, - DXGI_FORMAT_R8G8B8A8_SNORM, - DXGI_FORMAT_R8G8B8A8_SNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_SNORM, - GL_RGBA8_SNORM, - Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x7F>); + static const Format info(GL_RGB8_SNORM, + angle::Format::ID::R8G8B8A8_SNORM, + DXGI_FORMAT_R8G8B8A8_SNORM, + DXGI_FORMAT_R8G8B8A8_SNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_SNORM, + GL_RGBA8_SNORM, + Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x7F>, + deviceCaps); return info; } case GL_RGB9_E5: { - static constexpr Format info(GL_RGB9_E5, - angle::Format::ID::R9G9B9E5_SHAREDEXP, - DXGI_FORMAT_R9G9B9E5_SHAREDEXP, - DXGI_FORMAT_R9G9B9E5_SHAREDEXP, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R9G9B9E5_SHAREDEXP, - GL_RGBA16F_EXT, - nullptr); + static const Format info(GL_RGB9_E5, + angle::Format::ID::R9G9B9E5_SHAREDEXP, + DXGI_FORMAT_R9G9B9E5_SHAREDEXP, + DXGI_FORMAT_R9G9B9E5_SHAREDEXP, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R9G9B9E5_SHAREDEXP, + GL_RGBA16F_EXT, + nullptr, + deviceCaps); return info; } case GL_RGBA: { - static constexpr Format info(GL_RGBA, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - nullptr); + static const Format info(GL_RGBA, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_RGBA16F: { - static constexpr Format info(GL_RGBA16F, - angle::Format::ID::R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_R16G16B16A16_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_FLOAT, - GL_RGBA16F, - nullptr); + static const Format info(GL_RGBA16F, + angle::Format::ID::R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_FLOAT, + GL_RGBA16F, + nullptr, + deviceCaps); return info; } case GL_RGBA16I: { - static constexpr Format info(GL_RGBA16I, - angle::Format::ID::R16G16B16A16_SINT, - DXGI_FORMAT_R16G16B16A16_SINT, - DXGI_FORMAT_R16G16B16A16_SINT, - DXGI_FORMAT_R16G16B16A16_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_SINT, - GL_RGBA16I, - nullptr); + static const Format info(GL_RGBA16I, + angle::Format::ID::R16G16B16A16_SINT, + DXGI_FORMAT_R16G16B16A16_SINT, + DXGI_FORMAT_R16G16B16A16_SINT, + DXGI_FORMAT_R16G16B16A16_SINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_SINT, + GL_RGBA16I, + nullptr, + deviceCaps); return info; } case GL_RGBA16UI: { - static constexpr Format info(GL_RGBA16UI, - angle::Format::ID::R16G16B16A16_UINT, - DXGI_FORMAT_R16G16B16A16_UINT, - DXGI_FORMAT_R16G16B16A16_UINT, - DXGI_FORMAT_R16G16B16A16_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_UINT, - GL_RGBA16UI, - nullptr); + static const Format info(GL_RGBA16UI, + angle::Format::ID::R16G16B16A16_UINT, + DXGI_FORMAT_R16G16B16A16_UINT, + DXGI_FORMAT_R16G16B16A16_UINT, + DXGI_FORMAT_R16G16B16A16_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_UINT, + GL_RGBA16UI, + nullptr, + deviceCaps); return info; } case GL_RGBA16_EXT: { - static constexpr Format info(GL_RGBA16_EXT, - angle::Format::ID::R16G16B16A16_UNORM, - DXGI_FORMAT_R16G16B16A16_UNORM, - DXGI_FORMAT_R16G16B16A16_UNORM, - DXGI_FORMAT_R16G16B16A16_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_UNORM, - GL_RGBA16_EXT, - nullptr); + static const Format info(GL_RGBA16_EXT, + angle::Format::ID::R16G16B16A16_UNORM, + DXGI_FORMAT_R16G16B16A16_UNORM, + DXGI_FORMAT_R16G16B16A16_UNORM, + DXGI_FORMAT_R16G16B16A16_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_UNORM, + GL_RGBA16_EXT, + nullptr, + deviceCaps); return info; } case GL_RGBA16_SNORM_EXT: { - static constexpr Format info(GL_RGBA16_SNORM_EXT, - angle::Format::ID::R16G16B16A16_SNORM, - DXGI_FORMAT_R16G16B16A16_SNORM, - DXGI_FORMAT_R16G16B16A16_SNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R16G16B16A16_SNORM, - GL_RGBA16_SNORM_EXT, - nullptr); + static const Format info(GL_RGBA16_SNORM_EXT, + angle::Format::ID::R16G16B16A16_SNORM, + DXGI_FORMAT_R16G16B16A16_SNORM, + DXGI_FORMAT_R16G16B16A16_SNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R16G16B16A16_SNORM, + GL_RGBA16_SNORM_EXT, + nullptr, + deviceCaps); return info; } case GL_RGBA32F: { - static constexpr Format info(GL_RGBA32F, - angle::Format::ID::R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32B32A32_FLOAT, - GL_RGBA32F, - nullptr); + static const Format info(GL_RGBA32F, + angle::Format::ID::R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32B32A32_FLOAT, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } case GL_RGBA32I: { - static constexpr Format info(GL_RGBA32I, - angle::Format::ID::R32G32B32A32_SINT, - DXGI_FORMAT_R32G32B32A32_SINT, - DXGI_FORMAT_R32G32B32A32_SINT, - DXGI_FORMAT_R32G32B32A32_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32B32A32_SINT, - GL_RGBA32I, - nullptr); + static const Format info(GL_RGBA32I, + angle::Format::ID::R32G32B32A32_SINT, + DXGI_FORMAT_R32G32B32A32_SINT, + DXGI_FORMAT_R32G32B32A32_SINT, + DXGI_FORMAT_R32G32B32A32_SINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32B32A32_SINT, + GL_RGBA32I, + nullptr, + deviceCaps); return info; } case GL_RGBA32UI: { - static constexpr Format info(GL_RGBA32UI, - angle::Format::ID::R32G32B32A32_UINT, - DXGI_FORMAT_R32G32B32A32_UINT, - DXGI_FORMAT_R32G32B32A32_UINT, - DXGI_FORMAT_R32G32B32A32_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32B32A32_UINT, - GL_RGBA32UI, - nullptr); + static const Format info(GL_RGBA32UI, + angle::Format::ID::R32G32B32A32_UINT, + DXGI_FORMAT_R32G32B32A32_UINT, + DXGI_FORMAT_R32G32B32A32_UINT, + DXGI_FORMAT_R32G32B32A32_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32B32A32_UINT, + GL_RGBA32UI, + nullptr, + deviceCaps); return info; } case GL_RGBA4: { if (SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps)) { - static constexpr Format info(GL_RGBA4, - angle::Format::ID::B4G4R4A4_UNORM, - DXGI_FORMAT_B4G4R4A4_UNORM, - DXGI_FORMAT_B4G4R4A4_UNORM, - DXGI_FORMAT_B4G4R4A4_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_B4G4R4A4_UNORM, - GL_RGBA4, - nullptr); + static const Format info(GL_RGBA4, + angle::Format::ID::B4G4R4A4_UNORM, + DXGI_FORMAT_B4G4R4A4_UNORM, + DXGI_FORMAT_B4G4R4A4_UNORM, + DXGI_FORMAT_B4G4R4A4_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_B4G4R4A4_UNORM, + GL_RGBA4, + nullptr, + deviceCaps); return info; } else { - static constexpr Format info(GL_RGBA4, - angle::Format::ID::R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM, - GL_RGBA8, - nullptr); - return info; - } - } - case GL_RGBA8: - { - static constexpr Format info(GL_RGBA8, + static const Format info(GL_RGBA4, angle::Format::ID::R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, @@ -1708,100 +1819,123 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_R8G8B8A8_UNORM, GL_RGBA8, - nullptr); + nullptr, + deviceCaps); + return info; + } + } + case GL_RGBA8: + { + static const Format info(GL_RGBA8, + angle::Format::ID::R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM, + GL_RGBA8, + nullptr, + deviceCaps); return info; } case GL_RGBA8I: { - static constexpr Format info(GL_RGBA8I, - angle::Format::ID::R8G8B8A8_SINT, - DXGI_FORMAT_R8G8B8A8_SINT, - DXGI_FORMAT_R8G8B8A8_SINT, - DXGI_FORMAT_R8G8B8A8_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_SINT, - GL_RGBA8I, - nullptr); + static const Format info(GL_RGBA8I, + angle::Format::ID::R8G8B8A8_SINT, + DXGI_FORMAT_R8G8B8A8_SINT, + DXGI_FORMAT_R8G8B8A8_SINT, + DXGI_FORMAT_R8G8B8A8_SINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_SINT, + GL_RGBA8I, + nullptr, + deviceCaps); return info; } case GL_RGBA8UI: { - static constexpr Format info(GL_RGBA8UI, - angle::Format::ID::R8G8B8A8_UINT, - DXGI_FORMAT_R8G8B8A8_UINT, - DXGI_FORMAT_R8G8B8A8_UINT, - DXGI_FORMAT_R8G8B8A8_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UINT, - GL_RGBA8UI, - nullptr); + static const Format info(GL_RGBA8UI, + angle::Format::ID::R8G8B8A8_UINT, + DXGI_FORMAT_R8G8B8A8_UINT, + DXGI_FORMAT_R8G8B8A8_UINT, + DXGI_FORMAT_R8G8B8A8_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UINT, + GL_RGBA8UI, + nullptr, + deviceCaps); return info; } case GL_RGBA8_SNORM: { - static constexpr Format info(GL_RGBA8_SNORM, - angle::Format::ID::R8G8B8A8_SNORM, - DXGI_FORMAT_R8G8B8A8_SNORM, - DXGI_FORMAT_R8G8B8A8_SNORM, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_SNORM, - GL_RGBA8_SNORM, - nullptr); + static const Format info(GL_RGBA8_SNORM, + angle::Format::ID::R8G8B8A8_SNORM, + DXGI_FORMAT_R8G8B8A8_SNORM, + DXGI_FORMAT_R8G8B8A8_SNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_SNORM, + GL_RGBA8_SNORM, + nullptr, + deviceCaps); return info; } case GL_SRGB8: { - static constexpr Format info(GL_SRGB8, - angle::Format::ID::R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - GL_SRGB8_ALPHA8, - Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>); + static const Format info(GL_SRGB8, + angle::Format::ID::R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + GL_SRGB8_ALPHA8, + Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>, + deviceCaps); return info; } case GL_SRGB8_ALPHA8: { - static constexpr Format info(GL_SRGB8_ALPHA8, - angle::Format::ID::R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, - GL_SRGB8_ALPHA8, - nullptr); + static const Format info(GL_SRGB8_ALPHA8, + angle::Format::ID::R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + GL_SRGB8_ALPHA8, + nullptr, + deviceCaps); return info; } case GL_STENCIL_INDEX8: { if (OnlyFL10Plus(deviceCaps)) { - static constexpr Format info(GL_STENCIL_INDEX8, - angle::Format::ID::D24_UNORM_S8_UINT, - DXGI_FORMAT_R24G8_TYPELESS, - DXGI_FORMAT_R24_UNORM_X8_TYPELESS, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_D24_UNORM_S8_UINT, - DXGI_FORMAT_R24_UNORM_X8_TYPELESS, - GL_RGBA32F, - nullptr); + static const Format info(GL_STENCIL_INDEX8, + angle::Format::ID::D24_UNORM_S8_UINT, + DXGI_FORMAT_R24G8_TYPELESS, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } else { - static constexpr Format info(GL_STENCIL_INDEX8, - angle::Format::ID::D24_UNORM_S8_UINT, - DXGI_FORMAT_D24_UNORM_S8_UINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_D24_UNORM_S8_UINT, - DXGI_FORMAT_UNKNOWN, - GL_RGBA32F, - nullptr); + static const Format info(GL_STENCIL_INDEX8, + angle::Format::ID::D24_UNORM_S8_UINT, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_UNKNOWN, + GL_RGBA32F, + nullptr, + deviceCaps); return info; } } @@ -1812,7 +1946,7 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev // clang-format on UNREACHABLE(); - static constexpr Format defaultInfo; + static const Format defaultInfo; return defaultInfo; } diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Blit9.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Blit9.cpp index 95320f228..2ac8ee3a2 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Blit9.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Blit9.cpp @@ -145,7 +145,13 @@ gl::Error Blit9::setShader(ShaderId source, const char *profile, { const BYTE* shaderCode = g_shaderCode[source]; size_t shaderSize = g_shaderSize[source]; - ANGLE_TRY((mRenderer->*createShader)(reinterpret_cast<const DWORD*>(shaderCode), shaderSize, &shader)); + + gl::Error error = (mRenderer->*createShader)(reinterpret_cast<const DWORD*>(shaderCode), shaderSize, &shader); + if (error.isError()) + { + return error; + } + mCompiledShaders[source] = shader; } @@ -184,10 +190,18 @@ RECT Blit9::getSurfaceRect(IDirect3DSurface9 *surface) const gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest) { - ANGLE_TRY(initialize()); + gl::Error error = initialize(); + if (error.isError()) + { + return error; + } IDirect3DTexture9 *texture = NULL; - ANGLE_TRY(copySurfaceToTexture(source, getSurfaceRect(source), &texture)); + error = copySurfaceToTexture(source, getSurfaceRect(source), &texture); + if (error.isError()) + { + return error; + } IDirect3DDevice9 *device = mRenderer->getDevice(); @@ -216,13 +230,21 @@ gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest) gl::Error Blit9::copy2D(const gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, const gl::Offset &destOffset, TextureStorage *storage, GLint level) { - ANGLE_TRY(initialize()); + gl::Error error = initialize(); + if (error.isError()) + { + return error; + } const gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0); ASSERT(colorbuffer); RenderTarget9 *renderTarget9 = nullptr; - ANGLE_TRY(colorbuffer->getRenderTarget(&renderTarget9)); + error = colorbuffer->getRenderTarget(&renderTarget9); + if (error.isError()) + { + return error; + } ASSERT(renderTarget9); IDirect3DSurface9 *source = renderTarget9->getSurface(); @@ -230,7 +252,7 @@ gl::Error Blit9::copy2D(const gl::Framebuffer *framebuffer, const RECT &sourceRe IDirect3DSurface9 *destSurface = NULL; TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage); - gl::Error error = storage9->getSurfaceLevel(GL_TEXTURE_2D, level, true, &destSurface); + error = storage9->getSurfaceLevel(GL_TEXTURE_2D, level, true, &destSurface); if (error.isError()) { SafeRelease(source); @@ -492,12 +514,9 @@ gl::Error Blit9::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &so D3DSURFACE_DESC sourceDesc; surface->GetDesc(&sourceDesc); - const auto destWidth = sourceRect.right - sourceRect.left; - const auto destHeight = sourceRect.bottom - sourceRect.top; - // Copy the render target into a texture IDirect3DTexture9 *texture; - HRESULT result = device->CreateTexture(destWidth, destHeight, 1, D3DUSAGE_RENDERTARGET, sourceDesc.Format, D3DPOOL_DEFAULT, &texture, NULL); + HRESULT result = device->CreateTexture(sourceRect.right - sourceRect.left, sourceRect.bottom - sourceRect.top, 1, D3DUSAGE_RENDERTARGET, sourceDesc.Format, D3DPOOL_DEFAULT, &texture, NULL); if (FAILED(result)) { @@ -516,40 +535,8 @@ gl::Error Blit9::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &so } mRenderer->endScene(); + result = device->StretchRect(surface, &sourceRect, textureSurface, NULL, D3DTEXF_NONE); - if (sourceRect.left < sourceDesc.Width && sourceRect.right > 0 && - sourceRect.top < sourceDesc.Height && sourceRect.bottom > 0) - { - RECT validSourceRect = sourceRect; - RECT validDestRect = {0, 0, destWidth, destHeight}; - - if (sourceRect.left < 0) { - validSourceRect.left += 0 - sourceRect.left; - validDestRect.left += 0 - sourceRect.left; - } - - if (sourceRect.right > sourceDesc.Width) { - validSourceRect.right -= sourceRect.right - sourceDesc.Width; - validDestRect.right -= sourceRect.right - sourceDesc.Width; - } - - if (sourceRect.top < 0) { - validSourceRect.top += 0 - sourceRect.top; - validDestRect.top += 0 - sourceRect.top; - } - - if (sourceRect.bottom > sourceDesc.Height) { - validSourceRect.bottom -= sourceRect.bottom - sourceDesc.Height; - validDestRect.bottom -= sourceRect.bottom - sourceDesc.Height; - } - - ASSERT(validSourceRect.left < validSourceRect.right); - ASSERT(validSourceRect.top < validSourceRect.bottom); - ASSERT(validDestRect.left < validDestRect.right); - ASSERT(validDestRect.top < validDestRect.bottom); - result = device->StretchRect(surface, &validSourceRect, textureSurface, - &validDestRect, D3DTEXF_NONE); - } SafeRelease(textureSurface); if (FAILED(result)) diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Buffer9.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Buffer9.cpp index b8abf3845..0ee0d8325 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Buffer9.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Buffer9.cpp @@ -12,8 +12,9 @@ namespace rx { -Buffer9::Buffer9(const gl::BufferState &state, Renderer9 *renderer) - : BufferD3D(state, renderer), mSize(0) +Buffer9::Buffer9(Renderer9 *renderer) + : BufferD3D(renderer), + mSize(0) {} Buffer9::~Buffer9() @@ -21,7 +22,7 @@ Buffer9::~Buffer9() mSize = 0; } -gl::Error Buffer9::setData(GLenum /*target*/, const void *data, size_t size, GLenum usage) +gl::Error Buffer9::setData(const void* data, size_t size, GLenum usage) { if (size > mMemory.size()) { @@ -50,7 +51,7 @@ gl::Error Buffer9::getData(const uint8_t **outData) return gl::Error(GL_NO_ERROR); } -gl::Error Buffer9::setSubData(GLenum /*target*/, const void *data, size_t size, size_t offset) +gl::Error Buffer9::setSubData(const void* data, size_t size, size_t offset) { if (offset + size > mMemory.size()) { diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Buffer9.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Buffer9.h index dd7671827..219f8a658 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Buffer9.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Buffer9.h @@ -20,7 +20,7 @@ class Renderer9; class Buffer9 : public BufferD3D { public: - Buffer9(const gl::BufferState &state, Renderer9 *renderer); + Buffer9(Renderer9 *renderer); virtual ~Buffer9(); // BufferD3D implementation @@ -29,16 +29,13 @@ class Buffer9 : public BufferD3D gl::Error getData(const uint8_t **outData) override; // BufferImpl implementation - gl::Error setData(GLenum target, const void *data, size_t size, GLenum usage) override; - gl::Error setSubData(GLenum target, const void *data, size_t size, size_t offset) override; - gl::Error copySubData(BufferImpl *source, - GLintptr sourceOffset, - GLintptr destOffset, - GLsizeiptr size) override; - gl::Error map(GLenum access, GLvoid **mapPtr) override; - gl::Error mapRange(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr) override; - gl::Error unmap(GLboolean *result) override; - gl::Error markTransformFeedbackUsage() override; + virtual gl::Error setData(const void* data, size_t size, GLenum usage); + virtual gl::Error setSubData(const void* data, size_t size, size_t offset); + virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size); + virtual gl::Error map(GLenum access, GLvoid **mapPtr); + virtual gl::Error mapRange(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr); + virtual gl::Error unmap(GLboolean *result); + virtual gl::Error markTransformFeedbackUsage(); private: MemoryBuffer mMemory; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Context9.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Context9.cpp index c38bc1b11..9b31ab927 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Context9.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Context9.cpp @@ -82,9 +82,9 @@ RenderbufferImpl *Context9::createRenderbuffer() return new RenderbufferD3D(mRenderer); } -BufferImpl *Context9::createBuffer(const gl::BufferState &state) +BufferImpl *Context9::createBuffer() { - return new Buffer9(state, mRenderer); + return new Buffer9(mRenderer); } VertexArrayImpl *Context9::createVertexArray(const gl::VertexArrayState &data) diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Context9.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Context9.h index aeb18ff5e..7e3492f9a 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Context9.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Context9.h @@ -39,7 +39,7 @@ class Context9 : public ContextImpl RenderbufferImpl *createRenderbuffer() override; // Buffer creation - BufferImpl *createBuffer(const gl::BufferState &state) override; + BufferImpl *createBuffer() override; // Vertex Array creation VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp index 18e1b3da4..9286d9b0d 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp @@ -205,7 +205,7 @@ gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area, packParams.outputPitch = static_cast<GLuint>(outputPitch); packParams.pack = pack; - PackPixels(packParams, d3dFormatInfo.info(), inputPitch, source, pixels); + PackPixels(packParams, *d3dFormatInfo.info, inputPitch, source, pixels); systemSurface->UnlockRect(); SafeRelease(systemSurface); @@ -404,7 +404,7 @@ GLenum Framebuffer9::getRenderTargetImplementationFormat(RenderTargetD3D *render { RenderTarget9 *renderTarget9 = GetAs<RenderTarget9>(renderTarget); const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(renderTarget9->getD3DFormat()); - return d3dFormatInfo.info().glInternalFormat; + return d3dFormatInfo.info->glInternalFormat; } } // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp index ad2c41584..24c1e9150 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp @@ -61,7 +61,7 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 ASSERT(sourceDesc.Height == 1 || sourceDesc.Height / 2 == destDesc.Height); const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(sourceDesc.Format); - ASSERT(d3dFormatInfo.info().mipGenerationFunction != NULL); + ASSERT(d3dFormatInfo.info->mipGenerationFunction != NULL); D3DLOCKED_RECT sourceLocked = {0}; result = sourceSurface->LockRect(&sourceLocked, NULL, D3DLOCK_READONLY); @@ -85,9 +85,8 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 ASSERT(sourceData && destData); - d3dFormatInfo.info().mipGenerationFunction(sourceDesc.Width, sourceDesc.Height, 1, sourceData, - sourceLocked.Pitch, 0, destData, destLocked.Pitch, - 0); + d3dFormatInfo.info->mipGenerationFunction(sourceDesc.Width, sourceDesc.Height, 1, sourceData, + sourceLocked.Pitch, 0, destData, destLocked.Pitch, 0); destSurface->UnlockRect(); sourceSurface->UnlockRect(); @@ -295,6 +294,7 @@ void Image9::unlock() if (mSurface) { HRESULT result = mSurface->UnlockRect(); + UNUSED_ASSERTION_VARIABLE(result); ASSERT(SUCCEEDED(result)); } } @@ -475,17 +475,17 @@ gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, const gl::Box &a // into the target pixel rectangle. gl::Error Image9::loadData(const gl::Box &area, const gl::PixelUnpackState &unpack, - GLenum inputType, + GLenum type, const void *input, bool applySkipImages) { // 3D textures are not supported by the D3D9 backend. ASSERT(area.z == 0 && area.depth == 1); - ASSERT(getSizedInputFormat(inputType) == mInternalFormat); + const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat); GLuint inputRowPitch = 0; ANGLE_TRY_RESULT( - formatInfo.computeRowPitch(area.width, unpack.alignment, unpack.rowLength), + formatInfo.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength), inputRowPitch); ASSERT(!applySkipImages); ASSERT(unpack.skipPixels == 0); @@ -523,10 +523,11 @@ gl::Error Image9::loadCompressedData(const gl::Box &area, const void *input) const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat); GLsizei inputRowPitch = 0; - ANGLE_TRY_RESULT(formatInfo.computeRowPitch(area.width, 1, 0), inputRowPitch); + ANGLE_TRY_RESULT(formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0), inputRowPitch); GLsizei inputDepthPitch = 0; - ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(area.height, 0, inputDepthPitch), - inputDepthPitch); + ANGLE_TRY_RESULT( + formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1, 0, 0), + inputDepthPitch); const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp index d578d4075..63b33b6f2 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp @@ -525,7 +525,6 @@ void Renderer9::generateDisplayExtensions(egl::DisplayExtensions *outExtensions) outExtensions->d3dShareHandleClientBuffer = true; outExtensions->surfaceD3DTexture2DShareHandle = true; } - outExtensions->d3dTextureClientBuffer = true; outExtensions->querySurfacePointer = true; outExtensions->windowFixedSize = true; @@ -673,111 +672,12 @@ NativeWindowD3D *Renderer9::createNativeWindow(EGLNativeWindowType window, SwapChainD3D *Renderer9::createSwapChain(NativeWindowD3D *nativeWindow, HANDLE shareHandle, - IUnknown *d3dTexture, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) { - return new SwapChain9(this, GetAs<NativeWindow9>(nativeWindow), shareHandle, d3dTexture, - backBufferFormat, depthBufferFormat, orientation); -} - -egl::Error Renderer9::getD3DTextureInfo(IUnknown *d3dTexture, - EGLint *width, - EGLint *height, - GLenum *fboFormat) const -{ - IDirect3DTexture9 *texture = nullptr; - if (FAILED(d3dTexture->QueryInterface(&texture))) - { - return egl::Error(EGL_BAD_PARAMETER, "client buffer is not a IDirect3DTexture9"); - } - - IDirect3DDevice9 *textureDevice = nullptr; - texture->GetDevice(&textureDevice); - if (textureDevice != mDevice) - { - SafeRelease(texture); - return egl::Error(EGL_BAD_PARAMETER, "Texture's device does not match."); - } - SafeRelease(textureDevice); - - D3DSURFACE_DESC desc; - texture->GetLevelDesc(0, &desc); - SafeRelease(texture); - - if (width) - { - *width = static_cast<EGLint>(desc.Width); - } - if (height) - { - *height = static_cast<EGLint>(desc.Height); - } - - // From table egl.restrictions in EGL_ANGLE_d3d_texture_client_buffer. - switch (desc.Format) - { - case D3DFMT_R8G8B8: - case D3DFMT_A8R8G8B8: - case D3DFMT_A16B16G16R16F: - case D3DFMT_A32B32G32R32F: - break; - - default: - return egl::Error(EGL_BAD_PARAMETER, "Unknown client buffer texture format: %u.", - desc.Format); - } - - if (fboFormat) - { - const auto &d3dFormatInfo = d3d9::GetD3DFormatInfo(desc.Format); - ASSERT(d3dFormatInfo.info().id != angle::Format::ID::NONE); - *fboFormat = d3dFormatInfo.info().fboImplementationInternalFormat; - } - - return egl::Error(EGL_SUCCESS); -} - -egl::Error Renderer9::validateShareHandle(const egl::Config *config, - HANDLE shareHandle, - const egl::AttributeMap &attribs) const -{ - if (shareHandle == nullptr) - { - return egl::Error(EGL_BAD_PARAMETER, "NULL share handle."); - } - - EGLint width = attribs.getAsInt(EGL_WIDTH, 0); - EGLint height = attribs.getAsInt(EGL_HEIGHT, 0); - ASSERT(width != 0 && height != 0); - - const d3d9::TextureFormat &backBufferd3dFormatInfo = - d3d9::GetTextureFormatInfo(config->renderTargetFormat); - - IDirect3DTexture9 *texture = nullptr; - HRESULT result = mDevice->CreateTexture(width, height, 1, D3DUSAGE_RENDERTARGET, - backBufferd3dFormatInfo.texFormat, D3DPOOL_DEFAULT, - &texture, &shareHandle); - if (FAILED(result)) - { - return egl::Error(EGL_BAD_PARAMETER, "Failed to open share handle, result: 0x%X.", result); - } - - DWORD levelCount = texture->GetLevelCount(); - - D3DSURFACE_DESC desc; - texture->GetLevelDesc(0, &desc); - SafeRelease(texture); - - if (levelCount != 1 || desc.Width != static_cast<UINT>(width) || - desc.Height != static_cast<UINT>(height) || - desc.Format != backBufferd3dFormatInfo.texFormat) - { - return egl::Error(EGL_BAD_PARAMETER, "Invalid texture parameters in share handle texture."); - } - - return egl::Error(EGL_SUCCESS); + return new SwapChain9(this, GetAs<NativeWindow9>(nativeWindow), shareHandle, backBufferFormat, + depthBufferFormat, orientation); } ContextImpl *Renderer9::createContext(const gl::ContextState &state) @@ -918,9 +818,7 @@ gl::Error Renderer9::setSamplerState(gl::SamplerType type, int index, gl::Textur mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPMAPLODBIAS, static_cast<DWORD>(lodBias)); if (getNativeExtensions().textureFilterAnisotropic) { - DWORD maxAnisotropy = - std::min(mDeviceCaps.MaxAnisotropy, static_cast<DWORD>(samplerState.maxAnisotropy)); - mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXANISOTROPY, maxAnisotropy); + mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXANISOTROPY, (DWORD)samplerState.maxAnisotropy); } } @@ -1007,18 +905,7 @@ gl::Error Renderer9::updateState(Context9 *context, GLenum drawMode) setScissorRectangle(glState.getScissor(), glState.isScissorTestEnabled()); // Setting blend, depth stencil, and rasterizer states - // Since framebuffer->getSamples will return the original samples which may be different with - // the sample counts that we set in render target view, here we use renderTarget->getSamples to - // get the actual samples. - GLsizei samples = 0; - auto firstColorAttachment = framebuffer->getFirstColorbuffer(); - if (firstColorAttachment) - { - ASSERT(firstColorAttachment->isAttached()); - RenderTarget9 *renderTarget = nullptr; - ANGLE_TRY(firstColorAttachment->getRenderTarget(&renderTarget)); - samples = renderTarget->getSamples(); - } + int samples = framebuffer->getSamples(data); gl::RasterizerState rasterizer = glState.getRasterizerState(); rasterizer.pointDrawMode = (drawMode == GL_POINTS); rasterizer.multiSample = (samples != 0); @@ -1041,18 +928,7 @@ gl::Error Renderer9::setBlendDepthRasterStates(const gl::ContextState &glData, G const auto &glState = glData.getState(); auto drawFramebuffer = glState.getDrawFramebuffer(); ASSERT(!drawFramebuffer->hasAnyDirtyBit()); - // Since framebuffer->getSamples will return the original samples which may be different with - // the sample counts that we set in render target view, here we use renderTarget->getSamples to - // get the actual samples. - GLsizei samples = 0; - auto firstColorAttachment = drawFramebuffer->getFirstColorbuffer(); - if (firstColorAttachment) - { - ASSERT(firstColorAttachment->isAttached()); - RenderTarget9 *renderTarget = nullptr; - ANGLE_TRY(firstColorAttachment->getRenderTarget(&renderTarget)); - samples = renderTarget->getSamples(); - } + int samples = drawFramebuffer->getSamples(glData); gl::RasterizerState rasterizer = glState.getRasterizerState(); rasterizer.pointDrawMode = (drawMode == GL_POINTS); rasterizer.multiSample = (samples != 0); @@ -2464,15 +2340,6 @@ gl::Error Renderer9::copyTexture(const gl::Texture *source, return gl::Error(GL_INVALID_OPERATION); } -gl::Error Renderer9::copyCompressedTexture(const gl::Texture *source, - GLint sourceLevel, - TextureStorage *storage, - GLint destLevel) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - gl::Error Renderer9::createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT) { const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(format); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.h index 9c3ae8b04..fb8d8fa21 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.h @@ -18,7 +18,6 @@ #include "libANGLE/renderer/d3d/d3d9/ShaderCache.h" #include "libANGLE/renderer/d3d/d3d9/VertexDeclarationCache.h" #include "libANGLE/renderer/d3d/d3d9/StateManager9.h" -#include "libANGLE/renderer/driver_utils.h" namespace gl { @@ -88,17 +87,9 @@ class Renderer9 : public RendererD3D SwapChainD3D *createSwapChain(NativeWindowD3D *nativeWindow, HANDLE shareHandle, - IUnknown *d3dTexture, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) override; - egl::Error getD3DTextureInfo(IUnknown *d3dTexture, - EGLint *width, - EGLint *height, - GLenum *fboFormat) const override; - egl::Error validateShareHandle(const egl::Config *config, - HANDLE shareHandle, - const egl::AttributeMap &attribs) const override; ContextImpl *createContext(const gl::ContextState &state) override; @@ -220,10 +211,6 @@ class Renderer9 : public RendererD3D bool unpackFlipY, bool unpackPremultiplyAlpha, bool unpackUnmultiplyAlpha) override; - gl::Error copyCompressedTexture(const gl::Texture *source, - GLint sourceLevel, - TextureStorage *storage, - GLint destLevel) override; // RenderTarget creation gl::Error createRenderTarget(int width, diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.cpp index 54885bf81..5fb675ddb 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.cpp @@ -70,7 +70,7 @@ StateManager9::~StateManager9() void StateManager9::initialize() { - mUsingZeroColorMaskWorkaround = IsAMD(mRenderer9->getVendorId()); + mUsingZeroColorMaskWorkaround = mRenderer9->getVendorId() == VENDOR_ID_AMD; } void StateManager9::forceSetBlendState() diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp index 7e6948ebb..b61809050 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp @@ -19,11 +19,10 @@ namespace rx SwapChain9::SwapChain9(Renderer9 *renderer, NativeWindow9 *nativeWindow, HANDLE shareHandle, - IUnknown *d3dTexture, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation) - : SwapChainD3D(shareHandle, d3dTexture, backBufferFormat, depthBufferFormat), + : SwapChainD3D(shareHandle, backBufferFormat, depthBufferFormat), mRenderer(renderer), mWidth(-1), mHeight(-1), @@ -106,37 +105,28 @@ EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapI SafeRelease(mOffscreenTexture); SafeRelease(mDepthStencil); - const d3d9::TextureFormat &backBufferd3dFormatInfo = - d3d9::GetTextureFormatInfo(mOffscreenRenderTargetFormat); - if (mD3DTexture != nullptr) + HANDLE *pShareHandle = NULL; + if (!mNativeWindow->getNativeWindow() && mRenderer->getShareHandleSupport()) { - result = mD3DTexture->QueryInterface(&mOffscreenTexture); - ASSERT(SUCCEEDED(result)); + pShareHandle = &mShareHandle; } - else + + const d3d9::TextureFormat &backBufferd3dFormatInfo = d3d9::GetTextureFormatInfo(mOffscreenRenderTargetFormat); + result = device->CreateTexture(backbufferWidth, backbufferHeight, 1, D3DUSAGE_RENDERTARGET, + backBufferd3dFormatInfo.texFormat, D3DPOOL_DEFAULT, &mOffscreenTexture, + pShareHandle); + if (FAILED(result)) { - HANDLE *pShareHandle = NULL; - if (!mNativeWindow->getNativeWindow() && mRenderer->getShareHandleSupport()) + ERR("Could not create offscreen texture: %08lX", result); + release(); + + if (d3d9::isDeviceLostError(result)) { - pShareHandle = &mShareHandle; + return EGL_CONTEXT_LOST; } - - result = device->CreateTexture(backbufferWidth, backbufferHeight, 1, D3DUSAGE_RENDERTARGET, - backBufferd3dFormatInfo.texFormat, D3DPOOL_DEFAULT, - &mOffscreenTexture, pShareHandle); - if (FAILED(result)) + else { - ERR("Could not create offscreen texture: %08lX", result); - release(); - - if (d3d9::isDeviceLostError(result)) - { - return EGL_CONTEXT_LOST; - } - else - { - return EGL_BAD_ALLOC; - } + return EGL_BAD_ALLOC; } } @@ -201,7 +191,7 @@ EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapI // // Some non-switchable AMD GPUs / drivers do not respect the source rectangle to Present. Therefore, when the vendor ID // is not Intel, the back buffer width must be exactly the same width as the window or horizontal scaling will occur. - if (IsIntel(mRenderer->getVendorId())) + if (mRenderer->getVendorId() == VENDOR_ID_INTEL) { presentParameters.BackBufferWidth = (presentParameters.BackBufferWidth + 63) / 64 * 64; } diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.h index 2e5cce1db..7c21b1788 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/SwapChain9.h @@ -24,7 +24,6 @@ class SwapChain9 : public SwapChainD3D SwapChain9(Renderer9 *renderer, NativeWindow9 *nativeWindow, HANDLE shareHandle, - IUnknown *d3dTexture, GLenum backBufferFormat, GLenum depthBufferFormat, EGLint orientation); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/TextureStorage9.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/TextureStorage9.cpp index db8765218..fd792752a 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/TextureStorage9.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/TextureStorage9.cpp @@ -153,6 +153,7 @@ gl::Error TextureStorage9_2D::getSurfaceLevel(GLenum target, IDirect3DSurface9 **outSurface) { ASSERT(target == GL_TEXTURE_2D); + UNUSED_ASSERTION_VARIABLE(target); IDirect3DBaseTexture9 *baseTexture = NULL; gl::Error error = getBaseTexture(&baseTexture); @@ -328,6 +329,8 @@ gl::Error TextureStorage9_EGLImage::getSurfaceLevel(GLenum target, { ASSERT(target == GL_TEXTURE_2D); ASSERT(level == 0); + UNUSED_ASSERTION_VARIABLE(target); + UNUSED_ASSERTION_VARIABLE(level); RenderTargetD3D *renderTargetD3D = nullptr; gl::Error error = mImage->getRenderTarget(&renderTargetD3D); @@ -347,6 +350,7 @@ gl::Error TextureStorage9_EGLImage::getRenderTarget(const gl::ImageIndex &index, { ASSERT(!index.hasLayer()); ASSERT(index.mipIndex == 0); + UNUSED_ASSERTION_VARIABLE(index); return mImage->getRenderTarget(outRT); } diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/VertexDeclarationCache.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/VertexDeclarationCache.cpp index c2e935e71..afae5188c 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/VertexDeclarationCache.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/VertexDeclarationCache.cpp @@ -94,7 +94,7 @@ gl::Error VertexDeclarationCache::applyDeclaration( // The validation layer checks that there is at least one active attribute with a zero divisor as per // the GL_ANGLE_instanced_arrays spec. - ASSERT(indexedAttribute != invalidAttribIndex || !attributes.size()); + ASSERT(indexedAttribute != invalidAttribIndex); } D3DCAPS9 caps; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/formatutils9.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/formatutils9.cpp index 7cff9a117..8e6d40e25 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/formatutils9.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/formatutils9.cpp @@ -24,13 +24,13 @@ namespace rx namespace d3d9 { -constexpr D3DFORMAT D3DFMT_INTZ = ((D3DFORMAT)(MAKEFOURCC('I', 'N', 'T', 'Z'))); -constexpr D3DFORMAT D3DFMT_NULL = ((D3DFORMAT)(MAKEFOURCC('N', 'U', 'L', 'L'))); +const D3DFORMAT D3DFMT_INTZ = ((D3DFORMAT)(MAKEFOURCC('I', 'N', 'T', 'Z'))); +const D3DFORMAT D3DFMT_NULL = ((D3DFORMAT)(MAKEFOURCC('N', 'U', 'L', 'L'))); // A map to determine the pixel size and mip generation function of a given D3D format typedef std::map<D3DFORMAT, D3DFormat> D3D9FormatInfoMap; -constexpr D3DFormat::D3DFormat() +D3DFormat::D3DFormat() : pixelBytes(0), blockWidth(0), blockHeight(0), @@ -41,188 +41,97 @@ constexpr D3DFormat::D3DFormat() luminanceBits(0), depthBits(0), stencilBits(0), - formatID(angle::Format::ID::NONE) + info(nullptr) { } -constexpr D3DFormat::D3DFormat(GLuint bits, - GLuint blockWidth, - GLuint blockHeight, - GLuint redBits, - GLuint greenBits, - GLuint blueBits, - GLuint alphaBits, - GLuint lumBits, - GLuint depthBits, - GLuint stencilBits, - Format::ID formatID) - : pixelBytes(bits / 8), - blockWidth(blockWidth), - blockHeight(blockHeight), - redBits(redBits), - greenBits(greenBits), - blueBits(blueBits), - alphaBits(alphaBits), - luminanceBits(lumBits), - depthBits(depthBits), - stencilBits(stencilBits), - formatID(formatID) +static inline void InsertD3DFormatInfo(D3D9FormatInfoMap *map, + D3DFORMAT format, + GLuint bits, + GLuint blockWidth, + GLuint blockHeight, + GLuint redBits, + GLuint greenBits, + GLuint blueBits, + GLuint alphaBits, + GLuint lumBits, + GLuint depthBits, + GLuint stencilBits, + Format::ID formatID) { + D3DFormat info; + info.pixelBytes = bits / 8; + info.blockWidth = blockWidth; + info.blockHeight = blockHeight; + info.redBits = redBits; + info.greenBits = greenBits; + info.blueBits = blueBits; + info.alphaBits = alphaBits; + info.luminanceBits = lumBits; + info.depthBits = depthBits; + info.stencilBits = stencilBits; + info.info = &Format::Get(formatID); + + map->insert(std::make_pair(format, info)); +} + +static D3D9FormatInfoMap BuildD3D9FormatInfoMap() +{ + using namespace angle; // For image reading and mipmap generation functions + + D3D9FormatInfoMap map; + + // clang-format off + // | D3DFORMAT | S |W |H | R | G | B | A | L | D | S | ANGLE format | + InsertD3DFormatInfo(&map, D3DFMT_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Format::ID::NONE ); + InsertD3DFormatInfo(&map, D3DFMT_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Format::ID::NONE ); + + InsertD3DFormatInfo(&map, D3DFMT_L8, 8, 1, 1, 0, 0, 0, 0, 8, 0, 0, Format::ID::L8_UNORM ); + InsertD3DFormatInfo(&map, D3DFMT_A8, 8, 1, 1, 0, 0, 0, 8, 0, 0, 0, Format::ID::A8_UNORM ); + InsertD3DFormatInfo(&map, D3DFMT_A8L8, 16, 1, 1, 0, 0, 0, 8, 8, 0, 0, Format::ID::L8A8_UNORM ); + InsertD3DFormatInfo(&map, D3DFMT_A4R4G4B4, 16, 1, 1, 4, 4, 4, 4, 0, 0, 0, Format::ID::B4G4R4A4_UNORM ); + InsertD3DFormatInfo(&map, D3DFMT_A1R5G5B5, 16, 1, 1, 5, 5, 5, 1, 0, 0, 0, Format::ID::B5G5R5A1_UNORM ); + InsertD3DFormatInfo(&map, D3DFMT_R5G6B5, 16, 1, 1, 5, 6, 5, 0, 0, 0, 0, Format::ID::R5G6B5_UNORM ); + InsertD3DFormatInfo(&map, D3DFMT_X8R8G8B8, 32, 1, 1, 8, 8, 8, 0, 0, 0, 0, Format::ID::B8G8R8X8_UNORM ); + InsertD3DFormatInfo(&map, D3DFMT_A8R8G8B8, 32, 1, 1, 8, 8, 8, 8, 0, 0, 0, Format::ID::B8G8R8A8_UNORM ); + InsertD3DFormatInfo(&map, D3DFMT_R16F, 16, 1, 1, 16, 0, 0, 0, 0, 0, 0, Format::ID::R16_FLOAT ); + InsertD3DFormatInfo(&map, D3DFMT_G16R16F, 32, 1, 1, 16, 16, 0, 0, 0, 0, 0, Format::ID::R16G16_FLOAT ); + InsertD3DFormatInfo(&map, D3DFMT_A16B16G16R16F, 64, 1, 1, 16, 16, 16, 16, 0, 0, 0, Format::ID::R16G16B16A16_FLOAT ); + InsertD3DFormatInfo(&map, D3DFMT_R32F, 32, 1, 1, 32, 0, 0, 0, 0, 0, 0, Format::ID::R32_FLOAT ); + InsertD3DFormatInfo(&map, D3DFMT_G32R32F, 64, 1, 1, 32, 32, 0, 0, 0, 0, 0, Format::ID::R32G32_FLOAT ); + InsertD3DFormatInfo(&map, D3DFMT_A32B32G32R32F, 128, 1, 1, 32, 32, 32, 32, 0, 0, 0, Format::ID::R32G32B32A32_FLOAT ); + + InsertD3DFormatInfo(&map, D3DFMT_D16, 16, 1, 1, 0, 0, 0, 0, 0, 16, 0, Format::ID::D16_UNORM ); + InsertD3DFormatInfo(&map, D3DFMT_D24S8, 32, 1, 1, 0, 0, 0, 0, 0, 24, 8, Format::ID::D24_UNORM_S8_UINT ); + InsertD3DFormatInfo(&map, D3DFMT_D24X8, 32, 1, 1, 0, 0, 0, 0, 0, 24, 0, Format::ID::D16_UNORM ); + InsertD3DFormatInfo(&map, D3DFMT_D32, 32, 1, 1, 0, 0, 0, 0, 0, 32, 0, Format::ID::D32_UNORM ); + + InsertD3DFormatInfo(&map, D3DFMT_INTZ, 32, 1, 1, 0, 0, 0, 0, 0, 24, 8, Format::ID::D24_UNORM_S8_UINT ); + + InsertD3DFormatInfo(&map, D3DFMT_DXT1, 64, 4, 4, 0, 0, 0, 0, 0, 0, 0, Format::ID::BC1_RGBA_UNORM_BLOCK); + InsertD3DFormatInfo(&map, D3DFMT_DXT3, 128, 4, 4, 0, 0, 0, 0, 0, 0, 0, Format::ID::BC2_RGBA_UNORM_BLOCK); + InsertD3DFormatInfo(&map, D3DFMT_DXT5, 128, 4, 4, 0, 0, 0, 0, 0, 0, 0, Format::ID::BC3_RGBA_UNORM_BLOCK); + // clang-format on + + return map; } const D3DFormat &GetD3DFormatInfo(D3DFORMAT format) { - if (format == D3DFMT_NULL) + static const D3D9FormatInfoMap infoMap = BuildD3D9FormatInfoMap(); + D3D9FormatInfoMap::const_iterator iter = infoMap.find(format); + if (iter != infoMap.end()) { - static constexpr D3DFormat info(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Format::ID::NONE); - return info; + return iter->second; } - - if (format == D3DFMT_INTZ) + else { - static constexpr D3DFormat info(32, 1, 1, 0, 0, 0, 0, 0, 24, 8, - Format::ID::D24_UNORM_S8_UINT); - return info; + static const D3DFormat defaultInfo; + return defaultInfo; } +} - switch (format) - { - case D3DFMT_UNKNOWN: - { - static constexpr D3DFormat info(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Format::ID::NONE); - return info; - } - - case D3DFMT_L8: - { - static constexpr D3DFormat info(8, 1, 1, 0, 0, 0, 0, 8, 0, 0, Format::ID::L8_UNORM); - return info; - } - case D3DFMT_A8: - { - static constexpr D3DFormat info(8, 1, 1, 0, 0, 0, 8, 0, 0, 0, Format::ID::A8_UNORM); - return info; - } - case D3DFMT_A8L8: - { - static constexpr D3DFormat info(16, 1, 1, 0, 0, 0, 8, 8, 0, 0, Format::ID::L8A8_UNORM); - return info; - } - - case D3DFMT_A4R4G4B4: - { - static constexpr D3DFormat info(16, 1, 1, 4, 4, 4, 4, 0, 0, 0, - Format::ID::B4G4R4A4_UNORM); - return info; - } - case D3DFMT_A1R5G5B5: - { - static constexpr D3DFormat info(16, 1, 1, 5, 5, 5, 1, 0, 0, 0, - Format::ID::B5G5R5A1_UNORM); - return info; - } - case D3DFMT_R5G6B5: - { - static constexpr D3DFormat info(16, 1, 1, 5, 6, 5, 0, 0, 0, 0, - Format::ID::R5G6B5_UNORM); - return info; - } - case D3DFMT_X8R8G8B8: - { - static constexpr D3DFormat info(32, 1, 1, 8, 8, 8, 0, 0, 0, 0, - Format::ID::B8G8R8X8_UNORM); - return info; - } - case D3DFMT_A8R8G8B8: - { - static constexpr D3DFormat info(32, 1, 1, 8, 8, 8, 8, 0, 0, 0, - Format::ID::B8G8R8A8_UNORM); - return info; - } - - case D3DFMT_R16F: - { - static constexpr D3DFormat info(16, 1, 1, 16, 0, 0, 0, 0, 0, 0, Format::ID::R16_FLOAT); - return info; - } - case D3DFMT_G16R16F: - { - static constexpr D3DFormat info(32, 1, 1, 16, 16, 0, 0, 0, 0, 0, - Format::ID::R16G16_FLOAT); - return info; - } - case D3DFMT_A16B16G16R16F: - { - static constexpr D3DFormat info(64, 1, 1, 16, 16, 16, 16, 0, 0, 0, - Format::ID::R16G16B16A16_FLOAT); - return info; - } - case D3DFMT_R32F: - { - static constexpr D3DFormat info(32, 1, 1, 32, 0, 0, 0, 0, 0, 0, Format::ID::R32_FLOAT); - return info; - } - case D3DFMT_G32R32F: - { - static constexpr D3DFormat info(64, 1, 1, 32, 32, 0, 0, 0, 0, 0, - Format::ID::R32G32_FLOAT); - return info; - } - case D3DFMT_A32B32G32R32F: - { - static constexpr D3DFormat info(128, 1, 1, 32, 32, 32, 32, 0, 0, 0, - Format::ID::R32G32B32A32_FLOAT); - return info; - } - - case D3DFMT_D16: - { - static constexpr D3DFormat info(16, 1, 1, 0, 0, 0, 0, 0, 16, 0, Format::ID::D16_UNORM); - return info; - } - case D3DFMT_D24S8: - { - static constexpr D3DFormat info(32, 1, 1, 0, 0, 0, 0, 0, 24, 8, - Format::ID::D24_UNORM_S8_UINT); - return info; - } - case D3DFMT_D24X8: - { - static constexpr D3DFormat info(32, 1, 1, 0, 0, 0, 0, 0, 24, 0, Format::ID::D16_UNORM); - return info; - } - case D3DFMT_D32: - { - static constexpr D3DFormat info(32, 1, 1, 0, 0, 0, 0, 0, 32, 0, Format::ID::D32_UNORM); - return info; - } - - case D3DFMT_DXT1: - { - static constexpr D3DFormat info(64, 4, 4, 0, 0, 0, 0, 0, 0, 0, - Format::ID::BC1_RGBA_UNORM_BLOCK); - return info; - } - case D3DFMT_DXT3: - { - static constexpr D3DFormat info(128, 4, 4, 0, 0, 0, 0, 0, 0, 0, - Format::ID::BC2_RGBA_UNORM_BLOCK); - return info; - } - case D3DFMT_DXT5: - { - static constexpr D3DFormat info(128, 4, 4, 0, 0, 0, 0, 0, 0, 0, - Format::ID::BC3_RGBA_UNORM_BLOCK); - return info; - } - default: - { - static constexpr D3DFormat defaultInfo; - return defaultInfo; - } - } -} typedef std::pair<GLint, InitializeTextureDataFunction> InternalFormatInitialzerPair; typedef std::map<GLint, InitializeTextureDataFunction> InternalFormatInitialzerMap; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/formatutils9.h b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/formatutils9.h index 828252d33..2937e14e7 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/formatutils9.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/formatutils9.h @@ -29,20 +29,7 @@ namespace d3d9 struct D3DFormat { - constexpr D3DFormat(); - constexpr D3DFormat(GLuint pixelBytes, - GLuint blockWidth, - GLuint blockHeight, - GLuint redBits, - GLuint greenBits, - GLuint blueBits, - GLuint alphaBits, - GLuint luminanceBits, - GLuint depthBits, - GLuint stencilBits, - angle::Format::ID formatID); - - const angle::Format &info() const { return angle::Format::Get(formatID); } + D3DFormat(); GLuint pixelBytes; GLuint blockWidth; @@ -57,7 +44,7 @@ struct D3DFormat GLuint depthBits; GLuint stencilBits; - angle::Format::ID formatID; + const angle::Format *info; }; const D3DFormat &GetD3DFormatInfo(D3DFORMAT format); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp index a6e1f239d..1883636a3 100755 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp @@ -18,7 +18,6 @@ #include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h" #include "libANGLE/renderer/d3d/FramebufferD3D.h" #include "libANGLE/renderer/d3d/WorkaroundsD3D.h" -#include "libANGLE/renderer/driver_utils.h" #include "third_party/systeminfo/SystemInfo.h" @@ -307,7 +306,7 @@ GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type) bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format) { - GLenum internalFormat = d3d9::GetD3DFormatInfo(d3dformat).info().glInternalFormat; + GLenum internalFormat = d3d9::GetD3DFormatInfo(d3dformat).info->glInternalFormat; GLenum convertedFormat = gl::GetInternalFormatInfo(internalFormat).format; return convertedFormat == format; } @@ -541,12 +540,12 @@ void GenerateCaps(IDirect3D9 *d3d9, { // ATI cards on XP have problems with non-power-of-two textures. extensions->textureNPOT = !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_POW2) && - !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP_POW2) && - !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) && - !(!isWindowsVistaOrGreater() && IsAMD(adapterId.VendorId)); + !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP_POW2) && + !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) && + !(!isWindowsVistaOrGreater() && adapterId.VendorId == VENDOR_ID_AMD); // Disable depth texture support on AMD cards (See ANGLE issue 839) - if (IsAMD(adapterId.VendorId)) + if (adapterId.VendorId == VENDOR_ID_AMD) { extensions->depthTextures = false; } diff --git a/gfx/angle/src/libANGLE/renderer/driver_utils.cpp b/gfx/angle/src/libANGLE/renderer/driver_utils.cpp deleted file mode 100644 index 7e7b2d8a2..000000000 --- a/gfx/angle/src/libANGLE/renderer/driver_utils.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// -// Copyright (c) 2016 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. -// - -// driver_utils.h : provides more information about current driver. - -#include <algorithm> - -#include "libANGLE/renderer/driver_utils.h" - -namespace rx -{ -// Intel -// Referenced from https://cgit.freedesktop.org/vaapi/intel-driver/tree/src/i965_pciids.h -namespace -{ -// gen7 -const uint32_t Haswell[] = { - 0x0402, 0x0406, 0x040A, 0x040B, 0x040E, 0x0C02, 0x0C06, 0x0C0A, 0x0C0B, 0x0C0E, - 0x0A02, 0x0A06, 0x0A0A, 0x0A0B, 0x0A0E, 0x0D02, 0x0D06, 0x0D0A, 0x0D0B, 0x0D0E, // hsw_gt1 - 0x0412, 0x0416, 0x041A, 0x041B, 0x041E, 0x0C12, 0x0C16, 0x0C1A, 0x0C1B, 0x0C1E, - 0x0A12, 0x0A16, 0x0A1A, 0x0A1B, 0x0A1E, 0x0D12, 0x0D16, 0x0D1A, 0x0D1B, 0x0D1E, // hsw_gt2 - 0x0422, 0x0426, 0x042A, 0x042B, 0x042E, 0x0C22, 0x0C26, 0x0C2A, 0x0C2B, 0x0C2E, - 0x0A22, 0x0A26, 0x0A2A, 0x0A2B, 0x0A2E, 0x0D22, 0x0D26, 0x0D2A, 0x0D2B, 0x0D2E // hsw_gt3 -}; - -// gen8 -const uint32_t Broadwell[] = {0x1602, 0x1606, 0x160A, 0x160B, 0x160D, 0x160E, - 0x1612, 0x1616, 0x161A, 0x161B, 0x161D, 0x161E, - 0x1622, 0x1626, 0x162A, 0x162B, 0x162D, 0x162E}; - -const uint32_t CherryView[] = {0x22B0, 0x22B1, 0x22B2, 0x22B3}; - -// gen9 -const uint32_t Skylake[] = {0x1902, 0x1906, 0x190A, 0x190B, 0x190E, 0x1912, 0x1913, 0x1915, 0x1916, - 0x1917, 0x191A, 0x191B, 0x191D, 0x191E, 0x1921, 0x1923, 0x1926, 0x1927, - 0x192A, 0x192B, 0x192D, 0x1932, 0x193A, 0x193B, 0x193D}; - -const uint32_t Broxton[] = {0x0A84, 0x1A84, 0x1A85, 0x5A84, 0x5A85}; - -// gen9p5 -const uint32_t Kabylake[] = {0x5916, 0x5913, 0x5906, 0x5926, 0x5921, 0x5915, 0x590E, - 0x591E, 0x5912, 0x5917, 0x5902, 0x591B, 0x593B, 0x590B, - 0x591A, 0x590A, 0x591D, 0x5908, 0x5923, 0x5927}; - -} // anonymous namespace - -bool IsHaswell(uint32_t DeviceId) -{ - return std::find(std::begin(Haswell), std::end(Haswell), DeviceId) != std::end(Haswell); -} - -bool IsBroadwell(uint32_t DeviceId) -{ - return std::find(std::begin(Broadwell), std::end(Broadwell), DeviceId) != std::end(Broadwell); -} - -bool IsCherryView(uint32_t DeviceId) -{ - return std::find(std::begin(CherryView), std::end(CherryView), DeviceId) != - std::end(CherryView); -} - -bool IsSkylake(uint32_t DeviceId) -{ - return std::find(std::begin(Skylake), std::end(Skylake), DeviceId) != std::end(Skylake); -} - -bool IsBroxton(uint32_t DeviceId) -{ - return std::find(std::begin(Broxton), std::end(Broxton), DeviceId) != std::end(Broxton); -} - -bool IsKabylake(uint32_t DeviceId) -{ - return std::find(std::begin(Kabylake), std::end(Kabylake), DeviceId) != std::end(Kabylake); -} - -} // namespace rx
\ No newline at end of file diff --git a/gfx/angle/src/libANGLE/renderer/driver_utils.h b/gfx/angle/src/libANGLE/renderer/driver_utils.h deleted file mode 100644 index 865de73e1..000000000 --- a/gfx/angle/src/libANGLE/renderer/driver_utils.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// Copyright (c) 2016 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. -// - -// driver_utils.h : provides more information about current driver. - -#ifndef LIBANGLE_RENDERER_DRIVER_UTILS_H_ -#define LIBANGLE_RENDERER_DRIVER_UTILS_H_ - -#include "libANGLE/angletypes.h" - -namespace rx -{ - -enum VendorID : uint32_t -{ - VENDOR_ID_UNKNOWN = 0x0, - VENDOR_ID_AMD = 0x1002, - VENDOR_ID_INTEL = 0x8086, - VENDOR_ID_NVIDIA = 0x10DE, - // This is Qualcomm PCI Vendor ID. - // Android doesn't have a PCI bus, but all we need is a unique id. - VENDOR_ID_QUALCOMM = 0x5143, -}; - -inline bool IsAMD(uint32_t vendor_id) -{ - return vendor_id == VENDOR_ID_AMD; -} - -inline bool IsIntel(uint32_t vendor_id) -{ - return vendor_id == VENDOR_ID_INTEL; -} - -inline bool IsNvidia(uint32_t vendor_id) -{ - return vendor_id == VENDOR_ID_NVIDIA; -} - -inline bool IsQualcomm(uint32_t vendor_id) -{ - return vendor_id == VENDOR_ID_QUALCOMM; -} - -// Intel -bool IsHaswell(uint32_t DeviceId); -bool IsBroadwell(uint32_t DeviceId); -bool IsCherryView(uint32_t DeviceId); -bool IsSkylake(uint32_t DeviceId); -bool IsBroxton(uint32_t DeviceId); -bool IsKabylake(uint32_t DeviceId); - -} // namespace rx -#endif // LIBANGLE_RENDERER_DRIVER_UTILS_H_
\ No newline at end of file diff --git a/gfx/angle/src/libANGLE/renderer/gen_angle_format_table.py b/gfx/angle/src/libANGLE/renderer/gen_angle_format_table.py index 6b56bb40c..7356fc414 100755 --- a/gfx/angle/src/libANGLE/renderer/gen_angle_format_table.py +++ b/gfx/angle/src/libANGLE/renderer/gen_angle_format_table.py @@ -16,7 +16,7 @@ import re import sys template_autogen_h = """// GENERATED FILE - DO NOT EDIT. -// Generated by {script_name} using data from {data_source_name} +// Generated by gen_angle_format_table.py using data from angle_format_data.json // // Copyright {copyright_year} The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be @@ -35,8 +35,8 @@ enum class Format::ID }} // namespace angle """ -template_autogen_inl = """// GENERATED FILE - DO NOT EDIT. -// Generated by {script_name} using data from {data_source_name} +template_autogen_cpp = """// GENERATED FILE - DO NOT EDIT. +// Generated by gen_angle_format_table.py using data from angle_format_data.json // // Copyright {copyright_year} The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be @@ -54,21 +54,21 @@ template_autogen_inl = """// GENERATED FILE - DO NOT EDIT. namespace angle {{ -static constexpr rx::FastCopyFunctionMap::Entry BGRAEntry = {{GL_RGBA, GL_UNSIGNED_BYTE, - CopyBGRA8ToRGBA8}}; -static constexpr rx::FastCopyFunctionMap BGRACopyFunctions = {{&BGRAEntry, 1}}; -static constexpr rx::FastCopyFunctionMap NoCopyFunctions; - -constexpr Format g_formatInfoTable[] = {{ - // clang-format off - {{ Format::ID::NONE, GL_NONE, GL_NONE, nullptr, NoCopyFunctions, nullptr, GL_NONE, 0, 0, 0, 0, 0, 0 }}, -{angle_format_info_cases} // clang-format on -}}; - // static const Format &Format::Get(ID id) {{ - return g_formatInfoTable[static_cast<size_t>(id)]; + // clang-format off + switch (id) + {{ +{angle_format_info_cases} + default: + UNREACHABLE(); + break; + }} + // clang-format on + + static const Format noneInfo(ID::NONE, GL_NONE, GL_NONE, nullptr, nullptr); + return noneInfo; }} }} // namespace angle @@ -123,7 +123,14 @@ def get_color_read_function(angle_format): } return 'ReadColor<' + channel_struct + ', '+ component_type_map[angle_format['componentType']] + '>' -format_entry_template = """ {{ Format::ID::{id}, {glInternalFormat}, {fboImplementationInternalFormat}, {mipGenerationFunction}, {fastCopyFunctions}, {colorReadFunction}, {namedComponentType}, {R}, {G}, {B}, {A}, {D}, {S} }}, +format_entry_template = """{space}{{ +{space} static const Format info(ID::{id}, +{space} {glInternalFormat}, +{space} {fboImplementationInternalFormat}, +{space} {mipGenerationFunction}, +{space} {colorReadFunction}); +{space} return info; +{space}}} """ def get_component_type(format_id): @@ -167,29 +174,13 @@ def get_bits(format_id): bits[token[0]] = int(token[1:]) return bits -def get_named_component_type(component_type): - if component_type == "snorm": - return "GL_SIGNED_NORMALIZED" - elif component_type == "unorm": - return "GL_UNSIGNED_NORMALIZED" - elif component_type == "float": - return "GL_FLOAT" - elif component_type == "uint": - return "GL_UNSIGNED_INT" - elif component_type == "int": - return "GL_INT" - elif component_type == "none": - return "GL_NONE" - else: - raise ValueError("Unknown component type for " + component_type) - def json_to_table_data(format_id, json, angle_to_gl): table_data = "" parsed = { + "space": " ", "id": format_id, - "fastCopyFunctions": "NoCopyFunctions", } for k, v in json.iteritems(): @@ -214,25 +205,14 @@ def json_to_table_data(format_id, json, angle_to_gl): parsed["mipGenerationFunction"] = get_mip_generation_function(parsed) parsed["colorReadFunction"] = get_color_read_function(parsed) - for channel in "ABDGLRS": - if parsed["bits"] != None and channel in parsed["bits"]: - parsed[channel] = parsed["bits"][channel] - else: - parsed[channel] = "0" - - parsed["namedComponentType"] = get_named_component_type(parsed["componentType"]) - - if format_id == "B8G8R8A8_UNORM": - parsed["fastCopyFunctions"] = "BGRACopyFunctions" - return format_entry_template.format(**parsed) -def parse_angle_format_table(all_angle, json_data, angle_to_gl): +def parse_json_into_angle_format_switch_string(all_angle, json_data, angle_to_gl): table_data = '' for format_id in sorted(all_angle): - if format_id != "NONE": - format_info = json_data[format_id] if format_id in json_data else {} - table_data += json_to_table_data(format_id, format_info, angle_to_gl) + format_info = json_data[format_id] if format_id in json_data else {} + table_data += ' case ID::' + format_id + ':\n' + table_data += json_to_table_data(format_id, format_info, angle_to_gl) return table_data @@ -246,27 +226,22 @@ def gen_enum_string(all_angle): gl_to_angle = angle_format.load_forward_table('angle_format_map.json') angle_to_gl = angle_format.load_inverse_table('angle_format_map.json') -data_source_name = 'angle_format_data.json' -json_data = angle_format.load_json(data_source_name) +json_data = angle_format.load_json('angle_format_data.json') all_angle = angle_to_gl.keys() -angle_format_cases = parse_angle_format_table( +angle_format_cases = parse_json_into_angle_format_switch_string( all_angle, json_data, angle_to_gl) -output_cpp = template_autogen_inl.format( - script_name = sys.argv[0], - copyright_year = date.today().year, - angle_format_info_cases = angle_format_cases, - data_source_name = data_source_name) -with open('Format_table_autogen.cpp', 'wt') as out_file: +output_cpp = template_autogen_cpp.format( + copyright_year=date.today().year, + angle_format_info_cases=angle_format_cases) +with open('Format_autogen.cpp', 'wt') as out_file: out_file.write(output_cpp) out_file.close() enum_data = gen_enum_string(all_angle) output_h = template_autogen_h.format( - script_name = sys.argv[0], - copyright_year = date.today().year, - angle_format_enum = enum_data, - data_source_name = data_source_name) + copyright_year=date.today().year, + angle_format_enum=enum_data) with open('Format_ID_autogen.inl', 'wt') as out_file: out_file.write(output_h) out_file.close() diff --git a/gfx/angle/src/libANGLE/renderer/gl/BlitGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/BlitGL.cpp index b181822ff..0a624dcb1 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/BlitGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/BlitGL.cpp @@ -30,7 +30,7 @@ gl::Error CheckCompileStatus(const rx::FunctionsGL *functions, GLuint shader) return gl::Error(GL_OUT_OF_MEMORY, "Failed to compile internal blit shader."); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error CheckLinkStatus(const rx::FunctionsGL *functions, GLuint program) @@ -43,7 +43,7 @@ gl::Error CheckLinkStatus(const rx::FunctionsGL *functions, GLuint program) return gl::Error(GL_OUT_OF_MEMORY, "Failed to link internal blit program."); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } } // anonymous namespace @@ -58,9 +58,6 @@ BlitGL::BlitGL(const FunctionsGL *functions, mWorkarounds(workarounds), mStateManager(stateManager), mBlitProgram(0), - mSourceTextureLocation(-1), - mScaleLocation(-1), - mOffsetLocation(-1), mScratchFBO(0), mVAO(0) { @@ -133,7 +130,11 @@ gl::Error BlitGL::copySubImageToLUMAWorkaroundTexture(GLuint texture, const gl::Rectangle &sourceArea, const gl::Framebuffer *source) { - ANGLE_TRY(initializeResources()); + gl::Error error = initializeResources(); + if (error.isError()) + { + return error; + } // Blit the framebuffer to the first scratch texture const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source); @@ -145,6 +146,7 @@ gl::Error BlitGL::copySubImageToLUMAWorkaroundTexture(GLuint texture, const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(copyTexImageFormat.internalFormat); + mStateManager->activeTexture(0); mStateManager->bindTexture(GL_TEXTURE_2D, mScratchTextures[0]); mFunctions->copyTexImage2D(GL_TEXTURE_2D, 0, copyTexImageFormat.internalFormat, sourceArea.x, sourceArea.y, sourceArea.width, sourceArea.height, 0); @@ -169,6 +171,7 @@ gl::Error BlitGL::copySubImageToLUMAWorkaroundTexture(GLuint texture, mScratchTextures[1], 0); // Render to the destination texture, sampling from the scratch texture + mStateManager->useProgram(mBlitProgram); mStateManager->setViewport(gl::Rectangle(0, 0, sourceArea.width, sourceArea.height)); mStateManager->setScissorTestEnabled(false); mStateManager->setDepthRange(0.0f, 1.0f); @@ -183,192 +186,16 @@ gl::Error BlitGL::copySubImageToLUMAWorkaroundTexture(GLuint texture, mStateManager->setRasterizerDiscardEnabled(false); mStateManager->bindTexture(GL_TEXTURE_2D, mScratchTextures[0]); - setScratchTextureParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST); - setScratchTextureParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST); - mStateManager->activeTexture(0); - mStateManager->bindTexture(GL_TEXTURE_2D, mScratchTextures[0]); - - mStateManager->useProgram(mBlitProgram); - mFunctions->uniform1i(mSourceTextureLocation, 0); - mFunctions->uniform2f(mScaleLocation, 1.0, 1.0); - mFunctions->uniform2f(mOffsetLocation, 0.0, 0.0); - mStateManager->bindVertexArray(mVAO, 0); - mFunctions->drawArrays(GL_TRIANGLES, 0, 3); + mFunctions->drawArrays(GL_TRIANGLES, 0, 6); - // Copy the swizzled texture to the destination texture + // Finally, copy the swizzled texture to the destination texture mStateManager->bindTexture(textureType, texture); mFunctions->copyTexSubImage2D(target, static_cast<GLint>(level), destOffset.x, destOffset.y, 0, 0, sourceArea.width, sourceArea.height); - // Finally orphan the scratch textures so they can be GCed by the driver. - orphanScratchTextures(); - - return gl::NoError(); -} - -gl::Error BlitGL::blitColorBufferWithShader(const gl::Framebuffer *source, - const gl::Framebuffer *dest, - const gl::Rectangle &sourceAreaIn, - const gl::Rectangle &destAreaIn, - GLenum filter) -{ - ANGLE_TRY(initializeResources()); - - // Normalize the destination area to have positive width and height because we will use - // glViewport to set it, which doesn't allow negative width or height. - gl::Rectangle sourceArea = sourceAreaIn; - gl::Rectangle destArea = destAreaIn; - if (destArea.width < 0) - { - destArea.x += destArea.width; - destArea.width = -destArea.width; - sourceArea.x += sourceArea.width; - sourceArea.width = -sourceArea.width; - } - if (destArea.height < 0) - { - destArea.y += destArea.height; - destArea.height = -destArea.height; - sourceArea.y += sourceArea.height; - sourceArea.height = -sourceArea.height; - } - - const gl::FramebufferAttachment *readAttachment = source->getReadColorbuffer(); - ASSERT(readAttachment->getSamples() <= 1); - - // Compute the part of the source that will be sampled. - gl::Rectangle inBoundsSource; - { - gl::Extents sourceSize = readAttachment->getSize(); - gl::Rectangle sourceBounds(0, 0, sourceSize.width, sourceSize.height); - gl::ClipRectangle(sourceArea, sourceBounds, &inBoundsSource); - - // Note that inBoundsSource will have lost the orientation information. - ASSERT(inBoundsSource.width >= 0 && inBoundsSource.height >= 0); - - // Early out when the sampled part is empty as the blit will be a noop, - // and it prevents a division by zero in later computations. - if (inBoundsSource.width == 0 || inBoundsSource.height == 0) - { - return gl::NoError(); - } - } - - // The blit will be emulated by getting the source of the blit in a texture and sampling it - // with CLAMP_TO_EDGE. The quad used to draw can trivially compute texture coordinates going - // from (0, 0) to (1, 1). These texture coordinates will need to be transformed to make two - // regions match: - // - The region of the texture representing the source framebuffer region that will be sampled - // - The region of the drawn quad that corresponds to non-clamped blit, this is the same as the - // region of the source rectangle that is inside the source attachment. - // - // These two regions, T (texture) and D (dest) are defined by their offset in texcoord space - // in (0, 1)^2 and their size in texcoord space in (-1, 1)^2. The size can be negative to - // represent the orientation of the blit. - // - // Then if P is the quad texcoord, Q the texcoord inside T, and R the texture texcoord: - // - Q = (P - D.offset) / D.size - // - Q = (R - T.offset) / T.size - // Hence R = (P - D.offset) / D.size * T.size - T.offset - // = P * (T.size / D.size) + (T.offset - D.offset * T.size / D.size) - - GLuint textureId; - gl::Vector2 TOffset; - gl::Vector2 TSize; - - // TODO(cwallez) once texture dirty bits are landed, reuse attached texture instead of using - // CopyTexImage2D - { - textureId = mScratchTextures[0]; - TOffset = gl::Vector2(0.0, 0.0); - TSize = gl::Vector2(1.0, 1.0); - if (sourceArea.width < 0) - { - TOffset.x = 1.0; - TSize.x = -1.0; - } - if (sourceArea.height < 0) - { - TOffset.y = 1.0; - TSize.y = -1.0; - } - - GLenum format = readAttachment->getFormat().info->internalFormat; - const FramebufferGL *sourceGL = GetImplAs<FramebufferGL>(source); - mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceGL->getFramebufferID()); - mStateManager->bindTexture(GL_TEXTURE_2D, textureId); - - mFunctions->copyTexImage2D(GL_TEXTURE_2D, 0, format, inBoundsSource.x, inBoundsSource.y, - inBoundsSource.width, inBoundsSource.height, 0); - } - - // Compute normalized sampled draw quad region - // It is the same as the region of the source rectangle that is in bounds. - gl::Vector2 DOffset; - gl::Vector2 DSize; - { - ASSERT(sourceArea.width != 0 && sourceArea.height != 0); - gl::Rectangle orientedInBounds = inBoundsSource; - if (sourceArea.width < 0) - { - orientedInBounds.x += orientedInBounds.width; - orientedInBounds.width = -orientedInBounds.width; - } - if (sourceArea.height < 0) - { - orientedInBounds.y += orientedInBounds.height; - orientedInBounds.height = -orientedInBounds.height; - } - - DOffset = - gl::Vector2(static_cast<float>(orientedInBounds.x - sourceArea.x) / sourceArea.width, - static_cast<float>(orientedInBounds.y - sourceArea.y) / sourceArea.height); - DSize = gl::Vector2(static_cast<float>(orientedInBounds.width) / sourceArea.width, - static_cast<float>(orientedInBounds.height) / sourceArea.height); - } - - ASSERT(DSize.x != 0.0 && DSize.y != 0.0); - gl::Vector2 texCoordScale = gl::Vector2(TSize.x / DSize.x, TSize.y / DSize.y); - gl::Vector2 texCoordOffset = gl::Vector2(TOffset.x - DOffset.x * texCoordScale.x, - TOffset.y - DOffset.y * texCoordScale.y); - - // Reset all the state except scissor and viewport - mStateManager->setDepthRange(0.0f, 1.0f); - mStateManager->setBlendEnabled(false); - mStateManager->setColorMask(true, true, true, true); - mStateManager->setSampleAlphaToCoverageEnabled(false); - mStateManager->setSampleCoverageEnabled(false); - mStateManager->setDepthTestEnabled(false); - mStateManager->setStencilTestEnabled(false); - mStateManager->setCullFaceEnabled(false); - mStateManager->setPolygonOffsetFillEnabled(false); - mStateManager->setRasterizerDiscardEnabled(false); - - // Use the viewport to draw exactly to the destination rectangle - mStateManager->setViewport(destArea); - - // Set uniforms - setScratchTextureParameter(GL_TEXTURE_MIN_FILTER, filter); - setScratchTextureParameter(GL_TEXTURE_MAG_FILTER, filter); - setScratchTextureParameter(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - setScratchTextureParameter(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - mStateManager->activeTexture(0); - mStateManager->bindTexture(GL_TEXTURE_2D, mScratchTextures[0]); - - mStateManager->useProgram(mBlitProgram); - mFunctions->uniform1i(mSourceTextureLocation, 0); - mFunctions->uniform2f(mScaleLocation, texCoordScale.x, texCoordScale.y); - mFunctions->uniform2f(mOffsetLocation, texCoordOffset.x, texCoordOffset.y); - - const FramebufferGL *destGL = GetImplAs<FramebufferGL>(dest); - mStateManager->bindFramebuffer(GL_DRAW_FRAMEBUFFER, destGL->getFramebufferID()); - - mStateManager->bindVertexArray(mVAO, 0); - mFunctions->drawArrays(GL_TRIANGLES, 0, 3); - - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } gl::Error BlitGL::initializeResources() @@ -378,38 +205,41 @@ gl::Error BlitGL::initializeResources() mBlitProgram = mFunctions->createProgram(); // Compile the fragment shader - // It uses a single, large triangle, to avoid arithmetic precision issues where fragments - // with the same Y coordinate don't get exactly the same interpolated texcoord Y. const char *vsSource = "#version 150\n" "out vec2 v_texcoord;\n" - "uniform vec2 u_scale;\n" - "uniform vec2 u_offset;\n" "\n" "void main()\n" "{\n" - " const vec2 quad_positions[3] = vec2[3]\n" + " const vec2 quad_positions[6] = vec2[6]\n" " (\n" - " vec2(-0.5f, 0.0f),\n" - " vec2( 1.5f, 0.0f),\n" - " vec2( 0.5f, 2.0f)\n" + " vec2(0.0f, 0.0f),\n" + " vec2(0.0f, 1.0f),\n" + " vec2(1.0f, 0.0f),\n" + "\n" + " vec2(0.0f, 1.0f),\n" + " vec2(1.0f, 0.0f),\n" + " vec2(1.0f, 1.0f)\n" " );\n" "\n" " gl_Position = vec4((quad_positions[gl_VertexID] * 2.0) - 1.0, 0.0, 1.0);\n" - " v_texcoord = quad_positions[gl_VertexID] * u_scale + u_offset;\n" + " v_texcoord = quad_positions[gl_VertexID];\n" "}\n"; GLuint vs = mFunctions->createShader(GL_VERTEX_SHADER); mFunctions->shaderSource(vs, 1, &vsSource, nullptr); mFunctions->compileShader(vs); - ANGLE_TRY(CheckCompileStatus(mFunctions, vs)); + gl::Error error = CheckCompileStatus(mFunctions, vs); mFunctions->attachShader(mBlitProgram, vs); mFunctions->deleteShader(vs); + if (error.isError()) + { + return error; + } + // Compile the vertex shader - // It discards if the texcoord is outside (0, 1)^2 so the blitframebuffer workaround - // doesn't write when the point sampled is outside of the source framebuffer. const char *fsSource = "#version 150\n" "uniform sampler2D u_source_texture;\n" @@ -418,28 +248,32 @@ gl::Error BlitGL::initializeResources() "\n" "void main()\n" "{\n" - " if (clamp(v_texcoord, vec2(0.0), vec2(1.0)) != v_texcoord)\n" - " {\n" - " discard;\n" - " }\n" " output_color = texture(u_source_texture, v_texcoord);\n" "}\n"; GLuint fs = mFunctions->createShader(GL_FRAGMENT_SHADER); mFunctions->shaderSource(fs, 1, &fsSource, nullptr); mFunctions->compileShader(fs); - ANGLE_TRY(CheckCompileStatus(mFunctions, fs)); + error = CheckCompileStatus(mFunctions, fs); mFunctions->attachShader(mBlitProgram, fs); mFunctions->deleteShader(fs); + if (error.isError()) + { + return error; + } + mFunctions->linkProgram(mBlitProgram); - ANGLE_TRY(CheckLinkStatus(mFunctions, mBlitProgram)); + error = CheckLinkStatus(mFunctions, mBlitProgram); + if (error.isError()) + { + return error; + } - mSourceTextureLocation = mFunctions->getUniformLocation(mBlitProgram, "u_source_texture"); - mScaleLocation = mFunctions->getUniformLocation(mBlitProgram, "u_scale"); - mOffsetLocation = mFunctions->getUniformLocation(mBlitProgram, "u_offset"); + GLuint textureUniform = mFunctions->getUniformLocation(mBlitProgram, "u_source_texture"); mStateManager->useProgram(mBlitProgram); + mFunctions->uniform1i(textureUniform, 0); } for (size_t i = 0; i < ArraySize(mScratchTextures); i++) @@ -447,6 +281,11 @@ gl::Error BlitGL::initializeResources() if (mScratchTextures[i] == 0) { mFunctions->genTextures(1, &mScratchTextures[i]); + mStateManager->bindTexture(GL_TEXTURE_2D, mScratchTextures[i]); + + // Use nearest, non-mipmapped sampling with the scratch texture + mFunctions->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + mFunctions->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } } @@ -460,27 +299,6 @@ gl::Error BlitGL::initializeResources() mFunctions->genVertexArrays(1, &mVAO); } - return gl::NoError(); + return gl::Error(GL_NO_ERROR); } - -void BlitGL::orphanScratchTextures() -{ - for (auto texture : mScratchTextures) - { - mStateManager->bindTexture(GL_TEXTURE_2D, texture); - mFunctions->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, - nullptr); - } -} - -void BlitGL::setScratchTextureParameter(GLenum param, GLenum value) -{ - for (auto texture : mScratchTextures) - { - mStateManager->bindTexture(GL_TEXTURE_2D, texture); - mFunctions->texParameteri(GL_TEXTURE_2D, param, value); - mFunctions->texParameteri(GL_TEXTURE_2D, param, value); - } } - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/gl/BlitGL.h b/gfx/angle/src/libANGLE/renderer/gl/BlitGL.h index b306ede29..3ab8319bb 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/BlitGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/BlitGL.h @@ -52,26 +52,14 @@ class BlitGL : public angle::NonCopyable const gl::Rectangle &sourceArea, const gl::Framebuffer *source); - gl::Error blitColorBufferWithShader(const gl::Framebuffer *source, - const gl::Framebuffer *dest, - const gl::Rectangle &sourceArea, - const gl::Rectangle &destArea, - GLenum filter); - gl::Error initializeResources(); private: - void orphanScratchTextures(); - void setScratchTextureParameter(GLenum param, GLenum value); - const FunctionsGL *mFunctions; const WorkaroundsGL &mWorkarounds; StateManagerGL *mStateManager; GLuint mBlitProgram; - GLint mSourceTextureLocation; - GLint mScaleLocation; - GLint mOffsetLocation; GLuint mScratchTextures[2]; GLuint mScratchFBO; diff --git a/gfx/angle/src/libANGLE/renderer/gl/BufferGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/BufferGL.cpp index a5eda6b30..cd82733d7 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/BufferGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/BufferGL.cpp @@ -29,10 +29,8 @@ static const GLenum SourceBufferOperationTarget = GL_COPY_READ_BUFFER; // supported GL versions and doesn't affect any current state when it changes. static const GLenum DestBufferOperationTarget = GL_ARRAY_BUFFER; -BufferGL::BufferGL(const gl::BufferState &state, - const FunctionsGL *functions, - StateManagerGL *stateManager) - : BufferImpl(state), +BufferGL::BufferGL(const FunctionsGL *functions, StateManagerGL *stateManager) + : BufferImpl(), mIsMapped(false), mMapOffset(0), mMapSize(0), @@ -55,7 +53,7 @@ BufferGL::~BufferGL() mBufferID = 0; } -gl::Error BufferGL::setData(GLenum /*target*/, const void *data, size_t size, GLenum usage) +gl::Error BufferGL::setData(const void* data, size_t size, GLenum usage) { mStateManager->bindBuffer(DestBufferOperationTarget, mBufferID); mFunctions->bufferData(DestBufferOperationTarget, size, data, usage); @@ -78,7 +76,7 @@ gl::Error BufferGL::setData(GLenum /*target*/, const void *data, size_t size, GL return gl::Error(GL_NO_ERROR); } -gl::Error BufferGL::setSubData(GLenum /*target*/, const void *data, size_t size, size_t offset) +gl::Error BufferGL::setSubData(const void* data, size_t size, size_t offset) { mStateManager->bindBuffer(DestBufferOperationTarget, mBufferID); mFunctions->bufferSubData(DestBufferOperationTarget, offset, size, data); diff --git a/gfx/angle/src/libANGLE/renderer/gl/BufferGL.h b/gfx/angle/src/libANGLE/renderer/gl/BufferGL.h index d886873fe..e787ec86e 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/BufferGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/BufferGL.h @@ -21,13 +21,11 @@ class StateManagerGL; class BufferGL : public BufferImpl { public: - BufferGL(const gl::BufferState &state, - const FunctionsGL *functions, - StateManagerGL *stateManager); + BufferGL(const FunctionsGL *functions, StateManagerGL *stateManager); ~BufferGL() override; - gl::Error setData(GLenum target, const void *data, size_t size, GLenum usage) override; - gl::Error setSubData(GLenum target, const void *data, size_t size, size_t offset) override; + gl::Error setData(const void* data, size_t size, GLenum usage) override; + gl::Error setSubData(const void* data, size_t size, size_t offset) override; gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) override; gl::Error map(GLenum access, GLvoid **mapPtr) override; gl::Error mapRange(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr) override; diff --git a/gfx/angle/src/libANGLE/renderer/gl/ContextGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/ContextGL.cpp index 8e378a4be..57dc222b9 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/ContextGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/ContextGL.cpp @@ -62,8 +62,7 @@ ProgramImpl *ContextGL::createProgram(const gl::ProgramState &data) FramebufferImpl *ContextGL::createFramebuffer(const gl::FramebufferState &data) { - return new FramebufferGL(data, getFunctions(), getStateManager(), getWorkaroundsGL(), - mRenderer->getBlitter(), false); + return new FramebufferGL(data, getFunctions(), getStateManager(), getWorkaroundsGL(), false); } TextureImpl *ContextGL::createTexture(const gl::TextureState &state) @@ -78,9 +77,9 @@ RenderbufferImpl *ContextGL::createRenderbuffer() getNativeTextureCaps()); } -BufferImpl *ContextGL::createBuffer(const gl::BufferState &state) +BufferImpl *ContextGL::createBuffer() { - return new BufferGL(state, getFunctions(), getStateManager()); + return new BufferGL(getFunctions(), getStateManager()); } VertexArrayImpl *ContextGL::createVertexArray(const gl::VertexArrayState &data) diff --git a/gfx/angle/src/libANGLE/renderer/gl/ContextGL.h b/gfx/angle/src/libANGLE/renderer/gl/ContextGL.h index b3d5e0ee8..798a90436 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/ContextGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/ContextGL.h @@ -47,7 +47,7 @@ class ContextGL : public ContextImpl RenderbufferImpl *createRenderbuffer() override; // Buffer creation - BufferImpl *createBuffer(const gl::BufferState &state) override; + BufferImpl *createBuffer() override; // Vertex Array creation VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override; diff --git a/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.cpp index 30c5c7b4e..e57513326 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.cpp @@ -22,7 +22,8 @@ namespace rx { -DisplayGL::DisplayGL() : mRenderer(nullptr), mCurrentDrawSurface(nullptr) +DisplayGL::DisplayGL() + : mRenderer(nullptr) { } @@ -72,13 +73,6 @@ StreamProducerImpl *DisplayGL::createStreamProducerD3DTextureNV12( egl::Error DisplayGL::makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) { - // Notify the previous surface (if it still exists) that it is no longer current - if (mCurrentDrawSurface && mSurfaceSet.find(mCurrentDrawSurface) != mSurfaceSet.end()) - { - ANGLE_TRY(GetImplAs<SurfaceGL>(mCurrentDrawSurface)->unMakeCurrent()); - } - mCurrentDrawSurface = nullptr; - if (!drawSurface) { return egl::Error(EGL_SUCCESS); @@ -89,10 +83,7 @@ egl::Error DisplayGL::makeCurrent(egl::Surface *drawSurface, egl::Surface *readS glContext->getStateManager()->pauseTransformFeedback(context->getContextState()); SurfaceGL *glDrawSurface = GetImplAs<SurfaceGL>(drawSurface); - ANGLE_TRY(glDrawSurface->makeCurrent()); - mCurrentDrawSurface = drawSurface; - - return egl::Error(EGL_SUCCESS); + return glDrawSurface->makeCurrent(); } gl::Version DisplayGL::getMaxSupportedESVersion() const diff --git a/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.h b/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.h index a63da6bbc..9f6515886 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.h @@ -12,11 +12,6 @@ #include "libANGLE/renderer/DisplayImpl.h" #include "libANGLE/renderer/gl/FunctionsGL.h" -namespace egl -{ -class Surface; -} - namespace rx { @@ -53,8 +48,6 @@ class DisplayGL : public DisplayImpl virtual const FunctionsGL *getFunctionsGL() const = 0; RendererGL *mRenderer; - - egl::Surface *mCurrentDrawSurface; }; } diff --git a/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp index 0a058f8ba..4606114ca 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp @@ -16,18 +16,14 @@ #include "libANGLE/angletypes.h" #include "libANGLE/formatutils.h" #include "libANGLE/renderer/ContextImpl.h" -#include "libANGLE/renderer/gl/BlitGL.h" #include "libANGLE/renderer/gl/FunctionsGL.h" #include "libANGLE/renderer/gl/RenderbufferGL.h" #include "libANGLE/renderer/gl/StateManagerGL.h" #include "libANGLE/renderer/gl/TextureGL.h" #include "libANGLE/renderer/gl/WorkaroundsGL.h" -#include "libANGLE/renderer/gl/formatutilsgl.h" -#include "libANGLE/renderer/gl/renderergl_utils.h" #include "platform/Platform.h" using namespace gl; -using angle::CheckedNumeric; namespace rx { @@ -36,13 +32,11 @@ FramebufferGL::FramebufferGL(const FramebufferState &state, const FunctionsGL *functions, StateManagerGL *stateManager, const WorkaroundsGL &workarounds, - BlitGL *blitter, bool isDefault) : FramebufferImpl(state), mFunctions(functions), mStateManager(stateManager), mWorkarounds(workarounds), - mBlitter(blitter), mFramebufferID(0), mIsDefault(isDefault) { @@ -56,13 +50,11 @@ FramebufferGL::FramebufferGL(GLuint id, const FramebufferState &state, const FunctionsGL *functions, const WorkaroundsGL &workarounds, - BlitGL *blitter, StateManagerGL *stateManager) : FramebufferImpl(state), mFunctions(functions), mStateManager(stateManager), mWorkarounds(workarounds), - mBlitter(blitter), mFramebufferID(id), mIsDefault(true) { @@ -220,14 +212,14 @@ GLenum FramebufferGL::getImplementationColorReadFormat() const { const auto *readAttachment = mState.getReadAttachment(); const Format &format = readAttachment->getFormat(); - return format.info->getReadPixelsFormat(); + return format.info->format; } GLenum FramebufferGL::getImplementationColorReadType() const { const auto *readAttachment = mState.getReadAttachment(); const Format &format = readAttachment->getFormat(); - return format.info->getReadPixelsType(); + return format.info->type; } Error FramebufferGL::readPixels(ContextImpl *context, @@ -241,37 +233,10 @@ Error FramebufferGL::readPixels(ContextImpl *context, const PixelPackState &packState = context->getGLState().getPackState(); mStateManager->setPixelPackState(packState); - nativegl::ReadPixelsFormat readPixelsFormat = - nativegl::GetReadPixelsFormat(mFunctions, mWorkarounds, format, type); - GLenum readFormat = readPixelsFormat.format; - GLenum readType = readPixelsFormat.type; - mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, mFramebufferID); + mFunctions->readPixels(area.x, area.y, area.width, area.height, format, type, pixels); - if (mWorkarounds.packOverlappingRowsSeparatelyPackBuffer && packState.pixelBuffer.get() && - packState.rowLength != 0 && packState.rowLength < area.width) - { - return readPixelsRowByRowWorkaround(area, readFormat, readType, packState, pixels); - } - - if (mWorkarounds.packLastRowSeparatelyForPaddingInclusion) - { - gl::Extents size(area.width, area.height, 1); - - bool apply; - ANGLE_TRY_RESULT(ShouldApplyLastRowPaddingWorkaround(size, packState, readFormat, readType, - false, pixels), - apply); - - if (apply) - { - return readPixelsPaddingWorkaround(area, readFormat, readType, packState, pixels); - } - } - - mFunctions->readPixels(area.x, area.y, area.width, area.height, readFormat, readType, pixels); - - return gl::NoError(); + return Error(GL_NO_ERROR); } Error FramebufferGL::blit(ContextImpl *context, @@ -281,80 +246,15 @@ Error FramebufferGL::blit(ContextImpl *context, GLenum filter) { const Framebuffer *sourceFramebuffer = context->getGLState().getReadFramebuffer(); - const Framebuffer *destFramebuffer = context->getGLState().getDrawFramebuffer(); - - const FramebufferAttachment *colorReadAttachment = sourceFramebuffer->getReadColorbuffer(); - GLsizei readAttachmentSamples = colorReadAttachment->getSamples(); - - bool needManualColorBlit = false; - - // TODO(cwallez) when the filter is LINEAR and both source and destination are SRGB, we - // could avoid doing a manual blit. - - // Prior to OpenGL 4.4 BlitFramebuffer (section 18.3.1 of GL 4.3 core profile) reads: - // When values are taken from the read buffer, no linearization is performed, even - // if the format of the buffer is SRGB. - // Starting from OpenGL 4.4 (section 18.3.1) it reads: - // When values are taken from the read buffer, if FRAMEBUFFER_SRGB is enabled and the - // value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer attachment - // corresponding to the read buffer is SRGB, the red, green, and blue components are - // converted from the non-linear sRGB color space according [...]. - { - bool sourceSRGB = colorReadAttachment != nullptr && - colorReadAttachment->getColorEncoding() == GL_SRGB; - needManualColorBlit = - needManualColorBlit || (sourceSRGB && mFunctions->isAtMostGL(gl::Version(4, 3))); - } - - // Prior to OpenGL 4.2 BlitFramebuffer (section 4.3.2 of GL 4.1 core profile) reads: - // Blit operations bypass the fragment pipeline. The only fragment operations which - // affect a blit are the pixel ownership test and scissor test. - // Starting from OpenGL 4.2 (section 4.3.2) it reads: - // When values are written to the draw buffers, blit operations bypass the fragment - // pipeline. The only fragment operations which affect a blit are the pixel ownership - // test, the scissor test and sRGB conversion. - if (!needManualColorBlit) - { - bool destSRGB = false; - for (size_t i = 0; i < destFramebuffer->getDrawbufferStateCount(); ++i) - { - const FramebufferAttachment *attachment = destFramebuffer->getDrawBuffer(i); - if (attachment && attachment->getColorEncoding() == GL_SRGB) - { - destSRGB = true; - break; - } - } - - needManualColorBlit = - needManualColorBlit || (destSRGB && mFunctions->isAtMostGL(gl::Version(4, 1))); - } - - // Enable FRAMEBUFFER_SRGB if needed - mStateManager->setFramebufferSRGBEnabledForFramebuffer(true, this); - - GLenum blitMask = mask; - if (needManualColorBlit && (mask & GL_COLOR_BUFFER_BIT) && readAttachmentSamples <= 1) - { - ANGLE_TRY(mBlitter->blitColorBufferWithShader(sourceFramebuffer, destFramebuffer, - sourceArea, destArea, filter)); - blitMask &= ~GL_COLOR_BUFFER_BIT; - } - - if (blitMask == 0) - { - return gl::NoError(); - } - const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(sourceFramebuffer); + mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID()); mStateManager->bindFramebuffer(GL_DRAW_FRAMEBUFFER, mFramebufferID); mFunctions->blitFramebuffer(sourceArea.x, sourceArea.y, sourceArea.x1(), sourceArea.y1(), - destArea.x, destArea.y, destArea.x1(), destArea.y1(), blitMask, - filter); + destArea.x, destArea.y, destArea.x1(), destArea.y1(), mask, filter); - return gl::NoError(); + return Error(GL_NO_ERROR); } bool FramebufferGL::checkStatus() const @@ -420,9 +320,17 @@ GLuint FramebufferGL::getFramebufferID() const return mFramebufferID; } -bool FramebufferGL::isDefault() const +void FramebufferGL::syncDrawState() const { - return mIsDefault; + if (mFunctions->standard == STANDARD_GL_DESKTOP) + { + // Enable SRGB blending for all framebuffers except the default framebuffer on Desktop + // OpenGL. + // When SRGB blending is enabled, only SRGB capable formats will use it but the default + // framebuffer will always use it if it is enabled. + // TODO(geofflang): Update this when the framebuffer binding dirty changes, when it exists. + mStateManager->setFramebufferSRGBEnabled(!mIsDefault); + } } void FramebufferGL::syncClearState(GLbitfield mask) @@ -432,17 +340,17 @@ void FramebufferGL::syncClearState(GLbitfield mask) if (mWorkarounds.doesSRGBClearsOnLinearFramebufferAttachments && (mask & GL_COLOR_BUFFER_BIT) != 0 && !mIsDefault) { - bool hasSRGBAttachment = false; + bool hasSRBAttachment = false; for (const auto &attachment : mState.getColorAttachments()) { if (attachment.isAttached() && attachment.getColorEncoding() == GL_SRGB) { - hasSRGBAttachment = true; + hasSRBAttachment = true; break; } } - mStateManager->setFramebufferSRGBEnabled(hasSRGBAttachment); + mStateManager->setFramebufferSRGBEnabled(hasSRBAttachment); } else { @@ -483,71 +391,4 @@ void FramebufferGL::syncClearBufferState(GLenum buffer, GLint drawBuffer) } } } -gl::Error FramebufferGL::readPixelsRowByRowWorkaround(const gl::Rectangle &area, - GLenum format, - GLenum type, - const gl::PixelPackState &pack, - GLvoid *pixels) const -{ - intptr_t offset = reinterpret_cast<intptr_t>(pixels); - - const gl::InternalFormat &glFormat = - gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type)); - GLuint rowBytes = 0; - ANGLE_TRY_RESULT(glFormat.computeRowPitch(area.width, pack.alignment, pack.rowLength), - rowBytes); - GLuint skipBytes = 0; - ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, 0, pack, false), skipBytes); - - gl::PixelPackState directPack; - directPack.pixelBuffer = pack.pixelBuffer; - directPack.alignment = 1; - mStateManager->setPixelPackState(directPack); - directPack.pixelBuffer.set(nullptr); - - offset += skipBytes; - for (GLint row = 0; row < area.height; ++row) - { - mFunctions->readPixels(area.x, row + area.y, area.width, 1, format, type, - reinterpret_cast<GLvoid *>(offset)); - offset += row * rowBytes; - } - - return gl::NoError(); -} - -gl::Error FramebufferGL::readPixelsPaddingWorkaround(const gl::Rectangle &area, - GLenum format, - GLenum type, - const gl::PixelPackState &pack, - GLvoid *pixels) const -{ - const gl::InternalFormat &glFormat = - gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type)); - GLuint rowBytes = 0; - ANGLE_TRY_RESULT(glFormat.computeRowPitch(area.width, pack.alignment, pack.rowLength), - rowBytes); - GLuint skipBytes = 0; - ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, 0, pack, false), skipBytes); - - // Get all by the last row - if (area.height > 1) - { - mFunctions->readPixels(area.x, area.y, area.width, area.height - 1, format, type, pixels); - } - - // Get the last row manually - gl::PixelPackState directPack; - directPack.pixelBuffer = pack.pixelBuffer; - directPack.alignment = 1; - mStateManager->setPixelPackState(directPack); - directPack.pixelBuffer.set(nullptr); - - intptr_t lastRowOffset = - reinterpret_cast<intptr_t>(pixels) + skipBytes + (area.height - 1) * rowBytes; - mFunctions->readPixels(area.x, area.y + area.height - 1, area.width, 1, format, type, - reinterpret_cast<GLvoid *>(lastRowOffset)); - - return gl::NoError(); -} } // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.h b/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.h index a8bcb894c..69d4aef35 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.h @@ -14,7 +14,6 @@ namespace rx { -class BlitGL; class FunctionsGL; class StateManagerGL; struct WorkaroundsGL; @@ -26,7 +25,6 @@ class FramebufferGL : public FramebufferImpl const FunctionsGL *functions, StateManagerGL *stateManager, const WorkaroundsGL &workarounds, - BlitGL *blitter, bool isDefault); // Constructor called when we need to create a FramebufferGL from an // existing framebuffer name, for example for the default framebuffer @@ -35,7 +33,6 @@ class FramebufferGL : public FramebufferImpl const gl::FramebufferState &data, const FunctionsGL *functions, const WorkaroundsGL &workarounds, - BlitGL *blitter, StateManagerGL *stateManager); ~FramebufferGL() override; @@ -80,29 +77,17 @@ class FramebufferGL : public FramebufferImpl void syncState(const gl::Framebuffer::DirtyBits &dirtyBits) override; + void syncDrawState() const; + GLuint getFramebufferID() const; - bool isDefault() const; private: void syncClearState(GLbitfield mask); void syncClearBufferState(GLenum buffer, GLint drawBuffer); - gl::Error readPixelsRowByRowWorkaround(const gl::Rectangle &area, - GLenum format, - GLenum type, - const gl::PixelPackState &pack, - GLvoid *pixels) const; - - gl::Error readPixelsPaddingWorkaround(const gl::Rectangle &area, - GLenum format, - GLenum type, - const gl::PixelPackState &pack, - GLvoid *pixels) const; - const FunctionsGL *mFunctions; StateManagerGL *mStateManager; const WorkaroundsGL &mWorkarounds; - BlitGL *mBlitter; GLuint mFramebufferID; bool mIsDefault; diff --git a/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp index fcbf211bc..9c3964e47 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp @@ -2283,21 +2283,11 @@ bool FunctionsGL::isAtLeastGL(const gl::Version &glVersion) const return standard == STANDARD_GL_DESKTOP && version >= glVersion; } -bool FunctionsGL::isAtMostGL(const gl::Version &glVersion) const -{ - return standard == STANDARD_GL_DESKTOP && glVersion >= version; -} - bool FunctionsGL::isAtLeastGLES(const gl::Version &glesVersion) const { return standard == STANDARD_GL_ES && version >= glesVersion; } -bool FunctionsGL::isAtMostGLES(const gl::Version &glesVersion) const -{ - return standard == STANDARD_GL_ES && glesVersion >= version; -} - bool FunctionsGL::hasExtension(const std::string &ext) const { return std::find(extensions.begin(), extensions.end(), ext) != extensions.end(); diff --git a/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.h b/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.h index fa8634e57..e790d96fe 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.h @@ -36,9 +36,7 @@ class FunctionsGL StandardGL standard; GLint profile; bool isAtLeastGL(const gl::Version &glVersion) const; - bool isAtMostGL(const gl::Version &glVersion) const; bool isAtLeastGLES(const gl::Version &glesVersion) const; - bool isAtMostGLES(const gl::Version &glesVersion) const; // Extensions std::vector<std::string> extensions; diff --git a/gfx/angle/src/libANGLE/renderer/gl/ProgramGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/ProgramGL.cpp index 88c7df720..2c2c4e7ad 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/ProgramGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/ProgramGL.cpp @@ -62,12 +62,12 @@ LinkResult ProgramGL::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) // Verify that the program linked if (!checkLinkStatus(infoLog)) { - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } postLink(); - return true; + return LinkResult(true, gl::Error(GL_NO_ERROR)); } gl::Error ProgramGL::save(gl::BinaryOutputStream *stream) @@ -167,7 +167,7 @@ LinkResult ProgramGL::link(const gl::ContextState &data, gl::InfoLog &infoLog) // Verify the link if (!checkLinkStatus(infoLog)) { - return false; + return LinkResult(false, gl::Error(GL_NO_ERROR)); } if (mWorkarounds.alwaysCallUseProgramAfterLink) @@ -177,7 +177,7 @@ LinkResult ProgramGL::link(const gl::ContextState &data, gl::InfoLog &infoLog) postLink(); - return true; + return LinkResult(true, gl::Error(GL_NO_ERROR)); } GLboolean ProgramGL::validate(const gl::Caps & /*caps*/, gl::InfoLog * /*infoLog*/) @@ -223,7 +223,7 @@ void ProgramGL::setUniform1iv(GLint location, GLsizei count, const GLint *v) std::vector<GLuint> &boundTextureUnits = mSamplerBindings[samplerIndex].boundTextureUnits; size_t copyCount = - std::min<size_t>(count, boundTextureUnits.size() - locationEntry.element); + std::max<size_t>(count, boundTextureUnits.size() - locationEntry.element); std::copy(v, v + copyCount, boundTextureUnits.begin() + locationEntry.element); } } @@ -577,7 +577,7 @@ void ProgramGL::postLink() for (GLint arrayIndex = 1; arrayIndex < arraySize; ++arrayIndex) { PathRenderingFragmentInput arrayElementInput; - arrayElementInput.name = name + "[" + ToString(arrayIndex) + "]"; + arrayElementInput.name = name + "[" + std::to_string(arrayIndex) + "]"; arrayElementInput.location = baseLocation + arrayIndex; mPathRenderingFragmentInputs.push_back(std::move(arrayElementInput)); } diff --git a/gfx/angle/src/libANGLE/renderer/gl/RenderbufferGL.h b/gfx/angle/src/libANGLE/renderer/gl/RenderbufferGL.h index 0ff0faeae..eeb164378 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/RenderbufferGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/RenderbufferGL.h @@ -38,6 +38,12 @@ class RenderbufferGL : public RenderbufferImpl GLuint getRenderbufferID() const; + gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target, + FramebufferAttachmentRenderTarget **rtOut) override + { + return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL"); + } + private: const FunctionsGL *mFunctions; const WorkaroundsGL &mWorkarounds; diff --git a/gfx/angle/src/libANGLE/renderer/gl/RendererGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/RendererGL.cpp index da1a65687..10c408d93 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/RendererGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/RendererGL.cpp @@ -122,7 +122,6 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at #ifndef NDEBUG if (mHasDebugOutput) { - mFunctions->enable(GL_DEBUG_OUTPUT); mFunctions->enable(GL_DEBUG_OUTPUT_SYNCHRONOUS); mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH, 0, nullptr, GL_TRUE); mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, nullptr, GL_TRUE); @@ -138,17 +137,6 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at { mSkipDrawCalls = true; } - - if (mWorkarounds.initializeCurrentVertexAttributes) - { - GLint maxVertexAttribs = 0; - mFunctions->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs); - - for (GLint i = 0; i < maxVertexAttribs; ++i) - { - mFunctions->vertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 1.0f); - } - } } RendererGL::~RendererGL() diff --git a/gfx/angle/src/libANGLE/renderer/gl/SamplerGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/SamplerGL.cpp index 2a6d81583..bffc89ec9 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/SamplerGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/SamplerGL.cpp @@ -62,7 +62,6 @@ void SamplerGL::syncState(const gl::SamplerState &samplerState) const SyncSamplerStateMember(mFunctions, mSamplerID, samplerState, mAppliedSamplerState, GL_TEXTURE_MAX_LOD, &gl::SamplerState::maxLod); SyncSamplerStateMember(mFunctions, mSamplerID, samplerState, mAppliedSamplerState, GL_TEXTURE_COMPARE_MODE, &gl::SamplerState::compareMode); SyncSamplerStateMember(mFunctions, mSamplerID, samplerState, mAppliedSamplerState, GL_TEXTURE_COMPARE_FUNC, &gl::SamplerState::compareFunc); - SyncSamplerStateMember(mFunctions, mSamplerID, samplerState, mAppliedSamplerState, GL_TEXTURE_SRGB_DECODE_EXT, &gl::SamplerState::sRGBDecode); // clang-format on } diff --git a/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.cpp index c9145b00a..400917b35 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.cpp @@ -36,8 +36,8 @@ ShaderGL::~ShaderGL() } } -ShCompileOptions ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sourceStream, - std::string * /*sourcePath*/) +int ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sourceStream, + std::string * /*sourcePath*/) { // Reset the previous state if (mShaderID != 0) @@ -48,43 +48,13 @@ ShCompileOptions ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sour *sourceStream << mData.getSource(); - ShCompileOptions options = SH_INIT_GL_POSITION; + int options = SH_INIT_GL_POSITION; if (mWorkarounds.doWhileGLSLCausesGPUHang) { options |= SH_REWRITE_DO_WHILE_LOOPS; } - if (mWorkarounds.emulateAbsIntFunction) - { - options |= SH_EMULATE_ABS_INT_FUNCTION; - } - - if (mWorkarounds.addAndTrueToLoopCondition) - { - options |= SH_ADD_AND_TRUE_TO_LOOP_CONDITION; - } - - if (mWorkarounds.emulateIsnanFloat) - { - options |= SH_EMULATE_ISNAN_FLOAT_FUNCTION; - } - - if (mWorkarounds.useUnusedBlocksWithStandardOrSharedLayout) - { - options |= SH_USE_UNUSED_STANDARD_SHARED_BLOCKS; - } - - if (mWorkarounds.dontRemoveInvariantForFragmentInput) - { - options |= SH_DONT_REMOVE_INVARIANT_FOR_FRAGMENT_INPUT; - } - - if (mWorkarounds.removeInvariantAndCentroidForESSL3) - { - options |= SH_REMOVE_INVARIANT_AND_CENTROID_FOR_ESSL3; - } - return options; } diff --git a/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.h b/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.h index 0ecd89ce6..f35d2f711 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.h @@ -25,8 +25,8 @@ class ShaderGL : public ShaderImpl ~ShaderGL() override; // ShaderImpl implementation - ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream, - std::string *sourcePath) override; + int prepareSourceAndReturnOptions(std::stringstream *sourceStream, + std::string *sourcePath) override; bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override; std::string getDebugInfo() const override; diff --git a/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp index 3a227906f..1cf08b242 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp @@ -119,7 +119,6 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions, const gl::Caps &ren mClearDepth(1.0f), mClearStencil(0), mFramebufferSRGBEnabled(false), - mDitherEnabled(true), mTextureCubemapSeamlessEnabled(false), mMultisamplingEnabled(true), mSampleAlphaToOneEnabled(false), @@ -743,21 +742,18 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::ContextState &data) GLenum textureType = samplerUniform.textureType; for (GLuint textureUnitIndex : samplerUniform.boundTextureUnits) { - gl::Texture *texture = state.getSamplerTexture(textureUnitIndex, textureType); + const gl::Texture *texture = state.getSamplerTexture(textureUnitIndex, textureType); if (texture != nullptr) { const TextureGL *textureGL = GetImplAs<TextureGL>(texture); - if (mTextures[textureType][textureUnitIndex] != textureGL->getTextureID() || - texture->hasAnyDirtyBit() || textureGL->hasAnyDirtyBit()) + if (mTextures[textureType][textureUnitIndex] != textureGL->getTextureID()) { activeTexture(textureUnitIndex); bindTexture(textureType, textureGL->getTextureID()); - - // TODO: Call this from the gl:: layer once other backends use dirty bits for - // texture state. - texture->syncImplState(); } + + textureGL->syncState(textureUnitIndex); } else { @@ -785,6 +781,7 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::ContextState &data) const gl::Framebuffer *framebuffer = state.getDrawFramebuffer(); const FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(framebuffer); bindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferGL->getFramebufferID()); + framebufferGL->syncDrawState(); // Seamless cubemaps are required for ES3 and higher contexts. setTextureCubemapSeamlessEnabled(data.getClientMajorVersion() >= 3); @@ -1319,13 +1316,6 @@ void StateManagerGL::setClearStencil(GLint clearStencil) void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBits &glDirtyBits) { - // The the current framebuffer binding sometimes requires resetting the srgb blending - if (glDirtyBits[gl::State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING] && - mFunctions->standard == STANDARD_GL_DESKTOP) - { - mLocalDirtyBits.set(gl::State::DIRTY_BIT_FRAMEBUFFER_SRGB); - } - const auto &glAndLocalDirtyBits = (glDirtyBits | mLocalDirtyBits); if (!glAndLocalDirtyBits.any()) @@ -1523,7 +1513,7 @@ void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBit setPixelPackState(state.getPackState()); break; case gl::State::DIRTY_BIT_DITHER_ENABLED: - setDitherEnabled(state.isDitherEnabled()); + // TODO(jmadill): implement this break; case gl::State::DIRTY_BIT_GENERATE_MIPMAP_HINT: // TODO(jmadill): implement this @@ -1566,11 +1556,6 @@ void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBit setPathRenderingStencilState(state.getPathStencilFunc(), state.getPathStencilRef(), state.getPathStencilMask()); break; - case gl::State::DIRTY_BIT_FRAMEBUFFER_SRGB: - setFramebufferSRGBEnabledForFramebuffer( - state.getFramebufferSRGB(), - GetImplAs<FramebufferGL>(state.getDrawFramebuffer())); - break; default: { ASSERT(dirtyBit >= gl::State::DIRTY_BIT_CURRENT_VALUE_0 && @@ -1600,41 +1585,6 @@ void StateManagerGL::setFramebufferSRGBEnabled(bool enabled) { mFunctions->disable(GL_FRAMEBUFFER_SRGB); } - mLocalDirtyBits.set(gl::State::DIRTY_BIT_FRAMEBUFFER_SRGB); - } -} - -void StateManagerGL::setFramebufferSRGBEnabledForFramebuffer(bool enabled, - const FramebufferGL *framebuffer) -{ - if (mFunctions->standard == STANDARD_GL_DESKTOP && framebuffer->isDefault()) - { - // Obey the framebuffer sRGB state for blending on all framebuffers except the default - // framebuffer on Desktop OpenGL. - // When SRGB blending is enabled, only SRGB capable formats will use it but the default - // framebuffer will always use it if it is enabled. - // TODO(geofflang): Update this when the framebuffer binding dirty changes, when it exists. - setFramebufferSRGBEnabled(false); - } - else - { - setFramebufferSRGBEnabled(enabled); - } -} - -void StateManagerGL::setDitherEnabled(bool enabled) -{ - if (mDitherEnabled != enabled) - { - mDitherEnabled = enabled; - if (mDitherEnabled) - { - mFunctions->enable(GL_DITHER); - } - else - { - mFunctions->disable(GL_DITHER); - } } } diff --git a/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.h b/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.h index 3c8c5389f..f7ec64772 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.h @@ -27,7 +27,6 @@ class State; namespace rx { -class FramebufferGL; class FunctionsGL; class TransformFeedbackGL; class QueryGL; @@ -124,9 +123,6 @@ class StateManagerGL final : angle::NonCopyable GLuint packBuffer); void setFramebufferSRGBEnabled(bool enabled); - void setFramebufferSRGBEnabledForFramebuffer(bool enabled, const FramebufferGL *framebuffer); - - void setDitherEnabled(bool enabled); void setMultisamplingStateEnabled(bool enabled); void setSampleAlphaToOneStateEnabled(bool enabled); @@ -268,7 +264,6 @@ class StateManagerGL final : angle::NonCopyable GLint mClearStencil; bool mFramebufferSRGBEnabled; - bool mDitherEnabled; bool mTextureCubemapSeamlessEnabled; bool mMultisamplingEnabled; diff --git a/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp index a1f0abba7..fcdddebe0 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp @@ -26,11 +26,6 @@ SurfaceGL::~SurfaceGL() FramebufferImpl *SurfaceGL::createDefaultFramebuffer(const gl::FramebufferState &data) { return new FramebufferGL(data, mRenderer->getFunctions(), mRenderer->getStateManager(), - mRenderer->getWorkarounds(), mRenderer->getBlitter(), true); -} - -egl::Error SurfaceGL::unMakeCurrent() -{ - return egl::Error(EGL_SUCCESS); + mRenderer->getWorkarounds(), true); } } diff --git a/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.h b/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.h index 681c365d2..329b562b9 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.h @@ -22,10 +22,15 @@ class SurfaceGL : public SurfaceImpl SurfaceGL(const egl::SurfaceState &state, RendererGL *renderer); ~SurfaceGL() override; + gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target, + FramebufferAttachmentRenderTarget **rtOut) override + { + return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL"); + } + FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override; virtual egl::Error makeCurrent() = 0; - virtual egl::Error unMakeCurrent(); private: RendererGL *mRenderer; diff --git a/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp index 589580505..8b78bdc01 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp @@ -8,7 +8,6 @@ #include "libANGLE/renderer/gl/TextureGL.h" -#include "common/BitSetIterator.h" #include "common/debug.h" #include "common/utilities.h" #include "libANGLE/State.h" @@ -21,27 +20,21 @@ #include "libANGLE/renderer/gl/StateManagerGL.h" #include "libANGLE/renderer/gl/WorkaroundsGL.h" #include "libANGLE/renderer/gl/formatutilsgl.h" -#include "libANGLE/renderer/gl/renderergl_utils.h" - -using angle::CheckedNumeric; namespace rx { -namespace -{ - -bool UseTexImage2D(GLenum textureType) +static bool UseTexImage2D(GLenum textureType) { return textureType == GL_TEXTURE_2D || textureType == GL_TEXTURE_CUBE_MAP; } -bool UseTexImage3D(GLenum textureType) +static bool UseTexImage3D(GLenum textureType) { return textureType == GL_TEXTURE_2D_ARRAY || textureType == GL_TEXTURE_3D; } -bool CompatibleTextureTarget(GLenum textureType, GLenum textureTarget) +static bool CompatibleTextureTarget(GLenum textureType, GLenum textureTarget) { if (textureType != GL_TEXTURE_CUBE_MAP) { @@ -53,13 +46,13 @@ bool CompatibleTextureTarget(GLenum textureType, GLenum textureTarget) } } -bool IsLUMAFormat(GLenum format) +static bool IsLUMAFormat(GLenum format) { return format == GL_LUMINANCE || format == GL_ALPHA || format == GL_LUMINANCE_ALPHA; } -LUMAWorkaroundGL GetLUMAWorkaroundInfo(const gl::InternalFormat &originalFormatInfo, - GLenum destinationFormat) +static LUMAWorkaroundGL GetLUMAWorkaroundInfo(const gl::InternalFormat &originalFormatInfo, + GLenum destinationFormat) { if (IsLUMAFormat(originalFormatInfo.format)) { @@ -74,35 +67,23 @@ LUMAWorkaroundGL GetLUMAWorkaroundInfo(const gl::InternalFormat &originalFormatI } } -bool IsDepthStencilFormat(GLenum format) +static bool IsDepthStencilFormat(GLenum format) { return format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL; } -bool GetDepthStencilWorkaround(const gl::InternalFormat &originalFormatInfo) +static bool GetDepthStencilWorkaround(const gl::InternalFormat &originalFormatInfo) { return IsDepthStencilFormat(originalFormatInfo.format); } -LevelInfoGL GetLevelInfo(GLenum originalFormat, GLenum destinationFormat) +static LevelInfoGL GetLevelInfo(GLenum originalFormat, GLenum destinationFormat) { const gl::InternalFormat &originalFormatInfo = gl::GetInternalFormatInfo(originalFormat); return LevelInfoGL(originalFormat, GetDepthStencilWorkaround(originalFormatInfo), GetLUMAWorkaroundInfo(originalFormatInfo, destinationFormat)); } -gl::Texture::DirtyBits GetLevelWorkaroundDirtyBits() -{ - gl::Texture::DirtyBits bits; - bits.set(gl::Texture::DIRTY_BIT_SWIZZLE_RED); - bits.set(gl::Texture::DIRTY_BIT_SWIZZLE_GREEN); - bits.set(gl::Texture::DIRTY_BIT_SWIZZLE_BLUE); - bits.set(gl::Texture::DIRTY_BIT_SWIZZLE_ALPHA); - return bits; -} - -} // anonymous namespace - LUMAWorkaroundGL::LUMAWorkaroundGL() : LUMAWorkaroundGL(false, GL_NONE) { } @@ -153,14 +134,8 @@ TextureGL::~TextureGL() mTextureID = 0; } -gl::Error TextureGL::setImage(GLenum target, - size_t level, - GLenum internalFormat, - const gl::Extents &size, - GLenum format, - GLenum type, - const gl::PixelUnpackState &unpack, - const uint8_t *pixels) +gl::Error TextureGL::setImage(GLenum target, size_t level, GLenum internalFormat, const gl::Extents &size, GLenum format, GLenum type, + const gl::PixelUnpackState &unpack, const uint8_t *pixels) { if (mWorkarounds.unpackOverlappingRowsSeparatelyUnpackBuffer && unpack.pixelBuffer.get() && unpack.rowLength != 0 && unpack.rowLength < size.width) @@ -168,41 +143,13 @@ gl::Error TextureGL::setImage(GLenum target, // The rows overlap in unpack memory. Upload the texture row by row to work around // driver bug. reserveTexImageToBeFilled(target, level, internalFormat, size, format, type); - - if (size.width == 0 || size.height == 0 || size.depth == 0) - { - return gl::NoError(); - } - gl::Box area(0, 0, 0, size.width, size.height, size.depth); - return setSubImageRowByRowWorkaround(target, level, area, format, type, unpack, pixels); + ANGLE_TRY(setSubImageRowByRowWorkaround(target, level, area, format, type, unpack, pixels)); } - - if (mWorkarounds.unpackLastRowSeparatelyForPaddingInclusion) + else { - bool apply; - ANGLE_TRY_RESULT(ShouldApplyLastRowPaddingWorkaround(size, unpack, format, type, - UseTexImage3D(mState.mTarget), pixels), - apply); - - // The driver will think the pixel buffer doesn't have enough data, work around this bug - // by uploading the last row (and last level if 3D) separately. - if (apply) - { - reserveTexImageToBeFilled(target, level, internalFormat, size, format, type); - - if (size.width == 0 || size.height == 0 || size.depth == 0) - { - return gl::NoError(); - } - - gl::Box area(0, 0, 0, size.width, size.height, size.depth); - return setSubImagePaddingWorkaround(target, level, area, format, type, unpack, pixels); - } + setImageHelper(target, level, internalFormat, size, format, type, pixels); } - - setImageHelper(target, level, internalFormat, size, format, type, pixels); - return gl::NoError(); } @@ -214,6 +161,7 @@ void TextureGL::setImageHelper(GLenum target, GLenum type, const uint8_t *pixels) { + UNUSED_ASSERTION_VARIABLE(&CompatibleTextureTarget); // Reference this function to avoid warnings. ASSERT(CompatibleTextureTarget(mState.mTarget, target)); nativegl::TexImageFormat texImageFormat = @@ -239,7 +187,7 @@ void TextureGL::setImageHelper(GLenum target, UNREACHABLE(); } - setLevelInfo(level, 1, GetLevelInfo(internalFormat, texImageFormat.internalFormat)); + mLevelInfo[level] = GetLevelInfo(internalFormat, texImageFormat.internalFormat); } void TextureGL::reserveTexImageToBeFilled(GLenum target, @@ -264,47 +212,32 @@ gl::Error TextureGL::setSubImage(GLenum target, size_t level, const gl::Box &are nativegl::TexSubImageFormat texSubImageFormat = nativegl::GetTexSubImageFormat(mFunctions, mWorkarounds, format, type); - ASSERT(mLevelInfo[level].lumaWorkaround.enabled == - GetLevelInfo(format, texSubImageFormat.format).lumaWorkaround.enabled); - mStateManager->bindTexture(mState.mTarget, mTextureID); if (mWorkarounds.unpackOverlappingRowsSeparatelyUnpackBuffer && unpack.pixelBuffer.get() && unpack.rowLength != 0 && unpack.rowLength < area.width) { - return setSubImageRowByRowWorkaround(target, level, area, format, type, unpack, pixels); - } - - if (mWorkarounds.unpackLastRowSeparatelyForPaddingInclusion) - { - gl::Extents size(area.width, area.height, area.depth); - - bool apply; - ANGLE_TRY_RESULT(ShouldApplyLastRowPaddingWorkaround(size, unpack, format, type, - UseTexImage3D(mState.mTarget), pixels), - apply); - - // The driver will think the pixel buffer doesn't have enough data, work around this bug - // by uploading the last row (and last level if 3D) separately. - if (apply) - { - return setSubImagePaddingWorkaround(target, level, area, format, type, unpack, pixels); - } + ANGLE_TRY(setSubImageRowByRowWorkaround(target, level, area, format, type, unpack, pixels)); } - - if (UseTexImage2D(mState.mTarget)) + else if (UseTexImage2D(mState.mTarget)) { ASSERT(area.z == 0 && area.depth == 1); mFunctions->texSubImage2D(target, static_cast<GLint>(level), area.x, area.y, area.width, area.height, texSubImageFormat.format, texSubImageFormat.type, pixels); } - else + else if (UseTexImage3D(mState.mTarget)) { - ASSERT(UseTexImage3D(mState.mTarget)); mFunctions->texSubImage3D(target, static_cast<GLint>(level), area.x, area.y, area.z, area.width, area.height, area.depth, texSubImageFormat.format, texSubImageFormat.type, pixels); } + else + { + UNREACHABLE(); + } + + ASSERT(mLevelInfo[level].lumaWorkaround.enabled == + GetLevelInfo(format, texSubImageFormat.format).lumaWorkaround.enabled); return gl::Error(GL_NO_ERROR); } @@ -317,24 +250,26 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(GLenum target, const gl::PixelUnpackState &unpack, const uint8_t *pixels) { - gl::PixelUnpackState directUnpack; - directUnpack.pixelBuffer = unpack.pixelBuffer; - directUnpack.alignment = 1; - mStateManager->setPixelUnpackState(directUnpack); - directUnpack.pixelBuffer.set(nullptr); - - const gl::InternalFormat &glFormat = - gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type)); - GLuint rowBytes = 0; - ANGLE_TRY_RESULT(glFormat.computeRowPitch(area.width, unpack.alignment, unpack.rowLength), - rowBytes); + gl::PixelUnpackState unpackToUse; + unpackToUse.pixelBuffer = unpack.pixelBuffer; + mStateManager->setPixelUnpackState(unpackToUse); + unpackToUse.pixelBuffer.set(nullptr); + const gl::Format &glFormat = mState.getImageDesc(mState.mTarget, level).format; + GLuint rowBytes = 0; + ANGLE_TRY_RESULT( + glFormat.info->computeRowPitch(GL_NONE, area.width, unpack.alignment, unpack.rowLength), + rowBytes); GLuint imageBytes = 0; - ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(area.height, unpack.imageHeight, rowBytes), - imageBytes); + ANGLE_TRY_RESULT( + glFormat.info->computeDepthPitch(GL_NONE, area.width, area.height, unpack.alignment, + unpack.rowLength, unpack.imageHeight), + imageBytes); bool useTexImage3D = UseTexImage3D(mState.mTarget); GLuint skipBytes = 0; - ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, imageBytes, unpack, useTexImage3D), - skipBytes); + ANGLE_TRY_RESULT( + glFormat.info->computeSkipBytes(rowBytes, imageBytes, unpack.skipImages, unpack.skipRows, + unpack.skipPixels, useTexImage3D), + skipBytes); const uint8_t *pixelsWithSkip = pixels + skipBytes; if (useTexImage3D) @@ -352,9 +287,8 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(GLenum target, } } } - else + else if (UseTexImage2D(mState.mTarget)) { - ASSERT(UseTexImage2D(mState.mTarget)); for (GLint row = 0; row < area.height; ++row) { GLint byteOffset = row * rowBytes; @@ -363,89 +297,10 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(GLenum target, area.width, 1, format, type, rowPixels); } } - return gl::NoError(); -} - -gl::Error TextureGL::setSubImagePaddingWorkaround(GLenum target, - size_t level, - const gl::Box &area, - GLenum format, - GLenum type, - const gl::PixelUnpackState &unpack, - const uint8_t *pixels) -{ - const gl::InternalFormat &glFormat = - gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type)); - GLuint rowBytes = 0; - ANGLE_TRY_RESULT(glFormat.computeRowPitch(area.width, unpack.alignment, unpack.rowLength), - rowBytes); - GLuint imageBytes = 0; - ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(area.height, unpack.imageHeight, rowBytes), - imageBytes); - bool useTexImage3D = UseTexImage3D(mState.mTarget); - GLuint skipBytes = 0; - ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, imageBytes, unpack, useTexImage3D), - skipBytes); - - gl::PixelUnpackState directUnpack; - directUnpack.pixelBuffer = unpack.pixelBuffer; - directUnpack.alignment = 1; - - if (useTexImage3D) - { - // Upload all but the last slice - if (area.depth > 1) - { - mFunctions->texSubImage3D(target, static_cast<GLint>(level), area.x, area.y, area.z, - area.width, area.height, area.depth - 1, format, type, - pixels); - } - - // Upload the last slice but its last row - if (area.height > 1) - { - // Do not include skipBytes in the last image pixel start offset as it will be done by - // the driver - GLint lastImageOffset = (area.depth - 1) * imageBytes; - const GLubyte *lastImagePixels = pixels + lastImageOffset; - mFunctions->texSubImage3D(target, static_cast<GLint>(level), area.x, area.y, - area.z + area.depth - 1, area.width, area.height - 1, 1, - format, type, lastImagePixels); - } - - // Upload the last row of the last slice "manually" - mStateManager->setPixelUnpackState(directUnpack); - - GLint lastRowOffset = - skipBytes + (area.depth - 1) * imageBytes + (area.height - 1) * rowBytes; - const GLubyte *lastRowPixels = pixels + lastRowOffset; - mFunctions->texSubImage3D(target, static_cast<GLint>(level), area.x, - area.y + area.height - 1, area.z + area.depth - 1, area.width, 1, - 1, format, type, lastRowPixels); - } else { - ASSERT(UseTexImage2D(mState.mTarget)); - - // Upload all but the last row - if (area.height > 1) - { - mFunctions->texSubImage2D(target, static_cast<GLint>(level), area.x, area.y, area.width, - area.height - 1, format, type, pixels); - } - - // Upload the last row "manually" - mStateManager->setPixelUnpackState(directUnpack); - - GLint lastRowOffset = skipBytes + (area.height - 1) * rowBytes; - const GLubyte *lastRowPixels = pixels + lastRowOffset; - mFunctions->texSubImage2D(target, static_cast<GLint>(level), area.x, - area.y + area.height - 1, area.width, 1, format, type, - lastRowPixels); + UNREACHABLE(); } - - directUnpack.pixelBuffer.set(nullptr); - return gl::NoError(); } @@ -476,7 +331,7 @@ gl::Error TextureGL::setCompressedImage(GLenum target, size_t level, GLenum inte UNREACHABLE(); } - setLevelInfo(level, 1, GetLevelInfo(internalFormat, compressedTexImageFormat.internalFormat)); + mLevelInfo[level] = GetLevelInfo(internalFormat, compressedTexImageFormat.internalFormat); ASSERT(!mLevelInfo[level].lumaWorkaround.enabled); return gl::Error(GL_NO_ERROR); @@ -553,7 +408,7 @@ gl::Error TextureGL::copyImage(GLenum target, size_t level, const gl::Rectangle } } - setLevelInfo(level, 1, levelInfo); + mLevelInfo[level] = levelInfo; return gl::Error(GL_NO_ERROR); } @@ -639,7 +494,8 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor if (internalFormatInfo.compressed) { GLuint dataSize = 0; - ANGLE_TRY_RESULT(internalFormatInfo.computeCompressedImageSize(levelSize), + ANGLE_TRY_RESULT(internalFormatInfo.computeCompressedImageSize( + GL_UNSIGNED_BYTE, levelSize), dataSize); mFunctions->compressedTexImage2D(target, static_cast<GLint>(level), texStorageFormat.internalFormat, @@ -662,7 +518,7 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor { GLuint dataSize = 0; ANGLE_TRY_RESULT(internalFormatInfo.computeCompressedImageSize( - levelSize), + GL_UNSIGNED_BYTE, levelSize), dataSize); mFunctions->compressedTexImage2D( face, static_cast<GLint>(level), texStorageFormat.internalFormat, @@ -713,7 +569,7 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor { GLuint dataSize = 0; ANGLE_TRY_RESULT( - internalFormatInfo.computeCompressedImageSize(levelSize), + internalFormatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, levelSize), dataSize); mFunctions->compressedTexImage3D(target, i, texStorageFormat.internalFormat, levelSize.width, levelSize.height, @@ -735,7 +591,11 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor UNREACHABLE(); } - setLevelInfo(0, levels, GetLevelInfo(internalFormat, texStorageFormat.internalFormat)); + LevelInfoGL levelInfo = GetLevelInfo(internalFormat, texStorageFormat.internalFormat); + for (size_t level = 0; level < mLevelInfo.size(); level++) + { + mLevelInfo[level] = levelInfo; + } return gl::Error(GL_NO_ERROR); } @@ -750,6 +610,8 @@ gl::Error TextureGL::setImageExternal(GLenum target, gl::Error TextureGL::generateMipmap() { + // Need to sync base level and max level to driver before calling GenerateMipmap. + syncState(0); mStateManager->bindTexture(mState.mTarget, mTextureID); mFunctions->generateMipmap(mState.mTarget); @@ -758,7 +620,10 @@ gl::Error TextureGL::generateMipmap() ASSERT(maxLevel < mLevelInfo.size()); - setLevelInfo(effectiveBaseLevel, maxLevel - effectiveBaseLevel, mLevelInfo[effectiveBaseLevel]); + for (GLuint level = effectiveBaseLevel; level <= maxLevel; level++) + { + mLevelInfo[level] = mLevelInfo[effectiveBaseLevel]; + } return gl::Error(GL_NO_ERROR); } @@ -770,7 +635,7 @@ void TextureGL::bindTexImage(egl::Surface *surface) // Make sure this texture is bound mStateManager->bindTexture(mState.mTarget, mTextureID); - setLevelInfo(0, 1, LevelInfoGL()); + mLevelInfo[0] = LevelInfoGL(); } void TextureGL::releaseTexImage() @@ -796,121 +661,58 @@ gl::Error TextureGL::setEGLImageTarget(GLenum target, egl::Image *image) return gl::Error(GL_INVALID_OPERATION); } -void TextureGL::syncState(const gl::Texture::DirtyBits &dirtyBits) +template <typename T, typename ApplyTextureFuncType> +static inline void SyncSamplerStateMember(const FunctionsGL *functions, + ApplyTextureFuncType applyTextureFunc, + const gl::SamplerState &newState, + gl::SamplerState &curState, + GLenum textureType, + GLenum name, + T(gl::SamplerState::*samplerMember)) { - if (dirtyBits.none() && mLocalDirtyBits.none()) - { - return; - } - - mStateManager->bindTexture(mState.mTarget, mTextureID); - - if (dirtyBits[gl::Texture::DIRTY_BIT_BASE_LEVEL] || dirtyBits[gl::Texture::DIRTY_BIT_MAX_LEVEL]) + if (curState.*samplerMember != newState.*samplerMember) { - // Don't know if the previous base level was using any workarounds, always re-sync the - // workaround dirty bits - mLocalDirtyBits |= GetLevelWorkaroundDirtyBits(); + applyTextureFunc(); + curState.*samplerMember = newState.*samplerMember; + functions->texParameterf(textureType, name, static_cast<GLfloat>(curState.*samplerMember)); } - - for (auto dirtyBit : angle::IterateBitSet(dirtyBits | mLocalDirtyBits)) - { - switch (dirtyBit) - { - case gl::Texture::DIRTY_BIT_MIN_FILTER: - mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_MIN_FILTER, - mState.getSamplerState().minFilter); - break; - case gl::Texture::DIRTY_BIT_MAG_FILTER: - mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_MAG_FILTER, - mState.getSamplerState().magFilter); - break; - case gl::Texture::DIRTY_BIT_WRAP_S: - mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_WRAP_S, - mState.getSamplerState().wrapS); - break; - case gl::Texture::DIRTY_BIT_WRAP_T: - mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_WRAP_T, - mState.getSamplerState().wrapT); - break; - case gl::Texture::DIRTY_BIT_WRAP_R: - mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_WRAP_R, - mState.getSamplerState().wrapR); - break; - case gl::Texture::DIRTY_BIT_MAX_ANISOTROPY: - mFunctions->texParameterf(mState.mTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, - mState.getSamplerState().maxAnisotropy); - break; - case gl::Texture::DIRTY_BIT_MIN_LOD: - mFunctions->texParameterf(mState.mTarget, GL_TEXTURE_MIN_LOD, - mState.getSamplerState().minLod); - break; - case gl::Texture::DIRTY_BIT_MAX_LOD: - mFunctions->texParameterf(mState.mTarget, GL_TEXTURE_MAX_LOD, - mState.getSamplerState().maxLod); - break; - case gl::Texture::DIRTY_BIT_COMPARE_MODE: - mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_COMPARE_MODE, - mState.getSamplerState().compareMode); - break; - case gl::Texture::DIRTY_BIT_COMPARE_FUNC: - mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_COMPARE_FUNC, - mState.getSamplerState().compareFunc); - break; - case gl::Texture::DIRTY_BIT_SRGB_DECODE: - mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_SRGB_DECODE_EXT, - mState.getSamplerState().sRGBDecode); - break; - - // Texture state - case gl::Texture::DIRTY_BIT_SWIZZLE_RED: - syncTextureStateSwizzle(mFunctions, GL_TEXTURE_SWIZZLE_R, - mState.getSwizzleState().swizzleRed); - break; - case gl::Texture::DIRTY_BIT_SWIZZLE_GREEN: - syncTextureStateSwizzle(mFunctions, GL_TEXTURE_SWIZZLE_G, - mState.getSwizzleState().swizzleGreen); - break; - case gl::Texture::DIRTY_BIT_SWIZZLE_BLUE: - syncTextureStateSwizzle(mFunctions, GL_TEXTURE_SWIZZLE_B, - mState.getSwizzleState().swizzleBlue); - break; - case gl::Texture::DIRTY_BIT_SWIZZLE_ALPHA: - syncTextureStateSwizzle(mFunctions, GL_TEXTURE_SWIZZLE_A, - mState.getSwizzleState().swizzleAlpha); - break; - case gl::Texture::DIRTY_BIT_BASE_LEVEL: - mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_BASE_LEVEL, - mState.getEffectiveBaseLevel()); - break; - case gl::Texture::DIRTY_BIT_MAX_LEVEL: - mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_MAX_LEVEL, - mState.getEffectiveMaxLevel()); - break; - case gl::Texture::DIRTY_BIT_USAGE: - break; - - default: - UNREACHABLE(); - } - } - - mLocalDirtyBits.reset(); } -bool TextureGL::hasAnyDirtyBit() const +template <typename T, typename ApplyTextureFuncType> +static inline void SyncTextureStateMember(const FunctionsGL *functions, + ApplyTextureFuncType applyTextureFunc, + const gl::TextureState &newState, + gl::TextureState &curState, + GLenum textureType, + GLenum name, + T(gl::TextureState::*stateMember)) { - return mLocalDirtyBits.any(); + if (curState.*stateMember != newState.*stateMember) + { + applyTextureFunc(); + curState.*stateMember = newState.*stateMember; + functions->texParameterf(textureType, name, static_cast<GLfloat>(curState.*stateMember)); + } } -void TextureGL::syncTextureStateSwizzle(const FunctionsGL *functions, GLenum name, GLenum value) +template <typename T, typename ApplyTextureFuncType> +static inline void SyncTextureStateSwizzle(const FunctionsGL *functions, + ApplyTextureFuncType applyTextureFunc, + const LevelInfoGL &levelInfo, + const gl::SwizzleState &newState, + gl::SwizzleState &curState, + GLenum textureType, + GLenum name, + T(gl::SwizzleState::*stateMember)) { - const LevelInfoGL &levelInfo = mLevelInfo[mState.getEffectiveBaseLevel()]; - GLenum resultSwizzle = value; + GLenum resultSwizzle = newState.*stateMember; if (levelInfo.lumaWorkaround.enabled || levelInfo.depthStencilWorkaround) { if (levelInfo.lumaWorkaround.enabled) { - switch (value) + UNUSED_ASSERTION_VARIABLE(levelInfo.lumaWorkaround.workaroundFormat); + + switch (newState.*stateMember) { case GL_RED: case GL_GREEN: @@ -964,7 +766,7 @@ void TextureGL::syncTextureStateSwizzle(const FunctionsGL *functions, GLenum nam case GL_ZERO: case GL_ONE: // Don't modify the swizzle state when requesting ZERO or ONE. - resultSwizzle = value; + resultSwizzle = newState.*stateMember; break; default: @@ -974,11 +776,11 @@ void TextureGL::syncTextureStateSwizzle(const FunctionsGL *functions, GLenum nam } else if (levelInfo.depthStencilWorkaround) { - switch (value) + switch (newState.*stateMember) { case GL_RED: // Don't modify the swizzle state when requesting the red channel. - resultSwizzle = value; + resultSwizzle = newState.*stateMember; break; case GL_GREEN: @@ -995,7 +797,7 @@ void TextureGL::syncTextureStateSwizzle(const FunctionsGL *functions, GLenum nam case GL_ZERO: case GL_ONE: // Don't modify the swizzle state when requesting ZERO or ONE. - resultSwizzle = value; + resultSwizzle = newState.*stateMember; break; default: @@ -1010,25 +812,65 @@ void TextureGL::syncTextureStateSwizzle(const FunctionsGL *functions, GLenum nam } - functions->texParameteri(mState.mTarget, name, resultSwizzle); + if (curState.*stateMember != resultSwizzle) + { + applyTextureFunc(); + curState.*stateMember = resultSwizzle; + functions->texParameterf(textureType, name, static_cast<GLfloat>(resultSwizzle)); + } } -void TextureGL::setLevelInfo(size_t level, size_t levelCount, const LevelInfoGL &levelInfo) +void TextureGL::syncState(size_t textureUnit) const { - ASSERT(levelCount > 0 && level + levelCount < mLevelInfo.size()); + // Callback lamdba to bind this texture only if needed. + bool textureApplied = false; + auto applyTextureFunc = [&]() + { + if (!textureApplied) + { + mStateManager->activeTexture(textureUnit); + mStateManager->bindTexture(mState.mTarget, mTextureID); + textureApplied = true; + } + }; - GLuint baseLevel = mState.getEffectiveBaseLevel(); - bool needsResync = level <= baseLevel && level + levelCount >= baseLevel && - (levelInfo.depthStencilWorkaround || levelInfo.lumaWorkaround.enabled); - if (needsResync) + // Sync texture state + // Apply the effective base level and max level instead of the base level and max level set from + // the API. This can help with buggy drivers. + if (mAppliedTextureState.getEffectiveBaseLevel() != mState.getEffectiveBaseLevel()) { - mLocalDirtyBits |= GetLevelWorkaroundDirtyBits(); + applyTextureFunc(); + mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_BASE_LEVEL, + mState.getEffectiveBaseLevel()); } - - for (size_t i = level; i < level + levelCount; i++) + mAppliedTextureState.mBaseLevel = mState.mBaseLevel; + if (mAppliedTextureState.getEffectiveMaxLevel() != mState.getEffectiveMaxLevel()) { - mLevelInfo[i] = levelInfo; + applyTextureFunc(); + mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_MAX_LEVEL, + mState.getEffectiveMaxLevel()); } + mAppliedTextureState.mMaxLevel = mState.mMaxLevel; + + // clang-format off + const LevelInfoGL &levelInfo = mLevelInfo[mState.getEffectiveBaseLevel()]; + SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, mState.mSwizzleState, mAppliedTextureState.mSwizzleState, mState.mTarget, GL_TEXTURE_SWIZZLE_R, &gl::SwizzleState::swizzleRed); + SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, mState.mSwizzleState, mAppliedTextureState.mSwizzleState, mState.mTarget, GL_TEXTURE_SWIZZLE_G, &gl::SwizzleState::swizzleGreen); + SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, mState.mSwizzleState, mAppliedTextureState.mSwizzleState, mState.mTarget, GL_TEXTURE_SWIZZLE_B, &gl::SwizzleState::swizzleBlue); + SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, mState.mSwizzleState, mAppliedTextureState.mSwizzleState, mState.mTarget, GL_TEXTURE_SWIZZLE_A, &gl::SwizzleState::swizzleAlpha); + + // Sync sampler state + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_MIN_FILTER, &gl::SamplerState::minFilter); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_MAG_FILTER, &gl::SamplerState::magFilter); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_WRAP_S, &gl::SamplerState::wrapS); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_WRAP_T, &gl::SamplerState::wrapT); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_WRAP_R, &gl::SamplerState::wrapR); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, &gl::SamplerState::maxAnisotropy); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_MIN_LOD, &gl::SamplerState::minLod); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_MAX_LOD, &gl::SamplerState::maxLod); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_COMPARE_MODE, &gl::SamplerState::compareMode); + SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_COMPARE_FUNC, &gl::SamplerState::compareFunc); + // clang-format on } GLuint TextureGL::getTextureID() const diff --git a/gfx/angle/src/libANGLE/renderer/gl/TextureGL.h b/gfx/angle/src/libANGLE/renderer/gl/TextureGL.h index 068284c5b..540e6c3c6 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/TextureGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/TextureGL.h @@ -87,12 +87,16 @@ class TextureGL : public TextureImpl gl::Error setEGLImageTarget(GLenum target, egl::Image *image) override; + void syncState(size_t textureUnit) const; GLuint getTextureID() const; - void setBaseLevel(GLuint) override {} + gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target, + FramebufferAttachmentRenderTarget **rtOut) override + { + return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL"); + } - void syncState(const gl::Texture::DirtyBits &dirtyBits) override; - bool hasAnyDirtyBit() const; + void setBaseLevel(GLuint) override {} private: void setImageHelper(GLenum target, @@ -116,25 +120,12 @@ class TextureGL : public TextureImpl const gl::PixelUnpackState &unpack, const uint8_t *pixels); - gl::Error setSubImagePaddingWorkaround(GLenum target, - size_t level, - const gl::Box &area, - GLenum format, - GLenum type, - const gl::PixelUnpackState &unpack, - const uint8_t *pixels); - - void syncTextureStateSwizzle(const FunctionsGL *functions, GLenum name, GLenum value); - - void setLevelInfo(size_t level, size_t levelCount, const LevelInfoGL &levelInfo); - const FunctionsGL *mFunctions; const WorkaroundsGL &mWorkarounds; StateManagerGL *mStateManager; BlitGL *mBlitter; std::vector<LevelInfoGL> mLevelInfo; - gl::Texture::DirtyBits mLocalDirtyBits; mutable gl::TextureState mAppliedTextureState; GLuint mTextureID; diff --git a/gfx/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h b/gfx/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h index 105f94089..2549a2c47 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h @@ -21,13 +21,7 @@ struct WorkaroundsGL doWhileGLSLCausesGPUHang(false), finishDoesNotCauseQueriesToBeAvailable(false), alwaysCallUseProgramAfterLink(false), - unpackOverlappingRowsSeparatelyUnpackBuffer(false), - emulateAbsIntFunction(false), - addAndTrueToLoopCondition(false), - emulateIsnanFloat(false), - useUnusedBlocksWithStandardOrSharedLayout(false), - dontRemoveInvariantForFragmentInput(false), - removeInvariantAndCentroidForESSL3(false) + unpackOverlappingRowsSeparatelyUnpackBuffer(false) { } @@ -73,53 +67,6 @@ struct WorkaroundsGL // In the case of unpacking from a pixel unpack buffer, unpack overlapping rows row by row. bool unpackOverlappingRowsSeparatelyUnpackBuffer; - // In the case of packing to a pixel pack buffer, pack overlapping rows row by row. - bool packOverlappingRowsSeparatelyPackBuffer; - - // During initialization, assign the current vertex attributes to the spec-mandated defaults. - bool initializeCurrentVertexAttributes; - - // abs(i) where i is an integer returns unexpected result on Intel Mac. - // Emulate abs(i) with i * sign(i). - bool emulateAbsIntFunction; - - // On Intel Mac, calculation of loop conditions in for and while loop has bug. - // Add "&& true" to the end of the condition expression to work around the bug. - bool addAndTrueToLoopCondition; - - // When uploading textures from an unpack buffer, some drivers count an extra row padding when - // checking if the pixel unpack buffer is big enough. Tracking bug: http://anglebug.com/1512 - // For example considering the pixel buffer below where in memory, each row data (D) of the - // texture is followed by some unused data (the dots): - // +-------+--+ - // |DDDDDDD|..| - // |DDDDDDD|..| - // |DDDDDDD|..| - // |DDDDDDD|..| - // +-------A--B - // The last pixel read will be A, but the driver will think it is B, causing it to generate an - // error when the pixel buffer is just big enough. - bool unpackLastRowSeparatelyForPaddingInclusion; - - // Equivalent workaround when uploading data from a pixel pack buffer. - bool packLastRowSeparatelyForPaddingInclusion; - - // On some Intel drivers, using isnan() on highp float will get wrong answer. To work around - // this bug, we use an expression to emulate function isnan(). - // Tracking bug: http://crbug.com/650547 - bool emulateIsnanFloat; - - // On Mac with OpenGL version 4.1, unused std140 or shared uniform blocks will be - // treated as inactive which is not consistent with WebGL2.0 spec. Reference all members in a - // unused std140 or shared uniform block at the beginning of main to work around it. - bool useUnusedBlocksWithStandardOrSharedLayout; - - // This flag will keep invariant declaration for input in fragment shader for GLSL >=4.20 - // on AMD. - bool dontRemoveInvariantForFragmentInput; - - // This flag is used to fix spec difference between GLSL 4.1 or lower and ESSL3. - bool removeInvariantAndCentroidForESSL3; }; } diff --git a/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.h b/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.h index cc1b17bb7..0ba57b62b 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.h @@ -35,8 +35,7 @@ class DisplayCGL : public DisplayGL const egl::AttributeMap &attribs) override; SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) override; SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state, const egl::Config *configuration, diff --git a/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm b/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm index f87134c82..b9d5f39b0 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm +++ b/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm @@ -128,8 +128,7 @@ SurfaceImpl *DisplayCGL::createPbufferSurface(const egl::SurfaceState &state, SurfaceImpl *DisplayCGL::createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) { UNIMPLEMENTED(); diff --git a/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h b/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h index 7cbb74da4..1e198bf5a 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h @@ -53,7 +53,7 @@ class PbufferSurfaceCGL : public SurfaceGL const FunctionsGL *mFunctions; StateManagerGL *mStateManager; - RendererGL *mRenderer; + const WorkaroundsGL &mWorkarounds; GLuint mFramebuffer; GLuint mColorRenderbuffer; diff --git a/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm b/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm index c03d3836f..b9689177e 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm +++ b/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm @@ -28,7 +28,7 @@ PbufferSurfaceCGL::PbufferSurfaceCGL(const egl::SurfaceState &state, mHeight(height), mFunctions(functions), mStateManager(renderer->getStateManager()), - mRenderer(renderer), + mWorkarounds(renderer->getWorkarounds()), mFramebuffer(0), mColorRenderbuffer(0), mDSRenderbuffer(0) @@ -136,8 +136,7 @@ EGLint PbufferSurfaceCGL::getSwapBehavior() const FramebufferImpl *PbufferSurfaceCGL::createDefaultFramebuffer(const gl::FramebufferState &state) { // TODO(cwallez) assert it happens only once? - return new FramebufferGL(mFramebuffer, state, mFunctions, mRenderer->getWorkarounds(), - mRenderer->getBlitter(), mStateManager); + return new FramebufferGL(mFramebuffer, state, mFunctions, mWorkarounds, mStateManager); } } diff --git a/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h b/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h index 165ab0486..d8f1a14d7 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h @@ -88,7 +88,6 @@ class WindowSurfaceCGL : public SurfaceGL CGLContextObj mContext; const FunctionsGL *mFunctions; StateManagerGL *mStateManager; - RendererGL *mRenderer; const WorkaroundsGL &mWorkarounds; GLuint mFramebuffer; diff --git a/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm b/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm index c2ac4dca4..b5375b1f9 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm +++ b/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm @@ -154,12 +154,11 @@ mContext(context), mFunctions(functions), mStateManager(renderer->getStateManager()), - mRenderer(renderer), mWorkarounds(renderer->getWorkarounds()), mFramebuffer(0), mDSRenderbuffer(0) - { - pthread_mutex_init(&mSwapState.mutex, nullptr); +{ + pthread_mutex_init(&mSwapState.mutex, nullptr); } WindowSurfaceCGL::~WindowSurfaceCGL() @@ -325,8 +324,7 @@ EGLint WindowSurfaceCGL::getSwapBehavior() const FramebufferImpl *WindowSurfaceCGL::createDefaultFramebuffer(const gl::FramebufferState &state) { // TODO(cwallez) assert it happens only once? - return new FramebufferGL(mFramebuffer, state, mFunctions, mWorkarounds, mRenderer->getBlitter(), - mStateManager); + return new FramebufferGL(mFramebuffer, state, mFunctions, mWorkarounds, mStateManager); } } diff --git a/gfx/angle/src/libANGLE/renderer/gl/egl/SurfaceEGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/egl/SurfaceEGL.cpp index 693b61c9c..388832b2a 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/egl/SurfaceEGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/egl/SurfaceEGL.cpp @@ -33,6 +33,7 @@ SurfaceEGL::~SurfaceEGL() if (mSurface != EGL_NO_SURFACE) { EGLBoolean success = mEGL->destroySurface(mSurface); + UNUSED_ASSERTION_VARIABLE(success); ASSERT(success == EGL_TRUE); } } @@ -103,6 +104,7 @@ EGLint SurfaceEGL::getWidth() const { EGLint value; EGLBoolean success = mEGL->querySurface(mSurface, EGL_WIDTH, &value); + UNUSED_ASSERTION_VARIABLE(success); ASSERT(success == EGL_TRUE); return value; } @@ -111,6 +113,7 @@ EGLint SurfaceEGL::getHeight() const { EGLint value; EGLBoolean success = mEGL->querySurface(mSurface, EGL_HEIGHT, &value); + UNUSED_ASSERTION_VARIABLE(success); ASSERT(success == EGL_TRUE); return value; } @@ -125,6 +128,7 @@ EGLint SurfaceEGL::getSwapBehavior() const { EGLint value; EGLBoolean success = mEGL->querySurface(mSurface, EGL_SWAP_BEHAVIOR, &value); + UNUSED_ASSERTION_VARIABLE(success); ASSERT(success == EGL_TRUE); return value; } diff --git a/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp b/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp index b689578c9..4956c5b3f 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp @@ -159,6 +159,7 @@ SurfaceImpl *DisplayAndroid::createWindowSurface(const egl::SurfaceState &state, EGL_NONE}; success = mEGL->chooseConfig(configAttribList, &config, 1, &numConfig); ASSERT(success && numConfig == 1); + UNUSED_ASSERTION_VARIABLE(success); return new WindowSurfaceEGL(state, mEGL, config, window, attribs.toIntVector(), mContext, getRenderer()); @@ -176,6 +177,7 @@ SurfaceImpl *DisplayAndroid::createPbufferSurface(const egl::SurfaceState &state EGL_NONE}; success = mEGL->chooseConfig(configAttribList, &config, 1, &numConfig); ASSERT(success && numConfig == 1); + UNUSED_ASSERTION_VARIABLE(success); return new PbufferSurfaceEGL(state, mEGL, config, attribs.toIntVector(), mContext, getRenderer()); @@ -183,8 +185,7 @@ SurfaceImpl *DisplayAndroid::createPbufferSurface(const egl::SurfaceState &state SurfaceImpl *DisplayAndroid::createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) { UNIMPLEMENTED(); @@ -214,6 +215,7 @@ void DisplayAndroid::getConfigAttrib(EGLConfig config, EGLint attribute, T *valu EGLint tmp; EGLBoolean success = mEGL->getConfigAttrib(config, attribute, &tmp); ASSERT(success == EGL_TRUE); + UNUSED_ASSERTION_VARIABLE(success); *value = tmp; } @@ -231,6 +233,7 @@ egl::ConfigSet DisplayAndroid::generateConfigs() success = mEGL->chooseConfig(mConfigAttribList.data(), configs.data(), numConfigs, &numConfigs2); ASSERT(success == EGL_TRUE && numConfigs2 == numConfigs); + UNUSED_ASSERTION_VARIABLE(success); for (int i = 0; i < numConfigs; i++) { diff --git a/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.h b/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.h index 0be9bb465..693532fb4 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.h +++ b/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.h @@ -36,8 +36,7 @@ class DisplayAndroid : public DisplayEGL const egl::AttributeMap &attribs) override; SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) override; SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state, const egl::Config *configuration, diff --git a/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp b/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp index 01549fcfa..6f5321632 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp @@ -308,9 +308,9 @@ uint32_t DisplayOzone::Buffer::getDRMFB() FramebufferGL *DisplayOzone::Buffer::framebufferGL(const gl::FramebufferState &state) { - return new FramebufferGL( - mGLFB, state, mDisplay->mFunctionsGL, mDisplay->getRenderer()->getWorkarounds(), - mDisplay->getRenderer()->getBlitter(), mDisplay->getRenderer()->getStateManager()); + return new FramebufferGL(mGLFB, state, mDisplay->mFunctionsGL, + mDisplay->getRenderer()->getWorkarounds(), + mDisplay->getRenderer()->getStateManager()); } void DisplayOzone::Buffer::present() @@ -859,8 +859,7 @@ SurfaceImpl *DisplayOzone::createPbufferSurface(const egl::SurfaceState &state, SurfaceImpl *DisplayOzone::createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) { UNIMPLEMENTED(); diff --git a/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.h b/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.h index 77c669314..55a188c3e 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.h +++ b/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.h @@ -122,8 +122,7 @@ class DisplayOzone final : public DisplayEGL const egl::AttributeMap &attribs) override; SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) override; SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state, const egl::Config *configuration, diff --git a/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.cpp b/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.cpp index c5219b4b8..1688be116 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.cpp @@ -438,32 +438,6 @@ static GLenum GetNativeType(const FunctionsGL *functions, return result; } -static GLenum GetNativeReadType(const FunctionsGL *functions, - const WorkaroundsGL &workarounds, - GLenum type) -{ - GLenum result = type; - - if (functions->standard == STANDARD_GL_DESKTOP) - { - if (type == GL_HALF_FLOAT_OES) - { - // The enums differ for the OES half float extensions and desktop GL spec. Update it. - result = GL_HALF_FLOAT; - } - } - - return result; -} - -static GLenum GetNativeReadFormat(const FunctionsGL *functions, - const WorkaroundsGL &workarounds, - GLenum format) -{ - GLenum result = format; - return result; -} - TexImageFormat GetTexImageFormat(const FunctionsGL *functions, const WorkaroundsGL &workarounds, GLenum internalFormat, @@ -538,16 +512,6 @@ RenderbufferFormat GetRenderbufferFormat(const FunctionsGL *functions, GetNativeInternalFormat(functions, workarounds, internalFormat, internalFormat); return result; } -ReadPixelsFormat GetReadPixelsFormat(const FunctionsGL *functions, - const WorkaroundsGL &workarounds, - GLenum format, - GLenum type) -{ - ReadPixelsFormat result; - result.format = GetNativeReadFormat(functions, workarounds, format); - result.type = GetNativeReadType(functions, workarounds, type); - return result; -} } } diff --git a/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.h b/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.h index 616f37af2..547d4783e 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.h +++ b/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.h @@ -112,16 +112,6 @@ struct RenderbufferFormat RenderbufferFormat GetRenderbufferFormat(const FunctionsGL *functions, const WorkaroundsGL &workarounds, GLenum internalFormat); - -struct ReadPixelsFormat -{ - GLenum format; - GLenum type; -}; -ReadPixelsFormat GetReadPixelsFormat(const FunctionsGL *functions, - const WorkaroundsGL &workarounds, - GLenum format, - GLenum type); } } diff --git a/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp b/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp index e98401d0a..0358a428e 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp @@ -350,7 +350,7 @@ egl::Error DisplayGLX::initialize(egl::Display *display) bool isOpenGLES = eglAttributes.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE) == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE; - if (isOpenGLES && (IsIntel(vendor) || IsNvidia(vendor))) + if (isOpenGLES && (vendor == VENDOR_ID_INTEL || vendor == VENDOR_ID_NVIDIA)) { return egl::Error(EGL_NOT_INITIALIZED, "Intel or NVIDIA OpenGL ES drivers are not supported."); } @@ -410,8 +410,7 @@ SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::SurfaceState &state, SurfaceImpl *DisplayGLX::createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) { UNIMPLEMENTED(); diff --git a/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.h b/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.h index 7e870c2f3..79198395d 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.h +++ b/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.h @@ -53,8 +53,7 @@ class DisplayGLX : public DisplayGL const egl::AttributeMap &attribs) override; SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) override; SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state, const egl::Config *configuration, diff --git a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp index 504a787f8..87fd24a61 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp @@ -11,8 +11,6 @@ #include <limits> -#include "common/mathutil.h" -#include "libANGLE/Buffer.h" #include "libANGLE/Caps.h" #include "libANGLE/formatutils.h" #include "libANGLE/renderer/gl/FunctionsGL.h" @@ -22,8 +20,6 @@ #include <algorithm> #include <sstream> -using angle::CheckedNumeric; - namespace rx { VendorID GetVendorID(const FunctionsGL *functions) @@ -871,81 +867,35 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM functions->isAtLeastGLES(gl::Version(3, 1)); extensions->pathRendering = canEnableGLPathRendering || canEnableESPathRendering; - - extensions->textureSRGBDecode = functions->hasGLExtension("GL_EXT_texture_sRGB_decode") || - functions->hasGLESExtension("GL_EXT_texture_sRGB_decode"); - -#if defined(ANGLE_PLATFORM_APPLE) - VendorID vendor = GetVendorID(functions); - if ((IsAMD(vendor) || IsIntel(vendor)) && *maxSupportedESVersion >= gl::Version(3, 0)) - { - // Apple Intel/AMD drivers do not correctly use the TEXTURE_SRGB_DECODE property of sampler - // states. Disable this extension when we would advertise any ES version that has samplers. - extensions->textureSRGBDecode = false; - } -#endif - - extensions->sRGBWriteControl = functions->isAtLeastGL(gl::Version(3, 0)) || - functions->hasGLExtension("GL_EXT_framebuffer_sRGB") || - functions->hasGLExtension("GL_ARB_framebuffer_sRGB") || - functions->hasGLESExtension("GL_EXT_sRGB_write_control"); - -#if defined(ANGLE_PLATFORM_ANDROID) - // SRGB blending does not appear to work correctly on the Nexus 5. Writing to an SRGB - // framebuffer with GL_FRAMEBUFFER_SRGB enabled and then reading back returns the same value. - // Disabling GL_FRAMEBUFFER_SRGB will then convert in the wrong direction. - extensions->sRGBWriteControl = false; -#endif } void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds) { VendorID vendor = GetVendorID(functions); - workarounds->dontRemoveInvariantForFragmentInput = - functions->standard == STANDARD_GL_DESKTOP && IsAMD(vendor); - // Don't use 1-bit alpha formats on desktop GL with AMD or Intel drivers. workarounds->avoid1BitAlphaTextureFormats = - functions->standard == STANDARD_GL_DESKTOP && (IsAMD(vendor) || IsIntel(vendor)); + functions->standard == STANDARD_GL_DESKTOP && + (vendor == VENDOR_ID_AMD || vendor == VENDOR_ID_INTEL); workarounds->rgba4IsNotSupportedForColorRendering = - functions->standard == STANDARD_GL_DESKTOP && IsIntel(vendor); - - workarounds->emulateAbsIntFunction = IsIntel(vendor); - - workarounds->addAndTrueToLoopCondition = IsIntel(vendor); - - workarounds->emulateIsnanFloat = IsIntel(vendor); + functions->standard == STANDARD_GL_DESKTOP && vendor == VENDOR_ID_INTEL; workarounds->doesSRGBClearsOnLinearFramebufferAttachments = - functions->standard == STANDARD_GL_DESKTOP && (IsIntel(vendor) || IsAMD(vendor)); + functions->standard == STANDARD_GL_DESKTOP && + (vendor == VENDOR_ID_INTEL || vendor == VENDOR_ID_AMD); #if defined(ANGLE_PLATFORM_APPLE) workarounds->doWhileGLSLCausesGPUHang = true; - workarounds->useUnusedBlocksWithStandardOrSharedLayout = true; #endif workarounds->finishDoesNotCauseQueriesToBeAvailable = - functions->standard == STANDARD_GL_DESKTOP && IsNvidia(vendor); + functions->standard == STANDARD_GL_DESKTOP && vendor == VENDOR_ID_NVIDIA; // TODO(cwallez): Disable this workaround for MacOSX versions 10.9 or later. workarounds->alwaysCallUseProgramAfterLink = true; - workarounds->unpackOverlappingRowsSeparatelyUnpackBuffer = IsNvidia(vendor); - workarounds->packOverlappingRowsSeparatelyPackBuffer = IsNvidia(vendor); - - workarounds->initializeCurrentVertexAttributes = IsNvidia(vendor); - -#if defined(ANGLE_PLATFORM_APPLE) - workarounds->unpackLastRowSeparatelyForPaddingInclusion = true; - workarounds->packLastRowSeparatelyForPaddingInclusion = true; -#else - workarounds->unpackLastRowSeparatelyForPaddingInclusion = IsNvidia(vendor); - workarounds->packLastRowSeparatelyForPaddingInclusion = IsNvidia(vendor); -#endif - - workarounds->removeInvariantAndCentroidForESSL3 = functions->isAtMostGL(gl::Version(4, 1)); + workarounds->unpackOverlappingRowsSeparatelyUnpackBuffer = vendor == VENDOR_ID_NVIDIA; } } @@ -1001,45 +951,4 @@ uint8_t *MapBufferRangeWithFallback(const FunctionsGL *functions, return nullptr; } } - -gl::ErrorOrResult<bool> ShouldApplyLastRowPaddingWorkaround(const gl::Extents &size, - const gl::PixelStoreStateBase &state, - GLenum format, - GLenum type, - bool is3D, - const void *pixels) -{ - if (state.pixelBuffer.get() == nullptr) - { - return false; - } - - // We are using an pack or unpack buffer, compute what the driver thinks is going to be the - // last byte read or written. If it is past the end of the buffer, we will need to use the - // workaround otherwise the driver will generate INVALID_OPERATION and not do the operation. - CheckedNumeric<size_t> checkedEndByte; - CheckedNumeric<size_t> pixelBytes; - size_t rowPitch; - - const gl::InternalFormat &glFormat = - gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type)); - ANGLE_TRY_RESULT(glFormat.computePackUnpackEndByte(size, state, is3D), checkedEndByte); - ANGLE_TRY_RESULT(glFormat.computeRowPitch(size.width, state.alignment, state.rowLength), - rowPitch); - pixelBytes = glFormat.pixelBytes; - - checkedEndByte += reinterpret_cast<intptr_t>(pixels); - - // At this point checkedEndByte is the actual last byte read. - // The driver adds an extra row padding (if any), mimic it. - ANGLE_TRY_CHECKED_MATH(pixelBytes); - if (pixelBytes.ValueOrDie() * size.width < rowPitch) - { - checkedEndByte += rowPitch - pixelBytes * size.width; - } - - ANGLE_TRY_CHECKED_MATH(checkedEndByte); - - return checkedEndByte.ValueOrDie() > static_cast<size_t>(state.pixelBuffer->getSize()); -} } diff --git a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.h b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.h index 1e9338fb5..3b0cab27e 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.h +++ b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.h @@ -11,8 +11,6 @@ #define LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_ #include "libANGLE/angletypes.h" -#include "libANGLE/Error.h" -#include "libANGLE/renderer/driver_utils.h" #include "libANGLE/renderer/gl/functionsgl_typedefs.h" #include <string> @@ -49,13 +47,6 @@ uint8_t *MapBufferRangeWithFallback(const FunctionsGL *functions, size_t offset, size_t length, GLbitfield access); - -gl::ErrorOrResult<bool> ShouldApplyLastRowPaddingWorkaround(const gl::Extents &size, - const gl::PixelStoreStateBase &state, - GLenum format, - GLenum type, - bool is3D, - const void *pixels); } #endif // LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_ diff --git a/gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.cpp deleted file mode 100644 index f19e8fdf3..000000000 --- a/gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.cpp +++ /dev/null @@ -1,384 +0,0 @@ -// -// Copyright (c) 2015 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. -// - -// D3DTextureSurfaceWGL.cpp: WGL implementation of egl::Surface for D3D texture interop. - -#include "libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.h" - -#include "libANGLE/renderer/gl/FramebufferGL.h" -#include "libANGLE/renderer/gl/TextureGL.h" -#include "libANGLE/renderer/gl/RendererGL.h" -#include "libANGLE/renderer/gl/StateManagerGL.h" -#include "libANGLE/renderer/gl/wgl/DisplayWGL.h" -#include "libANGLE/renderer/gl/wgl/FunctionsWGL.h" - -namespace rx -{ - -namespace -{ - -egl::Error GetD3DTextureInfo(EGLClientBuffer clientBuffer, - size_t *width, - size_t *height, - IUnknown **object, - IUnknown **device) -{ - IUnknown *buffer = static_cast<IUnknown *>(clientBuffer); - - IDirect3DTexture9 *texture9 = nullptr; - ID3D11Texture2D *texture11 = nullptr; - if (SUCCEEDED(buffer->QueryInterface<ID3D11Texture2D>(&texture11))) - { - D3D11_TEXTURE2D_DESC textureDesc; - texture11->GetDesc(&textureDesc); - - // From table egl.restrictions in EGL_ANGLE_d3d_texture_client_buffer. - switch (textureDesc.Format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - break; - - default: - SafeRelease(texture11); - return egl::Error(EGL_BAD_PARAMETER, "Unknown client buffer texture format: %u.", - textureDesc.Format); - } - - ID3D11Device *d3d11Device = nullptr; - texture11->GetDevice(&d3d11Device); - if (d3d11Device == nullptr) - { - SafeRelease(texture11); - return egl::Error(EGL_BAD_PARAMETER, - "Could not query the D3D11 device from the client buffer."); - } - - if (width) - { - *width = textureDesc.Width; - } - if (height) - { - *height = textureDesc.Height; - } - - if (device) - { - *device = d3d11Device; - } - else - { - SafeRelease(d3d11Device); - } - - if (object) - { - *object = texture11; - } - else - { - SafeRelease(texture11); - } - - return egl::Error(EGL_SUCCESS); - } - else if (SUCCEEDED(buffer->QueryInterface<IDirect3DTexture9>(&texture9))) - { - D3DSURFACE_DESC surfaceDesc; - if (FAILED(texture9->GetLevelDesc(0, &surfaceDesc))) - { - SafeRelease(texture9); - return egl::Error(EGL_BAD_PARAMETER, - "Could not query description of the D3D9 surface."); - } - - // From table egl.restrictions in EGL_ANGLE_d3d_texture_client_buffer. - switch (surfaceDesc.Format) - { - case D3DFMT_R8G8B8: - case D3DFMT_A8R8G8B8: - case D3DFMT_A16B16G16R16F: - case D3DFMT_A32B32G32R32F: - break; - - default: - SafeRelease(texture9); - return egl::Error(EGL_BAD_PARAMETER, "Unknown client buffer texture format: %u.", - surfaceDesc.Format); - } - - if (width) - { - *width = surfaceDesc.Width; - } - if (height) - { - *height = surfaceDesc.Height; - } - - IDirect3DDevice9 *d3d9Device = nullptr; - HRESULT result = texture9->GetDevice(&d3d9Device); - if (FAILED(result)) - { - SafeRelease(texture9); - return egl::Error(EGL_BAD_PARAMETER, - "Could not query the D3D9 device from the client buffer."); - } - - if (device) - { - *device = d3d9Device; - } - else - { - SafeRelease(d3d9Device); - } - - if (object) - { - *object = texture9; - } - else - { - SafeRelease(texture9); - } - - return egl::Error(EGL_SUCCESS); - } - else - { - return egl::Error(EGL_BAD_PARAMETER, - "Provided buffer is not a IDirect3DTexture9 or ID3D11Texture2D."); - } -} - -} // anonymous namespace - -D3DTextureSurfaceWGL::D3DTextureSurfaceWGL(const egl::SurfaceState &state, - RendererGL *renderer, - EGLClientBuffer clientBuffer, - DisplayWGL *display, - HGLRC wglContext, - HDC deviceContext, - const FunctionsGL *functionsGL, - const FunctionsWGL *functionsWGL) - : SurfaceGL(state, renderer), - mClientBuffer(clientBuffer), - mRenderer(renderer), - mDisplay(display), - mStateManager(renderer->getStateManager()), - mWorkarounds(renderer->getWorkarounds()), - mFunctionsGL(functionsGL), - mFunctionsWGL(functionsWGL), - mWGLContext(wglContext), - mDeviceContext(deviceContext), - mWidth(0), - mHeight(0), - mDeviceHandle(nullptr), - mObject(nullptr), - mBoundObjectTextureHandle(nullptr), - mBoundObjectRenderbufferHandle(nullptr), - mRenderbufferID(0), - mFramebufferID(0) -{ -} - -D3DTextureSurfaceWGL::~D3DTextureSurfaceWGL() -{ - ASSERT(mBoundObjectTextureHandle == nullptr); - - SafeRelease(mObject); - - if (mDeviceHandle) - { - if (mBoundObjectRenderbufferHandle) - { - mFunctionsWGL->dxUnregisterObjectNV(mDeviceHandle, mBoundObjectRenderbufferHandle); - mBoundObjectRenderbufferHandle = nullptr; - } - mStateManager->deleteRenderbuffer(mRenderbufferID); - - if (mBoundObjectTextureHandle) - { - mFunctionsWGL->dxUnregisterObjectNV(mDeviceHandle, mBoundObjectTextureHandle); - mBoundObjectTextureHandle = nullptr; - } - - // GL framebuffer is deleted by the default framebuffer object - mFramebufferID = 0; - - mDisplay->releaseD3DDevice(mDeviceHandle); - mDeviceHandle = nullptr; - } -} - -egl::Error D3DTextureSurfaceWGL::ValidateD3DTextureClientBuffer(EGLClientBuffer clientBuffer) -{ - return GetD3DTextureInfo(clientBuffer, nullptr, nullptr, nullptr, nullptr); -} - -egl::Error D3DTextureSurfaceWGL::initialize() -{ - IUnknown *device = nullptr; - ANGLE_TRY(GetD3DTextureInfo(mClientBuffer, &mWidth, &mHeight, &mObject, &device)); - - ASSERT(device != nullptr); - egl::Error error = mDisplay->registerD3DDevice(device, &mDeviceHandle); - SafeRelease(device); - if (error.isError()) - { - return error; - } - - mFunctionsGL->genRenderbuffers(1, &mRenderbufferID); - mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mRenderbufferID); - mBoundObjectRenderbufferHandle = mFunctionsWGL->dxRegisterObjectNV( - mDeviceHandle, mObject, mRenderbufferID, GL_RENDERBUFFER, WGL_ACCESS_READ_WRITE_NV); - if (mBoundObjectRenderbufferHandle == nullptr) - { - return egl::Error(EGL_BAD_ALLOC, "Failed to register D3D object, error: 0x%08x.", - HRESULT_CODE(GetLastError())); - } - - mFunctionsGL->genFramebuffers(1, &mFramebufferID); - mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); - mFunctionsGL->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, - mRenderbufferID); - - return egl::Error(EGL_SUCCESS); -} - -egl::Error D3DTextureSurfaceWGL::makeCurrent() -{ - if (!mFunctionsWGL->makeCurrent(mDeviceContext, mWGLContext)) - { - // TODO(geofflang): What error type here? - return egl::Error(EGL_CONTEXT_LOST, "Failed to make the WGL context current."); - } - - if (!mFunctionsWGL->dxLockObjectsNV(mDeviceHandle, 1, &mBoundObjectRenderbufferHandle)) - { - DWORD error = GetLastError(); - return egl::Error(EGL_BAD_ALLOC, "Failed to lock object, error: 0x%08x.", - HRESULT_CODE(error)); - } - - return egl::Error(EGL_SUCCESS); -} - -egl::Error D3DTextureSurfaceWGL::unMakeCurrent() -{ - if (!mFunctionsWGL->dxUnlockObjectsNV(mDeviceHandle, 1, &mBoundObjectRenderbufferHandle)) - { - DWORD error = GetLastError(); - return egl::Error(EGL_BAD_ALLOC, "Failed to unlock object, error: 0x%08x.", - HRESULT_CODE(error)); - } - - return egl::Error(EGL_SUCCESS); -} - -egl::Error D3DTextureSurfaceWGL::swap() -{ - return egl::Error(EGL_SUCCESS); -} - -egl::Error D3DTextureSurfaceWGL::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) -{ - UNIMPLEMENTED(); - return egl::Error(EGL_SUCCESS); -} - -egl::Error D3DTextureSurfaceWGL::querySurfacePointerANGLE(EGLint attribute, void **value) -{ - UNIMPLEMENTED(); - return egl::Error(EGL_SUCCESS); -} - -egl::Error D3DTextureSurfaceWGL::bindTexImage(gl::Texture *texture, EGLint buffer) -{ - ASSERT(mBoundObjectTextureHandle == nullptr); - - const TextureGL *textureGL = GetImplAs<TextureGL>(texture); - GLuint textureID = textureGL->getTextureID(); - - mBoundObjectTextureHandle = mFunctionsWGL->dxRegisterObjectNV( - mDeviceHandle, mObject, textureID, GL_TEXTURE_2D, WGL_ACCESS_READ_WRITE_NV); - if (mBoundObjectTextureHandle == nullptr) - { - DWORD error = GetLastError(); - return egl::Error(EGL_BAD_ALLOC, "Failed to register D3D object, error: 0x%08x.", - HRESULT_CODE(error)); - } - - if (!mFunctionsWGL->dxLockObjectsNV(mDeviceHandle, 1, &mBoundObjectTextureHandle)) - { - DWORD error = GetLastError(); - return egl::Error(EGL_BAD_ALLOC, "Failed to lock object, error: 0x%08x.", - HRESULT_CODE(error)); - } - - return egl::Error(EGL_SUCCESS); -} - -egl::Error D3DTextureSurfaceWGL::releaseTexImage(EGLint buffer) -{ - ASSERT(mBoundObjectTextureHandle != nullptr); - if (!mFunctionsWGL->dxUnlockObjectsNV(mDeviceHandle, 1, &mBoundObjectTextureHandle)) - { - DWORD error = GetLastError(); - return egl::Error(EGL_BAD_ALLOC, "Failed to unlock object, error: 0x%08x.", - HRESULT_CODE(error)); - } - - if (!mFunctionsWGL->dxUnregisterObjectNV(mDeviceHandle, mBoundObjectTextureHandle)) - { - DWORD error = GetLastError(); - return egl::Error(EGL_BAD_ALLOC, "Failed to unregister D3D object, error: 0x%08x.", - HRESULT_CODE(error)); - } - mBoundObjectTextureHandle = nullptr; - - return egl::Error(EGL_SUCCESS); -} - -void D3DTextureSurfaceWGL::setSwapInterval(EGLint interval) -{ - UNIMPLEMENTED(); -} - -EGLint D3DTextureSurfaceWGL::getWidth() const -{ - return static_cast<EGLint>(mWidth); -} - -EGLint D3DTextureSurfaceWGL::getHeight() const -{ - return static_cast<EGLint>(mHeight); -} - -EGLint D3DTextureSurfaceWGL::isPostSubBufferSupported() const -{ - return EGL_FALSE; -} - -EGLint D3DTextureSurfaceWGL::getSwapBehavior() const -{ - return EGL_BUFFER_PRESERVED; -} - -FramebufferImpl *D3DTextureSurfaceWGL::createDefaultFramebuffer(const gl::FramebufferState &data) -{ - return new FramebufferGL(mFramebufferID, data, mFunctionsGL, mWorkarounds, - mRenderer->getBlitter(), mStateManager); -} -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.h b/gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.h deleted file mode 100644 index 8fb1d4003..000000000 --- a/gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.h +++ /dev/null @@ -1,86 +0,0 @@ - -// Copyright (c) 2015 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. -// - -// D3DTextureSurfaceWGL.h: WGL implementation of egl::Surface for D3D texture interop. - -#ifndef LIBANGLE_RENDERER_GL_WGL_D3DTEXTIRESURFACEWGL_H_ -#define LIBANGLE_RENDERER_GL_WGL_D3DTEXTIRESURFACEWGL_H_ - -#include "libANGLE/renderer/gl/SurfaceGL.h" - -#include <GL/wglext.h> - -namespace rx -{ - -class FunctionsGL; -class FunctionsWGL; -class DisplayWGL; -class StateManagerGL; -struct WorkaroundsGL; - -class D3DTextureSurfaceWGL : public SurfaceGL -{ - public: - D3DTextureSurfaceWGL(const egl::SurfaceState &state, - RendererGL *renderer, - EGLClientBuffer clientBuffer, - DisplayWGL *display, - HGLRC wglContext, - HDC deviceContext, - const FunctionsGL *functionsGL, - const FunctionsWGL *functionsWGL); - ~D3DTextureSurfaceWGL() override; - - static egl::Error ValidateD3DTextureClientBuffer(EGLClientBuffer clientBuffer); - - egl::Error initialize() override; - egl::Error makeCurrent() override; - egl::Error unMakeCurrent() override; - - egl::Error swap() override; - egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) override; - egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override; - egl::Error bindTexImage(gl::Texture *texture, EGLint buffer) override; - egl::Error releaseTexImage(EGLint buffer) override; - void setSwapInterval(EGLint interval) override; - - EGLint getWidth() const override; - EGLint getHeight() const override; - - EGLint isPostSubBufferSupported() const override; - EGLint getSwapBehavior() const override; - - FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override; - - private: - EGLClientBuffer mClientBuffer; - - RendererGL *mRenderer; - - DisplayWGL *mDisplay; - StateManagerGL *mStateManager; - const WorkaroundsGL &mWorkarounds; - const FunctionsGL *mFunctionsGL; - const FunctionsWGL *mFunctionsWGL; - - HGLRC mWGLContext; - HDC mDeviceContext; - - size_t mWidth; - size_t mHeight; - - HANDLE mDeviceHandle; - IUnknown *mObject; - HANDLE mBoundObjectTextureHandle; - HANDLE mBoundObjectRenderbufferHandle; - - GLuint mRenderbufferID; - GLuint mFramebufferID; -}; -} // namespace rx - -#endif // LIBANGLE_RENDERER_GL_WGL_D3DTEXTIRESURFACEWGL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp index 7c5214e82..e07457d10 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp @@ -36,7 +36,6 @@ DXGISwapChainWindowSurfaceWGL::DXGISwapChainWindowSurfaceWGL(const egl::SurfaceS mWindow(window), mStateManager(renderer->getStateManager()), mWorkarounds(renderer->getWorkarounds()), - mRenderer(renderer), mFunctionsGL(functionsGL), mFunctionsWGL(functionsWGL), mDevice(device), @@ -293,8 +292,7 @@ EGLint DXGISwapChainWindowSurfaceWGL::getSwapBehavior() const FramebufferImpl *DXGISwapChainWindowSurfaceWGL::createDefaultFramebuffer( const gl::FramebufferState &data) { - return new FramebufferGL(mFramebufferID, data, mFunctionsGL, mWorkarounds, - mRenderer->getBlitter(), mStateManager); + return new FramebufferGL(mFramebufferID, data, mFunctionsGL, mWorkarounds, mStateManager); } egl::Error DXGISwapChainWindowSurfaceWGL::setObjectsLocked(bool locked) diff --git a/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h b/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h index f516239c9..66444da9b 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h @@ -66,7 +66,6 @@ class DXGISwapChainWindowSurfaceWGL : public SurfaceGL StateManagerGL *mStateManager; const WorkaroundsGL &mWorkarounds; - RendererGL *mRenderer; const FunctionsGL *mFunctionsGL; const FunctionsWGL *mFunctionsWGL; diff --git a/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp index 188321115..4647fe589 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp @@ -14,15 +14,12 @@ #include "libANGLE/Surface.h" #include "libANGLE/renderer/gl/RendererGL.h" #include "libANGLE/renderer/gl/renderergl_utils.h" -#include "libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.h" #include "libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h" #include "libANGLE/renderer/gl/wgl/FunctionsWGL.h" #include "libANGLE/renderer/gl/wgl/PbufferSurfaceWGL.h" #include "libANGLE/renderer/gl/wgl/WindowSurfaceWGL.h" #include "libANGLE/renderer/gl/wgl/wgl_utils.h" -#include "platform/Platform.h" - #include <EGL/eglext.h> #include <string> #include <sstream> @@ -63,7 +60,7 @@ DisplayWGL::DisplayWGL() mOpenGLModule(nullptr), mFunctionsWGL(nullptr), mFunctionsGL(nullptr), - mHasRobustness(false), + mHasARBCreateContextRobustness(false), mWindowClass(0), mWindow(nullptr), mDeviceContext(nullptr), @@ -178,7 +175,7 @@ egl::Error DisplayWGL::initialize(egl::Display *display) // Reinitialize the wgl functions to grab the extensions mFunctionsWGL->initialize(mOpenGLModule, dummyDeviceContext); - bool hasWGLCreateContextRobustness = + mHasARBCreateContextRobustness = mFunctionsWGL->hasExtension("WGL_ARB_create_context_robustness"); // Destroy the dummy window and context @@ -267,7 +264,7 @@ egl::Error DisplayWGL::initialize(egl::Display *display) std::vector<int> contextCreationAttributes; - if (hasWGLCreateContextRobustness) + if (mHasARBCreateContextRobustness) { contextCreationAttributes.push_back(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB); contextCreationAttributes.push_back(WGL_LOSE_CONTEXT_ON_RESET_ARB); @@ -343,17 +340,9 @@ egl::Error DisplayWGL::initialize(egl::Display *display) mFunctionsGL = new FunctionsGLWindows(mOpenGLModule, mFunctionsWGL->getProcAddress); mFunctionsGL->initialize(); - mHasRobustness = mFunctionsGL->getGraphicsResetStatus != nullptr; - if (hasWGLCreateContextRobustness != mHasRobustness) - { - ANGLEPlatformCurrent()->logWarning( - "WGL_ARB_create_context_robustness exists but unable to OpenGL context with " - "robustness."); - } - // Intel OpenGL ES drivers are not currently supported due to bugs in the driver and ANGLE VendorID vendor = GetVendorID(mFunctionsGL); - if (requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE && IsIntel(vendor)) + if (requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE && vendor == VENDOR_ID_INTEL) { return egl::Error(EGL_NOT_INITIALIZED, "Intel OpenGL ES drivers are not supported."); } @@ -369,7 +358,7 @@ egl::Error DisplayWGL::initialize(egl::Display *display) GetWindowThreadProcessId(nativeWindow, &windowProcessId); // AMD drivers advertise the WGL_NV_DX_interop and WGL_NV_DX_interop2 extensions but fail - mUseDXGISwapChains = !IsAMD(vendor) && (currentProcessId != windowProcessId); + mUseDXGISwapChains = vendor != VENDOR_ID_AMD && (currentProcessId != windowProcessId); } else { @@ -465,13 +454,11 @@ SurfaceImpl *DisplayWGL::createPbufferSurface(const egl::SurfaceState &state, SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) { - ASSERT(buftype == EGL_D3D_TEXTURE_ANGLE); - return new D3DTextureSurfaceWGL(state, getRenderer(), clientBuffer, this, mWGLContext, - mDeviceContext, mFunctionsGL, mFunctionsWGL); + UNIMPLEMENTED(); + return nullptr; } SurfaceImpl *DisplayWGL::createPixmapSurface(const egl::SurfaceState &state, @@ -566,7 +553,7 @@ egl::ConfigSet DisplayWGL::generateConfigs() bool DisplayWGL::testDeviceLost() { - if (mHasRobustness) + if (mHasARBCreateContextRobustness) { return getRenderer()->getResetStatus() != GL_NO_ERROR; } @@ -584,21 +571,6 @@ bool DisplayWGL::isValidNativeWindow(EGLNativeWindowType window) const return (IsWindow(window) == TRUE); } -egl::Error DisplayWGL::validateClientBuffer(const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, - const egl::AttributeMap &attribs) const -{ - switch (buftype) - { - case EGL_D3D_TEXTURE_ANGLE: - return D3DTextureSurfaceWGL::ValidateD3DTextureClientBuffer(clientBuffer); - - default: - return DisplayGL::validateClientBuffer(configuration, buftype, clientBuffer, attribs); - } -} - std::string DisplayWGL::getVendorString() const { //UNIMPLEMENTED(); @@ -661,9 +633,7 @@ void DisplayWGL::generateExtensions(egl::DisplayExtensions *outExtensions) const outExtensions->postSubBuffer = mUseDXGISwapChains; outExtensions->surfaceOrientation = mUseDXGISwapChains; - outExtensions->createContextRobustness = mHasRobustness; - - outExtensions->d3dTextureClientBuffer = mFunctionsWGL->hasExtension("WGL_NV_DX_interop2"); + outExtensions->createContextRobustness = mHasARBCreateContextRobustness; } void DisplayWGL::generateCaps(egl::Caps *outCaps) const diff --git a/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.h b/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.h index 509ea9b39..3f56ecf4f 100755 --- a/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.h +++ b/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.h @@ -37,8 +37,7 @@ class DisplayWGL : public DisplayGL const egl::AttributeMap &attribs) override; SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) override; SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state, const egl::Config *configuration, @@ -51,10 +50,6 @@ class DisplayWGL : public DisplayGL egl::Error restoreLostDevice() override; bool isValidNativeWindow(EGLNativeWindowType window) const override; - egl::Error validateClientBuffer(const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, - const egl::AttributeMap &attribs) const override; egl::Error getDevice(DeviceImpl **device) override; @@ -83,7 +78,7 @@ class DisplayWGL : public DisplayGL FunctionsWGL *mFunctionsWGL; FunctionsGL *mFunctionsGL; - bool mHasRobustness; + bool mHasARBCreateContextRobustness; ATOM mWindowClass; HWND mWindow; diff --git a/gfx/angle/src/libANGLE/renderer/null/BufferNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/BufferNULL.cpp deleted file mode 100644 index 95463c3f4..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/BufferNULL.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright 2016 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. -// -// BufferNULL.cpp: -// Implements the class methods for BufferNULL. -// - -#include "libANGLE/renderer/null/BufferNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -BufferNULL::BufferNULL(const gl::BufferState &state) : BufferImpl(state) -{ -} - -BufferNULL::~BufferNULL() -{ -} - -gl::Error BufferNULL::setData(GLenum target, const void *data, size_t size, GLenum usage) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error BufferNULL::setSubData(GLenum target, const void *data, size_t size, size_t offset) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error BufferNULL::copySubData(BufferImpl *source, - GLintptr sourceOffset, - GLintptr destOffset, - GLsizeiptr size) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error BufferNULL::map(GLenum access, GLvoid **mapPtr) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error BufferNULL::mapRange(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error BufferNULL::unmap(GLboolean *result) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error BufferNULL::getIndexRange(GLenum type, - size_t offset, - size_t count, - bool primitiveRestartEnabled, - gl::IndexRange *outRange) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/BufferNULL.h b/gfx/angle/src/libANGLE/renderer/null/BufferNULL.h deleted file mode 100644 index 1578dacbb..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/BufferNULL.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// Copyright 2016 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. -// -// BufferNULL.h: -// Defines the class interface for BufferNULL, implementing BufferImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_BUFFERNULL_H_ -#define LIBANGLE_RENDERER_NULL_BUFFERNULL_H_ - -#include "libANGLE/renderer/BufferImpl.h" - -namespace rx -{ - -class BufferNULL : public BufferImpl -{ - public: - BufferNULL(const gl::BufferState &state); - ~BufferNULL() override; - - gl::Error setData(GLenum target, const void *data, size_t size, GLenum usage) override; - gl::Error setSubData(GLenum target, const void *data, size_t size, size_t offset) override; - gl::Error copySubData(BufferImpl *source, - GLintptr sourceOffset, - GLintptr destOffset, - GLsizeiptr size) override; - gl::Error map(GLenum access, GLvoid **mapPtr) override; - gl::Error mapRange(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr) override; - gl::Error unmap(GLboolean *result) override; - - gl::Error getIndexRange(GLenum type, - size_t offset, - size_t count, - bool primitiveRestartEnabled, - gl::IndexRange *outRange) override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_BUFFERNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/CompilerNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/CompilerNULL.cpp deleted file mode 100644 index 547f4c4e1..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/CompilerNULL.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// -// Copyright 2016 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. -// -// CompilerNULL.cpp: -// Implements the class methods for CompilerNULL. -// - -#include "libANGLE/renderer/null/CompilerNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -CompilerNULL::CompilerNULL() : CompilerImpl() -{ -} - -CompilerNULL::~CompilerNULL() -{ -} - -gl::Error CompilerNULL::release() -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -ShShaderOutput CompilerNULL::getTranslatorOutputType() const -{ - UNIMPLEMENTED(); - return ShShaderOutput(); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/CompilerNULL.h b/gfx/angle/src/libANGLE/renderer/null/CompilerNULL.h deleted file mode 100644 index 5cd85e8bf..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/CompilerNULL.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright 2016 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. -// -// CompilerNULL.h: -// Defines the class interface for CompilerNULL, implementing CompilerImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_COMPILERNULL_H_ -#define LIBANGLE_RENDERER_NULL_COMPILERNULL_H_ - -#include "libANGLE/renderer/CompilerImpl.h" - -namespace rx -{ - -class CompilerNULL : public CompilerImpl -{ - public: - CompilerNULL(); - ~CompilerNULL() override; - - gl::Error release() override; - - // TODO(jmadill): Expose translator built-in resources init method. - ShShaderOutput getTranslatorOutputType() const override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_COMPILERNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/ContextNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/ContextNULL.cpp deleted file mode 100644 index 95d4c046a..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/ContextNULL.cpp +++ /dev/null @@ -1,175 +0,0 @@ -// -// Copyright 2016 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. -// -// ContextNULL.cpp: -// Implements the class methods for ContextNULL. -// - -#include "libANGLE/renderer/null/ContextNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -ContextNULL::ContextNULL(const gl::ContextState &state) : ContextImpl(state) -{ -} - -ContextNULL::~ContextNULL() -{ -} - -gl::Error ContextNULL::initialize() -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error ContextNULL::flush() -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error ContextNULL::finish() -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error ContextNULL::drawArrays(GLenum mode, GLint first, GLsizei count) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error ContextNULL::drawArraysInstanced(GLenum mode, - GLint first, - GLsizei count, - GLsizei instanceCount) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error ContextNULL::drawElements(GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - const gl::IndexRange &indexRange) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error ContextNULL::drawElementsInstanced(GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - GLsizei instances, - const gl::IndexRange &indexRange) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error ContextNULL::drawRangeElements(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const GLvoid *indices, - const gl::IndexRange &indexRange) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -CompilerImpl *ContextNULL::createCompiler() -{ - UNIMPLEMENTED(); - return static_cast<CompilerImpl *>(0); -} - -ShaderImpl *ContextNULL::createShader(const gl::ShaderState &data) -{ - UNIMPLEMENTED(); - return static_cast<ShaderImpl *>(0); -} - -ProgramImpl *ContextNULL::createProgram(const gl::ProgramState &data) -{ - UNIMPLEMENTED(); - return static_cast<ProgramImpl *>(0); -} - -FramebufferImpl *ContextNULL::createFramebuffer(const gl::FramebufferState &data) -{ - UNIMPLEMENTED(); - return static_cast<FramebufferImpl *>(0); -} - -TextureImpl *ContextNULL::createTexture(const gl::TextureState &state) -{ - UNIMPLEMENTED(); - return static_cast<TextureImpl *>(0); -} - -RenderbufferImpl *ContextNULL::createRenderbuffer() -{ - UNIMPLEMENTED(); - return static_cast<RenderbufferImpl *>(0); -} - -BufferImpl *ContextNULL::createBuffer(const gl::BufferState &state) -{ - UNIMPLEMENTED(); - return static_cast<BufferImpl *>(0); -} - -VertexArrayImpl *ContextNULL::createVertexArray(const gl::VertexArrayState &data) -{ - UNIMPLEMENTED(); - return static_cast<VertexArrayImpl *>(0); -} - -QueryImpl *ContextNULL::createQuery(GLenum type) -{ - UNIMPLEMENTED(); - return static_cast<QueryImpl *>(0); -} - -FenceNVImpl *ContextNULL::createFenceNV() -{ - UNIMPLEMENTED(); - return static_cast<FenceNVImpl *>(0); -} - -FenceSyncImpl *ContextNULL::createFenceSync() -{ - UNIMPLEMENTED(); - return static_cast<FenceSyncImpl *>(0); -} - -TransformFeedbackImpl *ContextNULL::createTransformFeedback(const gl::TransformFeedbackState &state) -{ - UNIMPLEMENTED(); - return static_cast<TransformFeedbackImpl *>(0); -} - -SamplerImpl *ContextNULL::createSampler() -{ - UNIMPLEMENTED(); - return static_cast<SamplerImpl *>(0); -} - -std::vector<PathImpl *> ContextNULL::createPaths(GLsizei range) -{ - UNIMPLEMENTED(); - return std::vector<PathImpl *>(); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/ContextNULL.h b/gfx/angle/src/libANGLE/renderer/null/ContextNULL.h deleted file mode 100644 index 9a7987b67..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/ContextNULL.h +++ /dev/null @@ -1,95 +0,0 @@ -// -// Copyright 2016 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. -// -// ContextNULL.h: -// Defines the class interface for ContextNULL, implementing ContextImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_CONTEXTNULL_H_ -#define LIBANGLE_RENDERER_NULL_CONTEXTNULL_H_ - -#include "libANGLE/renderer/ContextImpl.h" - -namespace rx -{ - -class ContextNULL : public ContextImpl -{ - public: - ContextNULL(const gl::ContextState &state); - ~ContextNULL() override; - - gl::Error initialize() override; - - // Flush and finish. - gl::Error flush() override; - gl::Error finish() override; - - // Drawing methods. - gl::Error drawArrays(GLenum mode, GLint first, GLsizei count) override; - gl::Error drawArraysInstanced(GLenum mode, - GLint first, - GLsizei count, - GLsizei instanceCount) override; - - gl::Error drawElements(GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - const gl::IndexRange &indexRange) override; - gl::Error drawElementsInstanced(GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - GLsizei instances, - const gl::IndexRange &indexRange) override; - gl::Error drawRangeElements(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const GLvoid *indices, - const gl::IndexRange &indexRange) override; - - // CHROMIUM_path_rendering path drawing methods. - - // Shader creation - CompilerImpl *createCompiler() override; - ShaderImpl *createShader(const gl::ShaderState &data) override; - ProgramImpl *createProgram(const gl::ProgramState &data) override; - - // Framebuffer creation - FramebufferImpl *createFramebuffer(const gl::FramebufferState &data) override; - - // Texture creation - TextureImpl *createTexture(const gl::TextureState &state) override; - - // Renderbuffer creation - RenderbufferImpl *createRenderbuffer() override; - - // Buffer creation - BufferImpl *createBuffer(const gl::BufferState &state) override; - - // Vertex Array creation - VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override; - - // Query and Fence creation - QueryImpl *createQuery(GLenum type) override; - FenceNVImpl *createFenceNV() override; - FenceSyncImpl *createFenceSync() override; - - // Transform Feedback creation - TransformFeedbackImpl *createTransformFeedback( - const gl::TransformFeedbackState &state) override; - - // Sampler object creation - SamplerImpl *createSampler() override; - - std::vector<PathImpl *> createPaths(GLsizei range) override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_CONTEXTNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/DeviceNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/DeviceNULL.cpp deleted file mode 100644 index 4893f9466..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/DeviceNULL.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -// Copyright 2016 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. -// -// DeviceNULL.cpp: -// Implements the class methods for DeviceNULL. -// - -#include "libANGLE/renderer/null/DeviceNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -DeviceNULL::DeviceNULL() : DeviceImpl() -{ -} - -DeviceNULL::~DeviceNULL() -{ -} - -egl::Error DeviceNULL::getDevice(void **outValue) -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -EGLint DeviceNULL::getType() -{ - UNIMPLEMENTED(); - return EGLint(); -} - -void DeviceNULL::generateExtensions(egl::DeviceExtensions *outExtensions) const -{ - UNIMPLEMENTED(); -} - -bool DeviceNULL::deviceExternallySourced() -{ - UNIMPLEMENTED(); - return bool(); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/DeviceNULL.h b/gfx/angle/src/libANGLE/renderer/null/DeviceNULL.h deleted file mode 100644 index ed921039e..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/DeviceNULL.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright 2016 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. -// -// DeviceNULL.h: -// Defines the class interface for DeviceNULL, implementing DeviceImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_DEVICENULL_H_ -#define LIBANGLE_RENDERER_NULL_DEVICENULL_H_ - -#include "libANGLE/renderer/DeviceImpl.h" - -namespace rx -{ - -class DeviceNULL : public DeviceImpl -{ - public: - DeviceNULL(); - ~DeviceNULL() override; - - egl::Error getDevice(void **outValue) override; - EGLint getType() override; - void generateExtensions(egl::DeviceExtensions *outExtensions) const override; - bool deviceExternallySourced() override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_DEVICENULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/DisplayNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/DisplayNULL.cpp deleted file mode 100644 index fc04e0465..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/DisplayNULL.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// -// Copyright 2016 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. -// -// DisplayNULL.cpp: -// Implements the class methods for DisplayNULL. -// - -#include "libANGLE/renderer/null/DisplayNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -DisplayNULL::DisplayNULL() : DisplayImpl() -{ -} - -DisplayNULL::~DisplayNULL() -{ -} - -egl::Error DisplayNULL::initialize(egl::Display *display) -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -void DisplayNULL::terminate() -{ - UNIMPLEMENTED(); -} - -egl::Error DisplayNULL::makeCurrent(egl::Surface *drawSurface, - egl::Surface *readSurface, - gl::Context *context) -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -egl::ConfigSet DisplayNULL::generateConfigs() -{ - UNIMPLEMENTED(); - return egl::ConfigSet(); -} - -bool DisplayNULL::testDeviceLost() -{ - UNIMPLEMENTED(); - return bool(); -} - -egl::Error DisplayNULL::restoreLostDevice() -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -bool DisplayNULL::isValidNativeWindow(EGLNativeWindowType window) const -{ - UNIMPLEMENTED(); - return bool(); -} - -std::string DisplayNULL::getVendorString() const -{ - UNIMPLEMENTED(); - return std::string(); -} - -egl::Error DisplayNULL::getDevice(DeviceImpl **device) -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -egl::Error DisplayNULL::waitClient() const -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -egl::Error DisplayNULL::waitNative(EGLint engine, - egl::Surface *drawSurface, - egl::Surface *readSurface) const -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -gl::Version DisplayNULL::getMaxSupportedESVersion() const -{ - UNIMPLEMENTED(); - return gl::Version(); -} - -SurfaceImpl *DisplayNULL::createWindowSurface(const egl::SurfaceState &state, - const egl::Config *configuration, - EGLNativeWindowType window, - const egl::AttributeMap &attribs) -{ - UNIMPLEMENTED(); - return static_cast<SurfaceImpl *>(0); -} - -SurfaceImpl *DisplayNULL::createPbufferSurface(const egl::SurfaceState &state, - const egl::Config *configuration, - const egl::AttributeMap &attribs) -{ - UNIMPLEMENTED(); - return static_cast<SurfaceImpl *>(0); -} - -SurfaceImpl *DisplayNULL::createPbufferFromClientBuffer(const egl::SurfaceState &state, - const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer buffer, - const egl::AttributeMap &attribs) -{ - UNIMPLEMENTED(); - return static_cast<SurfaceImpl *>(0); -} - -SurfaceImpl *DisplayNULL::createPixmapSurface(const egl::SurfaceState &state, - const egl::Config *configuration, - NativePixmapType nativePixmap, - const egl::AttributeMap &attribs) -{ - UNIMPLEMENTED(); - return static_cast<SurfaceImpl *>(0); -} - -ImageImpl *DisplayNULL::createImage(EGLenum target, - egl::ImageSibling *buffer, - const egl::AttributeMap &attribs) -{ - UNIMPLEMENTED(); - return static_cast<ImageImpl *>(0); -} - -ContextImpl *DisplayNULL::createContext(const gl::ContextState &state) -{ - UNIMPLEMENTED(); - return static_cast<ContextImpl *>(0); -} - -StreamProducerImpl *DisplayNULL::createStreamProducerD3DTextureNV12( - egl::Stream::ConsumerType consumerType, - const egl::AttributeMap &attribs) -{ - UNIMPLEMENTED(); - return static_cast<StreamProducerImpl *>(0); -} - -void DisplayNULL::generateExtensions(egl::DisplayExtensions *outExtensions) const -{ - UNIMPLEMENTED(); -} - -void DisplayNULL::generateCaps(egl::Caps *outCaps) const -{ - UNIMPLEMENTED(); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/DisplayNULL.h b/gfx/angle/src/libANGLE/renderer/null/DisplayNULL.h deleted file mode 100644 index 5a453810a..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/DisplayNULL.h +++ /dev/null @@ -1,82 +0,0 @@ -// -// Copyright 2016 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. -// -// DisplayNULL.h: -// Defines the class interface for DisplayNULL, implementing DisplayImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_DISPLAYNULL_H_ -#define LIBANGLE_RENDERER_NULL_DISPLAYNULL_H_ - -#include "libANGLE/renderer/DisplayImpl.h" - -namespace rx -{ - -class DisplayNULL : public DisplayImpl -{ - public: - DisplayNULL(); - ~DisplayNULL() override; - - egl::Error initialize(egl::Display *display) override; - void terminate() override; - - egl::Error makeCurrent(egl::Surface *drawSurface, - egl::Surface *readSurface, - gl::Context *context) override; - - egl::ConfigSet generateConfigs() override; - - bool testDeviceLost() override; - egl::Error restoreLostDevice() override; - - bool isValidNativeWindow(EGLNativeWindowType window) const override; - - std::string getVendorString() const override; - - egl::Error getDevice(DeviceImpl **device) override; - - egl::Error waitClient() const override; - egl::Error waitNative(EGLint engine, - egl::Surface *drawSurface, - egl::Surface *readSurface) const override; - gl::Version getMaxSupportedESVersion() const override; - - SurfaceImpl *createWindowSurface(const egl::SurfaceState &state, - const egl::Config *configuration, - EGLNativeWindowType window, - const egl::AttributeMap &attribs) override; - SurfaceImpl *createPbufferSurface(const egl::SurfaceState &state, - const egl::Config *configuration, - const egl::AttributeMap &attribs) override; - SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state, - const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer buffer, - const egl::AttributeMap &attribs) override; - SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state, - const egl::Config *configuration, - NativePixmapType nativePixmap, - const egl::AttributeMap &attribs) override; - - ImageImpl *createImage(EGLenum target, - egl::ImageSibling *buffer, - const egl::AttributeMap &attribs) override; - - ContextImpl *createContext(const gl::ContextState &state) override; - - StreamProducerImpl *createStreamProducerD3DTextureNV12( - egl::Stream::ConsumerType consumerType, - const egl::AttributeMap &attribs) override; - - private: - void generateExtensions(egl::DisplayExtensions *outExtensions) const override; - void generateCaps(egl::Caps *outCaps) const override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_DISPLAYNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/FenceNVNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/FenceNVNULL.cpp deleted file mode 100644 index 9d7f26043..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/FenceNVNULL.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -// Copyright 2016 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. -// -// FenceNVNULL.cpp: -// Implements the class methods for FenceNVNULL. -// - -#include "libANGLE/renderer/null/FenceNVNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -FenceNVNULL::FenceNVNULL() : FenceNVImpl() -{ -} - -FenceNVNULL::~FenceNVNULL() -{ -} - -gl::Error FenceNVNULL::set(GLenum condition) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FenceNVNULL::test(GLboolean *outFinished) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FenceNVNULL::finish() -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/FenceNVNULL.h b/gfx/angle/src/libANGLE/renderer/null/FenceNVNULL.h deleted file mode 100644 index 10cf5c2cb..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/FenceNVNULL.h +++ /dev/null @@ -1,31 +0,0 @@ -// -// Copyright 2016 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. -// -// FenceNVNULL.h: -// Defines the class interface for FenceNVNULL, implementing FenceNVImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_FENCENVNULL_H_ -#define LIBANGLE_RENDERER_NULL_FENCENVNULL_H_ - -#include "libANGLE/renderer/FenceNVImpl.h" - -namespace rx -{ - -class FenceNVNULL : public FenceNVImpl -{ - public: - FenceNVNULL(); - ~FenceNVNULL() override; - - gl::Error set(GLenum condition) override; - gl::Error test(GLboolean *outFinished) override; - gl::Error finish() override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_FENCENVNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/FenceSyncNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/FenceSyncNULL.cpp deleted file mode 100644 index 37bfdfedb..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/FenceSyncNULL.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -// Copyright 2016 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. -// -// FenceSyncNULL.cpp: -// Implements the class methods for FenceSyncNULL. -// - -#include "libANGLE/renderer/null/FenceSyncNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -FenceSyncNULL::FenceSyncNULL() : FenceSyncImpl() -{ -} - -FenceSyncNULL::~FenceSyncNULL() -{ -} - -gl::Error FenceSyncNULL::set(GLenum condition, GLbitfield flags) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FenceSyncNULL::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *outResult) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FenceSyncNULL::serverWait(GLbitfield flags, GLuint64 timeout) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FenceSyncNULL::getStatus(GLint *outResult) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/FenceSyncNULL.h b/gfx/angle/src/libANGLE/renderer/null/FenceSyncNULL.h deleted file mode 100644 index 28a12f703..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/FenceSyncNULL.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright 2016 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. -// -// FenceSyncNULL.h: -// Defines the class interface for FenceSyncNULL, implementing FenceSyncImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_FENCESYNCNULL_H_ -#define LIBANGLE_RENDERER_NULL_FENCESYNCNULL_H_ - -#include "libANGLE/renderer/FenceSyncImpl.h" - -namespace rx -{ - -class FenceSyncNULL : public FenceSyncImpl -{ - public: - FenceSyncNULL(); - ~FenceSyncNULL() override; - - gl::Error set(GLenum condition, GLbitfield flags) override; - gl::Error clientWait(GLbitfield flags, GLuint64 timeout, GLenum *outResult) override; - gl::Error serverWait(GLbitfield flags, GLuint64 timeout) override; - gl::Error getStatus(GLint *outResult) override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_FENCESYNCNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/FramebufferNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/FramebufferNULL.cpp deleted file mode 100644 index 14ebe1eba..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/FramebufferNULL.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// -// Copyright 2016 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. -// -// FramebufferNULL.cpp: -// Implements the class methods for FramebufferNULL. -// - -#include "libANGLE/renderer/null/FramebufferNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -FramebufferNULL::FramebufferNULL(const gl::FramebufferState &state) : FramebufferImpl(state) -{ -} - -FramebufferNULL::~FramebufferNULL() -{ -} - -gl::Error FramebufferNULL::discard(size_t count, const GLenum *attachments) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FramebufferNULL::invalidate(size_t count, const GLenum *attachments) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FramebufferNULL::invalidateSub(size_t count, - const GLenum *attachments, - const gl::Rectangle &area) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FramebufferNULL::clear(ContextImpl *context, GLbitfield mask) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FramebufferNULL::clearBufferfv(ContextImpl *context, - GLenum buffer, - GLint drawbuffer, - const GLfloat *values) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FramebufferNULL::clearBufferuiv(ContextImpl *context, - GLenum buffer, - GLint drawbuffer, - const GLuint *values) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FramebufferNULL::clearBufferiv(ContextImpl *context, - GLenum buffer, - GLint drawbuffer, - const GLint *values) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FramebufferNULL::clearBufferfi(ContextImpl *context, - GLenum buffer, - GLint drawbuffer, - GLfloat depth, - GLint stencil) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -GLenum FramebufferNULL::getImplementationColorReadFormat() const -{ - UNIMPLEMENTED(); - return GLenum(); -} - -GLenum FramebufferNULL::getImplementationColorReadType() const -{ - UNIMPLEMENTED(); - return GLenum(); -} - -gl::Error FramebufferNULL::readPixels(ContextImpl *context, - const gl::Rectangle &area, - GLenum format, - GLenum type, - GLvoid *pixels) const -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error FramebufferNULL::blit(ContextImpl *context, - const gl::Rectangle &sourceArea, - const gl::Rectangle &destArea, - GLbitfield mask, - GLenum filter) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -bool FramebufferNULL::checkStatus() const -{ - UNIMPLEMENTED(); - return bool(); -} - -void FramebufferNULL::syncState(const gl::Framebuffer::DirtyBits &dirtyBits) -{ - UNIMPLEMENTED(); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/FramebufferNULL.h b/gfx/angle/src/libANGLE/renderer/null/FramebufferNULL.h deleted file mode 100644 index c53132c18..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/FramebufferNULL.h +++ /dev/null @@ -1,70 +0,0 @@ -// -// Copyright 2016 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. -// -// FramebufferNULL.h: -// Defines the class interface for FramebufferNULL, implementing FramebufferImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_FRAMEBUFFERNULL_H_ -#define LIBANGLE_RENDERER_NULL_FRAMEBUFFERNULL_H_ - -#include "libANGLE/renderer/FramebufferImpl.h" - -namespace rx -{ - -class FramebufferNULL : public FramebufferImpl -{ - public: - FramebufferNULL(const gl::FramebufferState &state); - ~FramebufferNULL() override; - - gl::Error discard(size_t count, const GLenum *attachments) override; - gl::Error invalidate(size_t count, const GLenum *attachments) override; - gl::Error invalidateSub(size_t count, - const GLenum *attachments, - const gl::Rectangle &area) override; - - gl::Error clear(ContextImpl *context, GLbitfield mask) override; - gl::Error clearBufferfv(ContextImpl *context, - GLenum buffer, - GLint drawbuffer, - const GLfloat *values) override; - gl::Error clearBufferuiv(ContextImpl *context, - GLenum buffer, - GLint drawbuffer, - const GLuint *values) override; - gl::Error clearBufferiv(ContextImpl *context, - GLenum buffer, - GLint drawbuffer, - const GLint *values) override; - gl::Error clearBufferfi(ContextImpl *context, - GLenum buffer, - GLint drawbuffer, - GLfloat depth, - GLint stencil) override; - - GLenum getImplementationColorReadFormat() const override; - GLenum getImplementationColorReadType() const override; - gl::Error readPixels(ContextImpl *context, - const gl::Rectangle &area, - GLenum format, - GLenum type, - GLvoid *pixels) const override; - - gl::Error blit(ContextImpl *context, - const gl::Rectangle &sourceArea, - const gl::Rectangle &destArea, - GLbitfield mask, - GLenum filter) override; - - bool checkStatus() const override; - - void syncState(const gl::Framebuffer::DirtyBits &dirtyBits) override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_FRAMEBUFFERNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/ImageNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/ImageNULL.cpp deleted file mode 100644 index 23f3ca099..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/ImageNULL.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// -// Copyright 2016 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. -// -// ImageNULL.cpp: -// Implements the class methods for ImageNULL. -// - -#include "libANGLE/renderer/null/ImageNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -ImageNULL::ImageNULL() : ImageImpl() -{ -} - -ImageNULL::~ImageNULL() -{ -} - -egl::Error ImageNULL::initialize() -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -gl::Error ImageNULL::orphan(egl::ImageSibling *sibling) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/ImageNULL.h b/gfx/angle/src/libANGLE/renderer/null/ImageNULL.h deleted file mode 100644 index b88b346dd..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/ImageNULL.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright 2016 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. -// -// ImageNULL.h: -// Defines the class interface for ImageNULL, implementing ImageImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_IMAGENULL_H_ -#define LIBANGLE_RENDERER_NULL_IMAGENULL_H_ - -#include "libANGLE/renderer/ImageImpl.h" - -namespace rx -{ - -class ImageNULL : public ImageImpl -{ - public: - ImageNULL(); - ~ImageNULL() override; - egl::Error initialize() override; - - gl::Error orphan(egl::ImageSibling *sibling) override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_IMAGENULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/PathNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/PathNULL.cpp deleted file mode 100644 index bb52ea2c2..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/PathNULL.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// -// Copyright 2016 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. -// -// PathNULL.cpp: -// Implements the class methods for PathNULL. -// - -#include "libANGLE/renderer/null/PathNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -PathNULL::PathNULL() : PathImpl() -{ -} - -PathNULL::~PathNULL() -{ -} - -gl::Error PathNULL::setCommands(GLsizei numCommands, - const GLubyte *commands, - GLsizei numCoords, - GLenum coordType, - const void *coords) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -void PathNULL::setPathParameter(GLenum pname, GLfloat value) -{ - UNIMPLEMENTED(); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/PathNULL.h b/gfx/angle/src/libANGLE/renderer/null/PathNULL.h deleted file mode 100644 index 4c80c1c91..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/PathNULL.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright 2016 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. -// -// PathNULL.h: -// Defines the class interface for PathNULL, implementing PathImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_PATHNULL_H_ -#define LIBANGLE_RENDERER_NULL_PATHNULL_H_ - -#include "libANGLE/renderer/PathImpl.h" - -namespace rx -{ - -class PathNULL : public PathImpl -{ - public: - PathNULL(); - ~PathNULL() override; - - gl::Error setCommands(GLsizei numCommands, - const GLubyte *commands, - GLsizei numCoords, - GLenum coordType, - const void *coords) override; - - void setPathParameter(GLenum pname, GLfloat value) override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_PATHNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/ProgramNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/ProgramNULL.cpp deleted file mode 100644 index fb44b6ee4..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/ProgramNULL.cpp +++ /dev/null @@ -1,212 +0,0 @@ -// -// Copyright 2016 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. -// -// ProgramNULL.cpp: -// Implements the class methods for ProgramNULL. -// - -#include "libANGLE/renderer/null/ProgramNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -ProgramNULL::ProgramNULL(const gl::ProgramState &state) : ProgramImpl(state) -{ -} - -ProgramNULL::~ProgramNULL() -{ -} - -LinkResult ProgramNULL::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error ProgramNULL::save(gl::BinaryOutputStream *stream) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -void ProgramNULL::setBinaryRetrievableHint(bool retrievable) -{ - UNIMPLEMENTED(); -} - -LinkResult ProgramNULL::link(const gl::ContextState &data, gl::InfoLog &infoLog) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -GLboolean ProgramNULL::validate(const gl::Caps &caps, gl::InfoLog *infoLog) -{ - UNIMPLEMENTED(); - return GLboolean(); -} - -void ProgramNULL::setUniform1fv(GLint location, GLsizei count, const GLfloat *v) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniform2fv(GLint location, GLsizei count, const GLfloat *v) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniform3fv(GLint location, GLsizei count, const GLfloat *v) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniform4fv(GLint location, GLsizei count, const GLfloat *v) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniform1iv(GLint location, GLsizei count, const GLint *v) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniform2iv(GLint location, GLsizei count, const GLint *v) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniform3iv(GLint location, GLsizei count, const GLint *v) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniform4iv(GLint location, GLsizei count, const GLint *v) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniform1uiv(GLint location, GLsizei count, const GLuint *v) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniform2uiv(GLint location, GLsizei count, const GLuint *v) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniform3uiv(GLint location, GLsizei count, const GLuint *v) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniform4uiv(GLint location, GLsizei count, const GLuint *v) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniformMatrix2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniformMatrix3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniformMatrix4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniformMatrix2x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniformMatrix3x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniformMatrix2x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniformMatrix4x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniformMatrix3x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniformMatrix4x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) -{ - UNIMPLEMENTED(); -} - -void ProgramNULL::setUniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) -{ - UNIMPLEMENTED(); -} - -bool ProgramNULL::getUniformBlockSize(const std::string &blockName, size_t *sizeOut) const -{ - UNIMPLEMENTED(); - return bool(); -} - -bool ProgramNULL::getUniformBlockMemberInfo(const std::string &memberUniformName, - sh::BlockMemberInfo *memberInfoOut) const -{ - UNIMPLEMENTED(); - return bool(); -} - -void ProgramNULL::setPathFragmentInputGen(const std::string &inputName, - GLenum genMode, - GLint components, - const GLfloat *coeffs) -{ - UNIMPLEMENTED(); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/ProgramNULL.h b/gfx/angle/src/libANGLE/renderer/null/ProgramNULL.h deleted file mode 100644 index 576a52c18..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/ProgramNULL.h +++ /dev/null @@ -1,101 +0,0 @@ -// -// Copyright 2016 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. -// -// ProgramNULL.h: -// Defines the class interface for ProgramNULL, implementing ProgramImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_PROGRAMNULL_H_ -#define LIBANGLE_RENDERER_NULL_PROGRAMNULL_H_ - -#include "libANGLE/renderer/ProgramImpl.h" - -namespace rx -{ - -class ProgramNULL : public ProgramImpl -{ - public: - ProgramNULL(const gl::ProgramState &state); - ~ProgramNULL() override; - - LinkResult load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) override; - gl::Error save(gl::BinaryOutputStream *stream) override; - void setBinaryRetrievableHint(bool retrievable) override; - - LinkResult link(const gl::ContextState &data, gl::InfoLog &infoLog) override; - GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) override; - - void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) override; - void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) override; - void setUniform3fv(GLint location, GLsizei count, const GLfloat *v) override; - void setUniform4fv(GLint location, GLsizei count, const GLfloat *v) override; - void setUniform1iv(GLint location, GLsizei count, const GLint *v) override; - void setUniform2iv(GLint location, GLsizei count, const GLint *v) override; - void setUniform3iv(GLint location, GLsizei count, const GLint *v) override; - void setUniform4iv(GLint location, GLsizei count, const GLint *v) override; - void setUniform1uiv(GLint location, GLsizei count, const GLuint *v) override; - void setUniform2uiv(GLint location, GLsizei count, const GLuint *v) override; - void setUniform3uiv(GLint location, GLsizei count, const GLuint *v) override; - void setUniform4uiv(GLint location, GLsizei count, const GLuint *v) override; - void setUniformMatrix2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) override; - void setUniformMatrix3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) override; - void setUniformMatrix4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) override; - void setUniformMatrix2x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) override; - void setUniformMatrix3x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) override; - void setUniformMatrix2x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) override; - void setUniformMatrix4x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) override; - void setUniformMatrix3x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) override; - void setUniformMatrix4x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value) override; - - // TODO: synchronize in syncState when dirty bits exist. - void setUniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) override; - - // May only be called after a successful link operation. - // Return false for inactive blocks. - bool getUniformBlockSize(const std::string &blockName, size_t *sizeOut) const override; - - // May only be called after a successful link operation. - // Returns false for inactive members. - bool getUniformBlockMemberInfo(const std::string &memberUniformName, - sh::BlockMemberInfo *memberInfoOut) const override; - // CHROMIUM_path_rendering - // Set parameters to control fragment shader input variable interpolation - void setPathFragmentInputGen(const std::string &inputName, - GLenum genMode, - GLint components, - const GLfloat *coeffs) override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_PROGRAMNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/QueryNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/QueryNULL.cpp deleted file mode 100644 index 6276a0ff1..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/QueryNULL.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -// Copyright 2016 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. -// -// QueryNULL.cpp: -// Implements the class methods for QueryNULL. -// - -#include "libANGLE/renderer/null/QueryNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -QueryNULL::QueryNULL(GLenum type) : QueryImpl(type) -{ -} - -QueryNULL::~QueryNULL() -{ -} - -gl::Error QueryNULL::begin() -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error QueryNULL::end() -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error QueryNULL::queryCounter() -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error QueryNULL::getResult(GLint *params) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error QueryNULL::getResult(GLuint *params) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error QueryNULL::getResult(GLint64 *params) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error QueryNULL::getResult(GLuint64 *params) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error QueryNULL::isResultAvailable(bool *available) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/QueryNULL.h b/gfx/angle/src/libANGLE/renderer/null/QueryNULL.h deleted file mode 100644 index 40082a9b8..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/QueryNULL.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// Copyright 2016 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. -// -// QueryNULL.h: -// Defines the class interface for QueryNULL, implementing QueryImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_QUERYNULL_H_ -#define LIBANGLE_RENDERER_NULL_QUERYNULL_H_ - -#include "libANGLE/renderer/QueryImpl.h" - -namespace rx -{ - -class QueryNULL : public QueryImpl -{ - public: - QueryNULL(GLenum type); - ~QueryNULL() override; - - gl::Error begin() override; - gl::Error end() override; - gl::Error queryCounter() override; - gl::Error getResult(GLint *params) override; - gl::Error getResult(GLuint *params) override; - gl::Error getResult(GLint64 *params) override; - gl::Error getResult(GLuint64 *params) override; - gl::Error isResultAvailable(bool *available) override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_QUERYNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/RenderbufferNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/RenderbufferNULL.cpp deleted file mode 100644 index 50f54a620..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/RenderbufferNULL.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright 2016 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. -// -// RenderbufferNULL.cpp: -// Implements the class methods for RenderbufferNULL. -// - -#include "libANGLE/renderer/null/RenderbufferNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -RenderbufferNULL::RenderbufferNULL() : RenderbufferImpl() -{ -} - -RenderbufferNULL::~RenderbufferNULL() -{ -} - -gl::Error RenderbufferNULL::setStorage(GLenum internalformat, size_t width, size_t height) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error RenderbufferNULL::setStorageMultisample(size_t samples, - GLenum internalformat, - size_t width, - size_t height) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error RenderbufferNULL::setStorageEGLImageTarget(egl::Image *image) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/RenderbufferNULL.h b/gfx/angle/src/libANGLE/renderer/null/RenderbufferNULL.h deleted file mode 100644 index 79e529c4c..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/RenderbufferNULL.h +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright 2016 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. -// -// RenderbufferNULL.h: -// Defines the class interface for RenderbufferNULL, implementing RenderbufferImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_RENDERBUFFERNULL_H_ -#define LIBANGLE_RENDERER_NULL_RENDERBUFFERNULL_H_ - -#include "libANGLE/renderer/RenderbufferImpl.h" - -namespace rx -{ - -class RenderbufferNULL : public RenderbufferImpl -{ - public: - RenderbufferNULL(); - ~RenderbufferNULL() override; - - gl::Error setStorage(GLenum internalformat, size_t width, size_t height) override; - gl::Error setStorageMultisample(size_t samples, - GLenum internalformat, - size_t width, - size_t height) override; - gl::Error setStorageEGLImageTarget(egl::Image *image) override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_RENDERBUFFERNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/SamplerNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/SamplerNULL.cpp deleted file mode 100644 index e1e8c7c62..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/SamplerNULL.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright 2016 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. -// -// SamplerNULL.cpp: -// Implements the class methods for SamplerNULL. -// - -#include "libANGLE/renderer/null/SamplerNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -SamplerNULL::SamplerNULL() : SamplerImpl() -{ -} - -SamplerNULL::~SamplerNULL() -{ -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/SamplerNULL.h b/gfx/angle/src/libANGLE/renderer/null/SamplerNULL.h deleted file mode 100644 index 031fafa39..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/SamplerNULL.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// Copyright 2016 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. -// -// SamplerNULL.h: -// Defines the class interface for SamplerNULL, implementing SamplerImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_SAMPLERNULL_H_ -#define LIBANGLE_RENDERER_NULL_SAMPLERNULL_H_ - -#include "libANGLE/renderer/SamplerImpl.h" - -namespace rx -{ - -class SamplerNULL : public SamplerImpl -{ - public: - SamplerNULL(); - ~SamplerNULL() override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_SAMPLERNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/ShaderNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/ShaderNULL.cpp deleted file mode 100644 index 168f4bdca..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/ShaderNULL.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// -// Copyright 2016 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. -// -// ShaderNULL.cpp: -// Implements the class methods for ShaderNULL. -// - -#include "libANGLE/renderer/null/ShaderNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -ShaderNULL::ShaderNULL(const gl::ShaderState &data) : ShaderImpl(data) -{ -} - -ShaderNULL::~ShaderNULL() -{ -} - -ShCompileOptions ShaderNULL::prepareSourceAndReturnOptions(std::stringstream *sourceStream, - std::string *sourcePath) -{ - UNIMPLEMENTED(); - return ShCompileOptions(); -} - -bool ShaderNULL::postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) -{ - UNIMPLEMENTED(); - return bool(); -} - -std::string ShaderNULL::getDebugInfo() const -{ - UNIMPLEMENTED(); - return std::string(); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/ShaderNULL.h b/gfx/angle/src/libANGLE/renderer/null/ShaderNULL.h deleted file mode 100644 index d29b4cfb7..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/ShaderNULL.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright 2016 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. -// -// ShaderNULL.h: -// Defines the class interface for ShaderNULL, implementing ShaderImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_SHADERNULL_H_ -#define LIBANGLE_RENDERER_NULL_SHADERNULL_H_ - -#include "libANGLE/renderer/ShaderImpl.h" - -namespace rx -{ - -class ShaderNULL : public ShaderImpl -{ - public: - ShaderNULL(const gl::ShaderState &data); - ~ShaderNULL() override; - - // Returns additional sh::Compile options. - ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream, - std::string *sourcePath) override; - // Returns success for compiling on the driver. Returns success. - bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override; - - std::string getDebugInfo() const override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_SHADERNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/SurfaceNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/SurfaceNULL.cpp deleted file mode 100644 index 81d763783..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/SurfaceNULL.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// -// Copyright 2016 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. -// -// SurfaceNULL.cpp: -// Implements the class methods for SurfaceNULL. -// - -#include "libANGLE/renderer/null/SurfaceNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -SurfaceNULL::SurfaceNULL(const egl::SurfaceState &surfaceState) : SurfaceImpl(surfaceState) -{ -} - -SurfaceNULL::~SurfaceNULL() -{ -} - -egl::Error SurfaceNULL::initialize() -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -FramebufferImpl *SurfaceNULL::createDefaultFramebuffer(const gl::FramebufferState &state) -{ - UNIMPLEMENTED(); - return static_cast<FramebufferImpl *>(0); -} - -egl::Error SurfaceNULL::swap() -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -egl::Error SurfaceNULL::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -egl::Error SurfaceNULL::querySurfacePointerANGLE(EGLint attribute, void **value) -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -egl::Error SurfaceNULL::bindTexImage(gl::Texture *texture, EGLint buffer) -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -egl::Error SurfaceNULL::releaseTexImage(EGLint buffer) -{ - UNIMPLEMENTED(); - return egl::Error(EGL_BAD_ACCESS); -} - -void SurfaceNULL::setSwapInterval(EGLint interval) -{ - UNIMPLEMENTED(); -} - -EGLint SurfaceNULL::getWidth() const -{ - UNIMPLEMENTED(); - return EGLint(); -} - -EGLint SurfaceNULL::getHeight() const -{ - UNIMPLEMENTED(); - return EGLint(); -} - -EGLint SurfaceNULL::isPostSubBufferSupported() const -{ - UNIMPLEMENTED(); - return EGLint(); -} - -EGLint SurfaceNULL::getSwapBehavior() const -{ - UNIMPLEMENTED(); - return EGLint(); -} - -gl::Error SurfaceNULL::getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target, - FramebufferAttachmentRenderTarget **rtOut) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/SurfaceNULL.h b/gfx/angle/src/libANGLE/renderer/null/SurfaceNULL.h deleted file mode 100644 index 597f1c21c..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/SurfaceNULL.h +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright 2016 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. -// -// SurfaceNULL.h: -// Defines the class interface for SurfaceNULL, implementing SurfaceImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_SURFACENULL_H_ -#define LIBANGLE_RENDERER_NULL_SURFACENULL_H_ - -#include "libANGLE/renderer/SurfaceImpl.h" - -namespace rx -{ - -class SurfaceNULL : public SurfaceImpl -{ - public: - SurfaceNULL(const egl::SurfaceState &surfaceState); - ~SurfaceNULL() override; - - egl::Error initialize() override; - FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &state) override; - egl::Error swap() override; - egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) override; - egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override; - egl::Error bindTexImage(gl::Texture *texture, EGLint buffer) override; - egl::Error releaseTexImage(EGLint buffer) override; - void setSwapInterval(EGLint interval) override; - - // width and height can change with client window resizing - EGLint getWidth() const override; - EGLint getHeight() const override; - - EGLint isPostSubBufferSupported() const override; - EGLint getSwapBehavior() const override; - - gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target, - FramebufferAttachmentRenderTarget **rtOut) override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_SURFACENULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/TextureNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/TextureNULL.cpp deleted file mode 100644 index 2c952e528..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/TextureNULL.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// -// Copyright 2016 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. -// -// TextureNULL.cpp: -// Implements the class methods for TextureNULL. -// - -#include "libANGLE/renderer/null/TextureNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -TextureNULL::TextureNULL(const gl::TextureState &state) : TextureImpl(state) -{ -} - -TextureNULL::~TextureNULL() -{ -} - -gl::Error TextureNULL::setImage(GLenum target, - size_t level, - GLenum internalFormat, - const gl::Extents &size, - GLenum format, - GLenum type, - const gl::PixelUnpackState &unpack, - const uint8_t *pixels) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error TextureNULL::setSubImage(GLenum target, - size_t level, - const gl::Box &area, - GLenum format, - GLenum type, - const gl::PixelUnpackState &unpack, - const uint8_t *pixels) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error TextureNULL::setCompressedImage(GLenum target, - size_t level, - GLenum internalFormat, - const gl::Extents &size, - const gl::PixelUnpackState &unpack, - size_t imageSize, - const uint8_t *pixels) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error TextureNULL::setCompressedSubImage(GLenum target, - size_t level, - const gl::Box &area, - GLenum format, - const gl::PixelUnpackState &unpack, - size_t imageSize, - const uint8_t *pixels) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error TextureNULL::copyImage(GLenum target, - size_t level, - const gl::Rectangle &sourceArea, - GLenum internalFormat, - const gl::Framebuffer *source) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error TextureNULL::copySubImage(GLenum target, - size_t level, - const gl::Offset &destOffset, - const gl::Rectangle &sourceArea, - const gl::Framebuffer *source) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error TextureNULL::setStorage(GLenum target, - size_t levels, - GLenum internalFormat, - const gl::Extents &size) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error TextureNULL::setEGLImageTarget(GLenum target, egl::Image *image) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error TextureNULL::setImageExternal(GLenum target, - egl::Stream *stream, - const egl::Stream::GLTextureDescription &desc) -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -gl::Error TextureNULL::generateMipmap() -{ - UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); -} - -void TextureNULL::setBaseLevel(GLuint baseLevel) -{ - UNIMPLEMENTED(); -} - -void TextureNULL::bindTexImage(egl::Surface *surface) -{ - UNIMPLEMENTED(); -} - -void TextureNULL::releaseTexImage() -{ - UNIMPLEMENTED(); -} - -void TextureNULL::syncState(const gl::Texture::DirtyBits &dirtyBits) -{ - UNIMPLEMENTED(); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/TextureNULL.h b/gfx/angle/src/libANGLE/renderer/null/TextureNULL.h deleted file mode 100644 index 10c2d3503..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/TextureNULL.h +++ /dev/null @@ -1,89 +0,0 @@ -// -// Copyright 2016 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. -// -// TextureNULL.h: -// Defines the class interface for TextureNULL, implementing TextureImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_TEXTURENULL_H_ -#define LIBANGLE_RENDERER_NULL_TEXTURENULL_H_ - -#include "libANGLE/renderer/TextureImpl.h" - -namespace rx -{ - -class TextureNULL : public TextureImpl -{ - public: - TextureNULL(const gl::TextureState &state); - ~TextureNULL() override; - - gl::Error setImage(GLenum target, - size_t level, - GLenum internalFormat, - const gl::Extents &size, - GLenum format, - GLenum type, - const gl::PixelUnpackState &unpack, - const uint8_t *pixels) override; - gl::Error setSubImage(GLenum target, - size_t level, - const gl::Box &area, - GLenum format, - GLenum type, - const gl::PixelUnpackState &unpack, - const uint8_t *pixels) override; - - gl::Error setCompressedImage(GLenum target, - size_t level, - GLenum internalFormat, - const gl::Extents &size, - const gl::PixelUnpackState &unpack, - size_t imageSize, - const uint8_t *pixels) override; - gl::Error setCompressedSubImage(GLenum target, - size_t level, - const gl::Box &area, - GLenum format, - const gl::PixelUnpackState &unpack, - size_t imageSize, - const uint8_t *pixels) override; - - gl::Error copyImage(GLenum target, - size_t level, - const gl::Rectangle &sourceArea, - GLenum internalFormat, - const gl::Framebuffer *source) override; - gl::Error copySubImage(GLenum target, - size_t level, - const gl::Offset &destOffset, - const gl::Rectangle &sourceArea, - const gl::Framebuffer *source) override; - - gl::Error setStorage(GLenum target, - size_t levels, - GLenum internalFormat, - const gl::Extents &size) override; - - gl::Error setEGLImageTarget(GLenum target, egl::Image *image) override; - - gl::Error setImageExternal(GLenum target, - egl::Stream *stream, - const egl::Stream::GLTextureDescription &desc) override; - - gl::Error generateMipmap() override; - - void setBaseLevel(GLuint baseLevel) override; - - void bindTexImage(egl::Surface *surface) override; - void releaseTexImage() override; - - void syncState(const gl::Texture::DirtyBits &dirtyBits) override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_TEXTURENULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/TransformFeedbackNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/TransformFeedbackNULL.cpp deleted file mode 100644 index e1433fb2d..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/TransformFeedbackNULL.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// -// Copyright 2016 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. -// -// TransformFeedbackNULL.cpp: -// Implements the class methods for TransformFeedbackNULL. -// - -#include "libANGLE/renderer/null/TransformFeedbackNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -TransformFeedbackNULL::TransformFeedbackNULL(const gl::TransformFeedbackState &state) - : TransformFeedbackImpl(state) -{ -} - -TransformFeedbackNULL::~TransformFeedbackNULL() -{ -} - -void TransformFeedbackNULL::begin(GLenum primitiveMode) -{ - UNIMPLEMENTED(); -} - -void TransformFeedbackNULL::end() -{ - UNIMPLEMENTED(); -} - -void TransformFeedbackNULL::pause() -{ - UNIMPLEMENTED(); -} - -void TransformFeedbackNULL::resume() -{ - UNIMPLEMENTED(); -} - -void TransformFeedbackNULL::bindGenericBuffer(const BindingPointer<gl::Buffer> &binding) -{ - UNIMPLEMENTED(); -} - -void TransformFeedbackNULL::bindIndexedBuffer(size_t index, - const OffsetBindingPointer<gl::Buffer> &binding) -{ - UNIMPLEMENTED(); -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/TransformFeedbackNULL.h b/gfx/angle/src/libANGLE/renderer/null/TransformFeedbackNULL.h deleted file mode 100644 index 477e81d85..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/TransformFeedbackNULL.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright 2016 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. -// -// TransformFeedbackNULL.h: -// Defines the class interface for TransformFeedbackNULL, implementing TransformFeedbackImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_TRANSFORMFEEDBACKNULL_H_ -#define LIBANGLE_RENDERER_NULL_TRANSFORMFEEDBACKNULL_H_ - -#include "libANGLE/renderer/TransformFeedbackImpl.h" - -namespace rx -{ - -class TransformFeedbackNULL : public TransformFeedbackImpl -{ - public: - TransformFeedbackNULL(const gl::TransformFeedbackState &state); - ~TransformFeedbackNULL() override; - - void begin(GLenum primitiveMode) override; - void end() override; - void pause() override; - void resume() override; - - void bindGenericBuffer(const BindingPointer<gl::Buffer> &binding) override; - void bindIndexedBuffer(size_t index, const OffsetBindingPointer<gl::Buffer> &binding) override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_TRANSFORMFEEDBACKNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/null/VertexArrayNULL.cpp b/gfx/angle/src/libANGLE/renderer/null/VertexArrayNULL.cpp deleted file mode 100644 index 95a835df1..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/VertexArrayNULL.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright 2016 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. -// -// VertexArrayNULL.cpp: -// Implements the class methods for VertexArrayNULL. -// - -#include "libANGLE/renderer/null/VertexArrayNULL.h" - -#include "common/debug.h" - -namespace rx -{ - -VertexArrayNULL::VertexArrayNULL(const gl::VertexArrayState &data) : VertexArrayImpl(data) -{ -} - -VertexArrayNULL::~VertexArrayNULL() -{ -} - -} // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/null/VertexArrayNULL.h b/gfx/angle/src/libANGLE/renderer/null/VertexArrayNULL.h deleted file mode 100644 index f8b2b0490..000000000 --- a/gfx/angle/src/libANGLE/renderer/null/VertexArrayNULL.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// Copyright 2016 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. -// -// VertexArrayNULL.h: -// Defines the class interface for VertexArrayNULL, implementing VertexArrayImpl. -// - -#ifndef LIBANGLE_RENDERER_NULL_VERTEXARRAYNULL_H_ -#define LIBANGLE_RENDERER_NULL_VERTEXARRAYNULL_H_ - -#include "libANGLE/renderer/VertexArrayImpl.h" - -namespace rx -{ - -class VertexArrayNULL : public VertexArrayImpl -{ - public: - VertexArrayNULL(const gl::VertexArrayState &data); - ~VertexArrayNULL() override; -}; - -} // namespace rx - -#endif // LIBANGLE_RENDERER_NULL_VERTEXARRAYNULL_H_ diff --git a/gfx/angle/src/libANGLE/renderer/renderer_utils.cpp b/gfx/angle/src/libANGLE/renderer/renderer_utils.cpp index cc04dbb14..b93a1ff93 100755 --- a/gfx/angle/src/libANGLE/renderer/renderer_utils.cpp +++ b/gfx/angle/src/libANGLE/renderer/renderer_utils.cpp @@ -268,25 +268,8 @@ ColorWriteFunction GetColorWriteFunction(const gl::FormatType &formatType) ColorCopyFunction GetFastCopyFunction(const FastCopyFunctionMap &fastCopyFunctions, const gl::FormatType &formatType) { - return fastCopyFunctions.get(formatType); -} - -bool FastCopyFunctionMap::has(const gl::FormatType &formatType) const -{ - return (get(formatType) != nullptr); -} - -ColorCopyFunction FastCopyFunctionMap::get(const gl::FormatType &formatType) const -{ - for (size_t index = 0; index < mSize; ++index) - { - if (mData[index].format == formatType.format && mData[index].type == formatType.type) - { - return mData[index].func; - } - } - - return nullptr; + auto iter = fastCopyFunctions.find(formatType); + return (iter != fastCopyFunctions.end()) ? iter->second : nullptr; } } // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/renderer_utils.h b/gfx/angle/src/libANGLE/renderer/renderer_utils.h index 440548e9c..e08703000 100755 --- a/gfx/angle/src/libANGLE/renderer/renderer_utils.h +++ b/gfx/angle/src/libANGLE/renderer/renderer_utils.h @@ -44,27 +44,7 @@ typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest); typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest); typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest); -class FastCopyFunctionMap -{ - public: - struct Entry - { - GLenum format; - GLenum type; - ColorCopyFunction func; - }; - - constexpr FastCopyFunctionMap() : FastCopyFunctionMap(nullptr, 0) {} - - constexpr FastCopyFunctionMap(const Entry *data, size_t size) : mSize(size), mData(data) {} - - bool has(const gl::FormatType &formatType) const; - ColorCopyFunction get(const gl::FormatType &formatType) const; - - private: - size_t mSize; - const Entry *mData; -}; +typedef std::map<gl::FormatType, ColorCopyFunction> FastCopyFunctionMap; struct PackPixelsParams { diff --git a/gfx/angle/src/libANGLE/renderer/vulkan/BufferVk.cpp b/gfx/angle/src/libANGLE/renderer/vulkan/BufferVk.cpp index 0b1babd5a..b0e01e86c 100755 --- a/gfx/angle/src/libANGLE/renderer/vulkan/BufferVk.cpp +++ b/gfx/angle/src/libANGLE/renderer/vulkan/BufferVk.cpp @@ -14,7 +14,7 @@ namespace rx { -BufferVk::BufferVk(const gl::BufferState &state) : BufferImpl(state) +BufferVk::BufferVk() : BufferImpl() { } @@ -22,13 +22,13 @@ BufferVk::~BufferVk() { } -gl::Error BufferVk::setData(GLenum target, const void *data, size_t size, GLenum usage) +gl::Error BufferVk::setData(const void *data, size_t size, GLenum usage) { UNIMPLEMENTED(); return gl::Error(GL_INVALID_OPERATION); } -gl::Error BufferVk::setSubData(GLenum target, const void *data, size_t size, size_t offset) +gl::Error BufferVk::setSubData(const void *data, size_t size, size_t offset) { UNIMPLEMENTED(); return gl::Error(GL_INVALID_OPERATION); diff --git a/gfx/angle/src/libANGLE/renderer/vulkan/BufferVk.h b/gfx/angle/src/libANGLE/renderer/vulkan/BufferVk.h index 27792962f..19bd61ea3 100755 --- a/gfx/angle/src/libANGLE/renderer/vulkan/BufferVk.h +++ b/gfx/angle/src/libANGLE/renderer/vulkan/BufferVk.h @@ -18,11 +18,11 @@ namespace rx class BufferVk : public BufferImpl { public: - BufferVk(const gl::BufferState &state); + BufferVk(); ~BufferVk() override; - gl::Error setData(GLenum target, const void *data, size_t size, GLenum usage) override; - gl::Error setSubData(GLenum target, const void *data, size_t size, size_t offset) override; + gl::Error setData(const void *data, size_t size, GLenum usage) override; + gl::Error setSubData(const void *data, size_t size, size_t offset) override; gl::Error copySubData(BufferImpl *source, GLintptr sourceOffset, GLintptr destOffset, diff --git a/gfx/angle/src/libANGLE/renderer/vulkan/ContextVk.cpp b/gfx/angle/src/libANGLE/renderer/vulkan/ContextVk.cpp index d0660bfdc..8bd063300 100755 --- a/gfx/angle/src/libANGLE/renderer/vulkan/ContextVk.cpp +++ b/gfx/angle/src/libANGLE/renderer/vulkan/ContextVk.cpp @@ -211,9 +211,9 @@ RenderbufferImpl *ContextVk::createRenderbuffer() return new RenderbufferVk(); } -BufferImpl *ContextVk::createBuffer(const gl::BufferState &state) +BufferImpl *ContextVk::createBuffer() { - return new BufferVk(state); + return new BufferVk(); } VertexArrayImpl *ContextVk::createVertexArray(const gl::VertexArrayState &state) diff --git a/gfx/angle/src/libANGLE/renderer/vulkan/ContextVk.h b/gfx/angle/src/libANGLE/renderer/vulkan/ContextVk.h index 64e85c984..61b4f5b30 100755 --- a/gfx/angle/src/libANGLE/renderer/vulkan/ContextVk.h +++ b/gfx/angle/src/libANGLE/renderer/vulkan/ContextVk.h @@ -97,7 +97,7 @@ class ContextVk : public ContextImpl RenderbufferImpl *createRenderbuffer() override; // Buffer creation - BufferImpl *createBuffer(const gl::BufferState &state) override; + BufferImpl *createBuffer() override; // Vertex Array creation VertexArrayImpl *createVertexArray(const gl::VertexArrayState &state) override; diff --git a/gfx/angle/src/libANGLE/renderer/vulkan/DisplayVk.cpp b/gfx/angle/src/libANGLE/renderer/vulkan/DisplayVk.cpp index 2c652ce3c..95e8ea653 100755 --- a/gfx/angle/src/libANGLE/renderer/vulkan/DisplayVk.cpp +++ b/gfx/angle/src/libANGLE/renderer/vulkan/DisplayVk.cpp @@ -111,8 +111,7 @@ SurfaceImpl *DisplayVk::createPbufferSurface(const egl::SurfaceState &state, SurfaceImpl *DisplayVk::createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) { UNIMPLEMENTED(); diff --git a/gfx/angle/src/libANGLE/renderer/vulkan/DisplayVk.h b/gfx/angle/src/libANGLE/renderer/vulkan/DisplayVk.h index 26eab5139..91838980d 100755 --- a/gfx/angle/src/libANGLE/renderer/vulkan/DisplayVk.h +++ b/gfx/angle/src/libANGLE/renderer/vulkan/DisplayVk.h @@ -54,8 +54,7 @@ class DisplayVk : public DisplayImpl const egl::AttributeMap &attribs) override; SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state, const egl::Config *configuration, - EGLenum buftype, - EGLClientBuffer clientBuffer, + EGLClientBuffer shareHandle, const egl::AttributeMap &attribs) override; SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state, const egl::Config *configuration, diff --git a/gfx/angle/src/libANGLE/renderer/vulkan/ProgramVk.cpp b/gfx/angle/src/libANGLE/renderer/vulkan/ProgramVk.cpp index a83f826e7..591cf062c 100755 --- a/gfx/angle/src/libANGLE/renderer/vulkan/ProgramVk.cpp +++ b/gfx/angle/src/libANGLE/renderer/vulkan/ProgramVk.cpp @@ -25,7 +25,7 @@ ProgramVk::~ProgramVk() LinkResult ProgramVk::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) { UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); + return LinkResult(false, gl::Error(GL_INVALID_OPERATION)); } gl::Error ProgramVk::save(gl::BinaryOutputStream *stream) @@ -42,7 +42,7 @@ void ProgramVk::setBinaryRetrievableHint(bool retrievable) LinkResult ProgramVk::link(const gl::ContextState &data, gl::InfoLog &infoLog) { UNIMPLEMENTED(); - return gl::Error(GL_INVALID_OPERATION); + return LinkResult(false, gl::Error(GL_INVALID_OPERATION)); } GLboolean ProgramVk::validate(const gl::Caps &caps, gl::InfoLog *infoLog) diff --git a/gfx/angle/src/libANGLE/renderer/vulkan/ShaderVk.cpp b/gfx/angle/src/libANGLE/renderer/vulkan/ShaderVk.cpp index 8bece9b45..06355c3c8 100755 --- a/gfx/angle/src/libANGLE/renderer/vulkan/ShaderVk.cpp +++ b/gfx/angle/src/libANGLE/renderer/vulkan/ShaderVk.cpp @@ -22,8 +22,8 @@ ShaderVk::~ShaderVk() { } -ShCompileOptions ShaderVk::prepareSourceAndReturnOptions(std::stringstream *sourceStream, - std::string *sourcePath) +int ShaderVk::prepareSourceAndReturnOptions(std::stringstream *sourceStream, + std::string *sourcePath) { UNIMPLEMENTED(); return int(); diff --git a/gfx/angle/src/libANGLE/renderer/vulkan/ShaderVk.h b/gfx/angle/src/libANGLE/renderer/vulkan/ShaderVk.h index 10f8fe423..f847070c4 100755 --- a/gfx/angle/src/libANGLE/renderer/vulkan/ShaderVk.h +++ b/gfx/angle/src/libANGLE/renderer/vulkan/ShaderVk.h @@ -21,9 +21,9 @@ class ShaderVk : public ShaderImpl ShaderVk(const gl::ShaderState &data); ~ShaderVk() override; - // Returns additional sh::Compile options. - ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream, - std::string *sourcePath) override; + // Returns additional ShCompile options. + int prepareSourceAndReturnOptions(std::stringstream *sourceStream, + std::string *sourcePath) override; // Returns success for compiling on the driver. Returns success. bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override; diff --git a/gfx/angle/src/libANGLE/renderer/vulkan/TextureVk.cpp b/gfx/angle/src/libANGLE/renderer/vulkan/TextureVk.cpp index a2220fcad..440f98754 100755 --- a/gfx/angle/src/libANGLE/renderer/vulkan/TextureVk.cpp +++ b/gfx/angle/src/libANGLE/renderer/vulkan/TextureVk.cpp @@ -142,9 +142,4 @@ gl::Error TextureVk::getAttachmentRenderTarget(const gl::FramebufferAttachment:: return gl::Error(GL_INVALID_OPERATION); } -void TextureVk::syncState(const gl::Texture::DirtyBits &dirtyBits) -{ - UNIMPLEMENTED(); -} - } // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/vulkan/TextureVk.h b/gfx/angle/src/libANGLE/renderer/vulkan/TextureVk.h index d5b9106c7..de45b93b7 100755 --- a/gfx/angle/src/libANGLE/renderer/vulkan/TextureVk.h +++ b/gfx/angle/src/libANGLE/renderer/vulkan/TextureVk.h @@ -83,8 +83,6 @@ class TextureVk : public TextureImpl gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target, FramebufferAttachmentRenderTarget **rtOut) override; - - void syncState(const gl::Texture::DirtyBits &dirtyBits) override; }; } // namespace rx diff --git a/gfx/angle/src/libANGLE/validationEGL.cpp b/gfx/angle/src/libANGLE/validationEGL.cpp index 7ee92e83e..6b6893b37 100755 --- a/gfx/angle/src/libANGLE/validationEGL.cpp +++ b/gfx/angle/src/libANGLE/validationEGL.cpp @@ -182,7 +182,7 @@ Error ValidateDisplay(const Display *display) return Error(EGL_SUCCESS); } -Error ValidateSurface(const Display *display, const Surface *surface) +Error ValidateSurface(const Display *display, Surface *surface) { ANGLE_TRY(ValidateDisplay(display)); @@ -206,7 +206,7 @@ Error ValidateConfig(const Display *display, const Config *config) return Error(EGL_SUCCESS); } -Error ValidateContext(const Display *display, const gl::Context *context) +Error ValidateContext(const Display *display, gl::Context *context) { ANGLE_TRY(ValidateDisplay(display)); @@ -258,6 +258,7 @@ Error ValidateCreateContext(Display *display, Config *configuration, gl::Context EGLAttrib clientMinorVersion = 0; EGLAttrib contextFlags = 0; bool resetNotification = false; + bool robustAccess = false; for (AttributeMap::const_iterator attributeIter = attributes.begin(); attributeIter != attributes.end(); attributeIter++) { EGLAttrib attribute = attributeIter->first; @@ -293,6 +294,7 @@ Error ValidateCreateContext(Display *display, Config *configuration, gl::Context { return Error(EGL_BAD_ATTRIBUTE); } + robustAccess = (value == EGL_TRUE); break; case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR: @@ -325,36 +327,6 @@ Error ValidateCreateContext(Display *display, Config *configuration, gl::Context } break; - case EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE: - if (!display->getExtensions().createContextWebGLCompatibility) - { - return Error(EGL_BAD_ATTRIBUTE, - "Attribute EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE requires " - "EGL_ANGLE_create_context_webgl_compatibility."); - } - if (value != EGL_TRUE && value != EGL_FALSE) - { - return Error( - EGL_BAD_ATTRIBUTE, - "EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE must be EGL_TRUE or EGL_FALSE."); - } - break; - - case EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM: - if (!display->getExtensions().createContextBindGeneratesResource) - { - return Error(EGL_BAD_ATTRIBUTE, - "Attribute EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM requires " - "EGL_CHROMIUM_create_context_bind_generates_resource."); - } - if (value != EGL_TRUE && value != EGL_FALSE) - { - return Error(EGL_BAD_ATTRIBUTE, - "EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM must be EGL_TRUE or " - "EGL_FALSE."); - } - break; - default: return Error(EGL_BAD_ATTRIBUTE); } @@ -397,6 +369,17 @@ Error ValidateCreateContext(Display *display, Config *configuration, gl::Context return Error(EGL_BAD_ATTRIBUTE); } + if ((contextFlags & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) > 0) + { + robustAccess = true; + } + + if (robustAccess) + { + // Unimplemented + return Error(EGL_BAD_CONFIG); + } + if (shareContext) { // Shared context is invalid or is owned by another display @@ -640,17 +623,6 @@ Error ValidateCreatePbufferFromClientBuffer(Display *display, EGLenum buftype, E } break; - case EGL_D3D_TEXTURE_ANGLE: - if (!displayExtensions.d3dTextureClientBuffer) - { - return Error(EGL_BAD_PARAMETER); - } - if (buffer == nullptr) - { - return Error(EGL_BAD_PARAMETER); - } - break; - default: return Error(EGL_BAD_PARAMETER); } @@ -751,8 +723,6 @@ Error ValidateCreatePbufferFromClientBuffer(Display *display, EGLenum buftype, E } } - ANGLE_TRY(display->validateClientBuffer(config, buftype, buffer, attributes)); - return Error(EGL_SUCCESS); } @@ -1576,41 +1546,4 @@ Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display, return stream->validateD3D11NV12Texture(texture); } - -Error ValidateSwapBuffersWithDamageEXT(const Display *display, - const Surface *surface, - EGLint *rects, - EGLint n_rects) -{ - Error error = ValidateSurface(display, surface); - if (error.isError()) - { - return error; - } - - if (!display->getExtensions().swapBuffersWithDamage) - { - // It is out of spec what happens when calling an extension function when the extension is - // not available. EGL_BAD_DISPLAY seems like a reasonable error. - return Error(EGL_BAD_DISPLAY, "EGL_EXT_swap_buffers_with_damage is not available."); - } - - if (surface == EGL_NO_SURFACE) - { - return Error(EGL_BAD_SURFACE, "Swap surface cannot be EGL_NO_SURFACE."); - } - - if (n_rects < 0) - { - return Error(EGL_BAD_PARAMETER, "n_rects cannot be negative."); - } - - if (n_rects > 0 && rects == nullptr) - { - return Error(EGL_BAD_PARAMETER, "n_rects cannot be greater than zero when rects is NULL."); - } - - return Error(EGL_SUCCESS); -} - } // namespace gl diff --git a/gfx/angle/src/libANGLE/validationEGL.h b/gfx/angle/src/libANGLE/validationEGL.h index c299f860c..049279087 100755 --- a/gfx/angle/src/libANGLE/validationEGL.h +++ b/gfx/angle/src/libANGLE/validationEGL.h @@ -32,9 +32,9 @@ class Surface; // Object validation Error ValidateDisplay(const Display *display); -Error ValidateSurface(const Display *display, const Surface *surface); +Error ValidateSurface(const Display *display, Surface *surface); Error ValidateConfig(const Display *display, const Config *config); -Error ValidateContext(const Display *display, const gl::Context *context); +Error ValidateContext(const Display *display, gl::Context *context); Error ValidateImage(const Display *display, const Image *image); // Entry point validation @@ -95,11 +95,6 @@ Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display, void *texture, const AttributeMap &attribs); -Error ValidateSwapBuffersWithDamageEXT(const Display *display, - const Surface *surface, - EGLint *rects, - EGLint n_rects); - // Other validation Error ValidateCompatibleConfigs(const Display *display, const Config *config1, diff --git a/gfx/angle/src/libANGLE/validationES.cpp b/gfx/angle/src/libANGLE/validationES.cpp index 79e3f6636..1bbfe866e 100755 --- a/gfx/angle/src/libANGLE/validationES.cpp +++ b/gfx/angle/src/libANGLE/validationES.cpp @@ -99,1190 +99,41 @@ bool ValidateDrawAttribs(ValidationContext *context, GLint primcount, GLint maxV return true; } -bool ValidReadPixelsFormatType(ValidationContext *context, - GLenum framebufferComponentType, - GLenum format, - GLenum type) -{ - switch (framebufferComponentType) - { - case GL_UNSIGNED_NORMALIZED: - // TODO(geofflang): Don't accept BGRA here. Some chrome internals appear to try to use - // ReadPixels with BGRA even if the extension is not present - return (format == GL_RGBA && type == GL_UNSIGNED_BYTE) || - (context->getExtensions().readFormatBGRA && format == GL_BGRA_EXT && - type == GL_UNSIGNED_BYTE); - - case GL_SIGNED_NORMALIZED: - return (format == GL_RGBA && type == GL_UNSIGNED_BYTE); - - case GL_INT: - return (format == GL_RGBA_INTEGER && type == GL_INT); - - case GL_UNSIGNED_INT: - return (format == GL_RGBA_INTEGER && type == GL_UNSIGNED_INT); - - case GL_FLOAT: - return (format == GL_RGBA && type == GL_FLOAT); - - default: - UNREACHABLE(); - return false; - } -} +} // anonymous namespace -bool ValidCap(const Context *context, GLenum cap, bool queryOnly) +bool ValidCap(const Context *context, GLenum cap) { switch (cap) { - // EXT_multisample_compatibility - case GL_MULTISAMPLE_EXT: - case GL_SAMPLE_ALPHA_TO_ONE_EXT: - return context->getExtensions().multisampleCompatibility; - - case GL_CULL_FACE: - case GL_POLYGON_OFFSET_FILL: - case GL_SAMPLE_ALPHA_TO_COVERAGE: - case GL_SAMPLE_COVERAGE: - case GL_SCISSOR_TEST: - case GL_STENCIL_TEST: - case GL_DEPTH_TEST: - case GL_BLEND: - case GL_DITHER: - return true; - - case GL_PRIMITIVE_RESTART_FIXED_INDEX: - case GL_RASTERIZER_DISCARD: - return (context->getClientMajorVersion() >= 3); - - case GL_DEBUG_OUTPUT_SYNCHRONOUS: - case GL_DEBUG_OUTPUT: - return context->getExtensions().debug; - - case GL_BIND_GENERATES_RESOURCE_CHROMIUM: - return queryOnly && context->getExtensions().bindGeneratesResource; - - case GL_FRAMEBUFFER_SRGB_EXT: - return context->getExtensions().sRGBWriteControl; - - default: - return false; - } -} - -bool ValidateReadPixelsBase(ValidationContext *context, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - GLsizei *length, - GLvoid *pixels) -{ - if (length != nullptr) - { - *length = 0; - } - - if (width < 0 || height < 0) - { - context->handleError(Error(GL_INVALID_VALUE, "width and height must be positive")); - return false; - } - - auto readFramebuffer = context->getGLState().getReadFramebuffer(); - - if (readFramebuffer->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE) - { - context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); - return false; - } - - if (readFramebuffer->id() != 0 && readFramebuffer->getSamples(context->getContextState()) != 0) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - - const Framebuffer *framebuffer = context->getGLState().getReadFramebuffer(); - ASSERT(framebuffer); - - if (framebuffer->getReadBufferState() == GL_NONE) - { - context->handleError(Error(GL_INVALID_OPERATION, "Read buffer is GL_NONE")); - return false; - } - - const FramebufferAttachment *readBuffer = framebuffer->getReadColorbuffer(); - if (!readBuffer) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - - GLenum currentFormat = framebuffer->getImplementationColorReadFormat(); - GLenum currentType = framebuffer->getImplementationColorReadType(); - GLenum currentInternalFormat = readBuffer->getFormat().asSized(); - - const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(currentInternalFormat); - bool validFormatTypeCombination = - ValidReadPixelsFormatType(context, internalFormatInfo.componentType, format, type); - - if (!(currentFormat == format && currentType == type) && !validFormatTypeCombination) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - - // Check for pixel pack buffer related API errors - gl::Buffer *pixelPackBuffer = context->getGLState().getTargetBuffer(GL_PIXEL_PACK_BUFFER); - if (pixelPackBuffer != nullptr && pixelPackBuffer->isMapped()) - { - // ...the buffer object's data store is currently mapped. - context->handleError(Error(GL_INVALID_OPERATION, "Pixel pack buffer is mapped.")); - return false; - } - - // .. the data would be packed to the buffer object such that the memory writes required - // would exceed the data store size. - GLenum sizedInternalFormat = GetSizedInternalFormat(format, type); - const InternalFormat &formatInfo = GetInternalFormatInfo(sizedInternalFormat); - const gl::Extents size(width, height, 1); - const auto &pack = context->getGLState().getPackState(); - - auto endByteOrErr = formatInfo.computePackUnpackEndByte(size, pack, false); - if (endByteOrErr.isError()) - { - context->handleError(endByteOrErr.getError()); - return false; - } - - size_t endByte = endByteOrErr.getResult(); - if (bufSize >= 0) - { - - if (static_cast<size_t>(bufSize) < endByte) - { - context->handleError( - Error(GL_INVALID_OPERATION, "bufSize must be at least %u bytes.", endByte)); - return false; - } - } - - if (pixelPackBuffer != nullptr) - { - CheckedNumeric<size_t> checkedEndByte(endByte); - CheckedNumeric<size_t> checkedOffset(reinterpret_cast<size_t>(pixels)); - checkedEndByte += checkedOffset; - - if (checkedEndByte.ValueOrDie() > static_cast<size_t>(pixelPackBuffer->getSize())) - { - // Overflow past the end of the buffer - context->handleError( - Error(GL_INVALID_OPERATION, "Writes would overflow the pixel pack buffer.")); - return false; - } - } - - if (length != nullptr) - { - if (endByte > static_cast<size_t>(std::numeric_limits<GLsizei>::max())) - { - context->handleError( - Error(GL_INVALID_OPERATION, "length would overflow GLsizei.", endByte)); - return false; - } - - *length = static_cast<GLsizei>(endByte); - } - - return true; -} - -bool ValidateGetRenderbufferParameterivBase(Context *context, - GLenum target, - GLenum pname, - GLsizei *length) -{ - if (length) - { - *length = 0; - } - - if (target != GL_RENDERBUFFER) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid target.")); - return false; - } - - Renderbuffer *renderbuffer = context->getGLState().getCurrentRenderbuffer(); - if (renderbuffer == nullptr) - { - context->handleError(Error(GL_INVALID_OPERATION, "No renderbuffer bound.")); - return false; - } - - switch (pname) - { - case GL_RENDERBUFFER_WIDTH: - case GL_RENDERBUFFER_HEIGHT: - case GL_RENDERBUFFER_INTERNAL_FORMAT: - case GL_RENDERBUFFER_RED_SIZE: - case GL_RENDERBUFFER_GREEN_SIZE: - case GL_RENDERBUFFER_BLUE_SIZE: - case GL_RENDERBUFFER_ALPHA_SIZE: - case GL_RENDERBUFFER_DEPTH_SIZE: - case GL_RENDERBUFFER_STENCIL_SIZE: - break; - - case GL_RENDERBUFFER_SAMPLES_ANGLE: - if (!context->getExtensions().framebufferMultisample) - { - context->handleError( - Error(GL_INVALID_ENUM, "GL_ANGLE_framebuffer_multisample is not enabled.")); - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown pname.")); - return false; - } - - if (length) - { - *length = 1; - } - return true; -} - -bool ValidateGetShaderivBase(Context *context, GLuint shader, GLenum pname, GLsizei *length) -{ - if (length) - { - *length = 0; - } - - if (GetValidShader(context, shader) == nullptr) - { - return false; - } - - switch (pname) - { - case GL_SHADER_TYPE: - case GL_DELETE_STATUS: - case GL_COMPILE_STATUS: - case GL_INFO_LOG_LENGTH: - case GL_SHADER_SOURCE_LENGTH: - break; - - case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: - if (!context->getExtensions().translatedShaderSource) - { - context->handleError( - Error(GL_INVALID_ENUM, "GL_ANGLE_translated_shader_source is not enabled.")); - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown pname.")); - return false; - } - - if (length) - { - *length = 1; - } - return true; -} - -bool ValidateGetTexParameterBase(Context *context, GLenum target, GLenum pname, GLsizei *length) -{ - if (length) - { - *length = 0; - } - - if (!ValidTextureTarget(context, target) && !ValidTextureExternalTarget(context, target)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid texture target")); - return false; - } - - if (context->getTargetTexture(target) == nullptr) - { - // Should only be possible for external textures - context->handleError(Error(GL_INVALID_ENUM, "No texture bound.")); - return false; - } - - switch (pname) - { - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - break; - - case GL_TEXTURE_USAGE_ANGLE: - if (!context->getExtensions().textureUsage) - { - context->handleError( - Error(GL_INVALID_ENUM, "GL_ANGLE_texture_usage is not enabled.")); - return false; - } - break; - - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (!context->getExtensions().textureFilterAnisotropic) - { - context->handleError( - Error(GL_INVALID_ENUM, "GL_EXT_texture_filter_anisotropic is not enabled.")); - return false; - } - break; - - case GL_TEXTURE_IMMUTABLE_FORMAT: - if (context->getClientMajorVersion() < 3 && !context->getExtensions().textureStorage) - { - context->handleError( - Error(GL_INVALID_ENUM, "GL_EXT_texture_storage is not enabled.")); - return false; - } - break; - - case GL_TEXTURE_WRAP_R: - case GL_TEXTURE_IMMUTABLE_LEVELS: - case GL_TEXTURE_SWIZZLE_R: - case GL_TEXTURE_SWIZZLE_G: - case GL_TEXTURE_SWIZZLE_B: - case GL_TEXTURE_SWIZZLE_A: - case GL_TEXTURE_BASE_LEVEL: - case GL_TEXTURE_MAX_LEVEL: - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - case GL_TEXTURE_COMPARE_MODE: - case GL_TEXTURE_COMPARE_FUNC: - if (context->getClientMajorVersion() < 3) - { - context->handleError(Error(GL_INVALID_ENUM, "pname requires OpenGL ES 3.0.")); - return false; - } - break; - - case GL_TEXTURE_SRGB_DECODE_EXT: - if (!context->getExtensions().textureSRGBDecode) - { - context->handleError( - Error(GL_INVALID_ENUM, "GL_EXT_texture_sRGB_decode is not enabled.")); - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown pname.")); - return false; - } - - if (length) - { - *length = 1; - } - return true; -} - -template <typename ParamType> -bool ValidateTextureWrapModeValue(Context *context, ParamType *params, bool isExternalTextureTarget) -{ - switch (ConvertToGLenum(params[0])) - { - case GL_CLAMP_TO_EDGE: - break; - - case GL_REPEAT: - case GL_MIRRORED_REPEAT: - if (isExternalTextureTarget) - { - // OES_EGL_image_external specifies this error. - context->handleError(Error( - GL_INVALID_ENUM, "external textures only support CLAMP_TO_EDGE wrap mode")); - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown param value.")); - return false; - } - - return true; -} - -template <typename ParamType> -bool ValidateTextureMinFilterValue(Context *context, - ParamType *params, - bool isExternalTextureTarget) -{ - switch (ConvertToGLenum(params[0])) - { - case GL_NEAREST: - case GL_LINEAR: - break; - - case GL_NEAREST_MIPMAP_NEAREST: - case GL_LINEAR_MIPMAP_NEAREST: - case GL_NEAREST_MIPMAP_LINEAR: - case GL_LINEAR_MIPMAP_LINEAR: - if (isExternalTextureTarget) - { - // OES_EGL_image_external specifies this error. - context->handleError( - Error(GL_INVALID_ENUM, - "external textures only support NEAREST and LINEAR filtering")); - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown param value.")); - return false; - } - - return true; -} - -template <typename ParamType> -bool ValidateTextureMagFilterValue(Context *context, ParamType *params) -{ - switch (ConvertToGLenum(params[0])) - { - case GL_NEAREST: - case GL_LINEAR: - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown param value.")); - return false; - } - - return true; -} - -template <typename ParamType> -bool ValidateTextureCompareModeValue(Context *context, ParamType *params) -{ - // Acceptable mode parameters from GLES 3.0.2 spec, table 3.17 - switch (ConvertToGLenum(params[0])) - { - case GL_NONE: - case GL_COMPARE_REF_TO_TEXTURE: - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown param value.")); - return false; - } - - return true; -} - -template <typename ParamType> -bool ValidateTextureCompareFuncValue(Context *context, ParamType *params) -{ - // Acceptable function parameters from GLES 3.0.2 spec, table 3.17 - switch (ConvertToGLenum(params[0])) - { - case GL_LEQUAL: - case GL_GEQUAL: - case GL_LESS: - case GL_GREATER: - case GL_EQUAL: - case GL_NOTEQUAL: - case GL_ALWAYS: - case GL_NEVER: - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown param value.")); - return false; - } - - return true; -} - -template <typename ParamType> -bool ValidateTextureSRGBDecodeValue(Context *context, ParamType *params) -{ - if (!context->getExtensions().textureSRGBDecode) - { - context->handleError(Error(GL_INVALID_ENUM, "GL_EXT_texture_sRGB_decode is not enabled.")); - return false; - } - - switch (ConvertToGLenum(params[0])) - { - case GL_DECODE_EXT: - case GL_SKIP_DECODE_EXT: - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown param value.")); - return false; - } - - return true; -} - -template <typename ParamType> -bool ValidateTexParameterBase(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - ParamType *params) -{ - if (!ValidTextureTarget(context, target) && !ValidTextureExternalTarget(context, target)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid texture target")); - return false; - } - - if (context->getTargetTexture(target) == nullptr) - { - // Should only be possible for external textures - context->handleError(Error(GL_INVALID_ENUM, "No texture bound.")); - return false; - } - - const GLsizei minBufSize = 1; - if (bufSize >= 0 && bufSize < minBufSize) - { - context->handleError( - Error(GL_INVALID_OPERATION, "bufSize must be at least %i.", minBufSize)); - return false; - } - - switch (pname) - { - case GL_TEXTURE_WRAP_R: - case GL_TEXTURE_SWIZZLE_R: - case GL_TEXTURE_SWIZZLE_G: - case GL_TEXTURE_SWIZZLE_B: - case GL_TEXTURE_SWIZZLE_A: - case GL_TEXTURE_BASE_LEVEL: - case GL_TEXTURE_MAX_LEVEL: - case GL_TEXTURE_COMPARE_MODE: - case GL_TEXTURE_COMPARE_FUNC: - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - if (context->getClientMajorVersion() < 3) - { - context->handleError(Error(GL_INVALID_ENUM, "pname requires OpenGL ES 3.0.")); - return false; - } - if (target == GL_TEXTURE_EXTERNAL_OES && - !context->getExtensions().eglImageExternalEssl3) - { - context->handleError(Error(GL_INVALID_ENUM, - "ES3 texture parameters are not available without " - "GL_OES_EGL_image_external_essl3.")); - return false; - } - break; - - default: - break; - } - - switch (pname) - { - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_WRAP_R: - if (!ValidateTextureWrapModeValue(context, params, target == GL_TEXTURE_EXTERNAL_OES)) - { - return false; - } - break; - - case GL_TEXTURE_MIN_FILTER: - if (!ValidateTextureMinFilterValue(context, params, target == GL_TEXTURE_EXTERNAL_OES)) - { - return false; - } - break; - - case GL_TEXTURE_MAG_FILTER: - if (!ValidateTextureMagFilterValue(context, params)) - { - return false; - } - break; - - case GL_TEXTURE_USAGE_ANGLE: - switch (ConvertToGLenum(params[0])) - { - case GL_NONE: - case GL_FRAMEBUFFER_ATTACHMENT_ANGLE: - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown param value.")); - return false; - } - break; - - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (!context->getExtensions().textureFilterAnisotropic) - { - context->handleError( - Error(GL_INVALID_ENUM, "GL_EXT_texture_anisotropic is not enabled.")); - return false; - } - - // we assume the parameter passed to this validation method is truncated, not rounded - if (params[0] < 1) - { - context->handleError(Error(GL_INVALID_VALUE, "Max anisotropy must be at least 1.")); - return false; - } - break; - - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - // any value is permissible - break; - - case GL_TEXTURE_COMPARE_MODE: - if (!ValidateTextureCompareModeValue(context, params)) - { - return false; - } - break; - - case GL_TEXTURE_COMPARE_FUNC: - if (!ValidateTextureCompareFuncValue(context, params)) - { - return false; - } - break; - - case GL_TEXTURE_SWIZZLE_R: - case GL_TEXTURE_SWIZZLE_G: - case GL_TEXTURE_SWIZZLE_B: - case GL_TEXTURE_SWIZZLE_A: - switch (ConvertToGLenum(params[0])) - { - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_ZERO: - case GL_ONE: - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown param value.")); - return false; - } - break; - - case GL_TEXTURE_BASE_LEVEL: - if (params[0] < 0) - { - context->handleError(Error(GL_INVALID_VALUE, "Base level must be at least 0.")); - return false; - } - if (target == GL_TEXTURE_EXTERNAL_OES && static_cast<GLuint>(params[0]) != 0) - { - context->handleError( - Error(GL_INVALID_OPERATION, "Base level must be 0 for external textures.")); - return false; - } - break; - - case GL_TEXTURE_MAX_LEVEL: - if (params[0] < 0) - { - context->handleError(Error(GL_INVALID_VALUE, "Max level must be at least 0.")); - return false; - } - break; - - case GL_TEXTURE_SRGB_DECODE_EXT: - if (!ValidateTextureSRGBDecodeValue(context, params)) - { - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown pname.")); - return false; - } - - return true; -} - -template <typename ParamType> -bool ValidateSamplerParameterBase(Context *context, - GLuint sampler, - GLenum pname, - GLsizei bufSize, - ParamType *params) -{ - if (context->getClientMajorVersion() < 3) - { - context->handleError( - Error(GL_INVALID_OPERATION, "Context does not support OpenGL ES 3.0.")); - return false; - } - - if (!context->isSampler(sampler)) - { - context->handleError(Error(GL_INVALID_OPERATION, "Sampler is not valid.")); - return false; - } - - const GLsizei minBufSize = 1; - if (bufSize >= 0 && bufSize < minBufSize) - { - context->handleError( - Error(GL_INVALID_OPERATION, "bufSize must be at least %i.", minBufSize)); - return false; - } - - switch (pname) - { - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_WRAP_R: - if (!ValidateTextureWrapModeValue(context, params, false)) - { - return false; - } - break; - - case GL_TEXTURE_MIN_FILTER: - if (!ValidateTextureMinFilterValue(context, params, false)) - { - return false; - } - break; - - case GL_TEXTURE_MAG_FILTER: - if (!ValidateTextureMagFilterValue(context, params)) - { - return false; - } - break; - - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - // any value is permissible - break; - - case GL_TEXTURE_COMPARE_MODE: - if (!ValidateTextureCompareModeValue(context, params)) - { - return false; - } - break; - - case GL_TEXTURE_COMPARE_FUNC: - if (!ValidateTextureCompareFuncValue(context, params)) - { - return false; - } - break; - - case GL_TEXTURE_SRGB_DECODE_EXT: - if (!ValidateTextureSRGBDecodeValue(context, params)) - { - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown pname.")); - return false; - } - - return true; -} - -bool ValidateGetSamplerParameterBase(Context *context, - GLuint sampler, - GLenum pname, - GLsizei *length) -{ - if (length) - { - *length = 0; - } - - if (context->getClientMajorVersion() < 3) - { - context->handleError( - Error(GL_INVALID_OPERATION, "Context does not support OpenGL ES 3.0.")); - return false; - } - - if (!context->isSampler(sampler)) - { - context->handleError(Error(GL_INVALID_OPERATION, "Sampler is not valid.")); - return false; - } - - switch (pname) - { - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_WRAP_R: - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - case GL_TEXTURE_COMPARE_MODE: - case GL_TEXTURE_COMPARE_FUNC: - break; - - case GL_TEXTURE_SRGB_DECODE_EXT: - if (!context->getExtensions().textureSRGBDecode) - { - context->handleError( - Error(GL_INVALID_ENUM, "GL_EXT_texture_sRGB_decode is not enabled.")); - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown pname.")); - return false; - } - - if (length) - { - *length = 1; - } - return true; -} - -bool ValidateGetVertexAttribBase(Context *context, - GLuint index, - GLenum pname, - GLsizei *length, - bool pointer, - bool pureIntegerEntryPoint) -{ - if (length) - { - *length = 0; - } - - if (pureIntegerEntryPoint && context->getClientMajorVersion() < 3) - { - context->handleError( - Error(GL_INVALID_OPERATION, "Context does not support OpenGL ES 3.0.")); - return false; - } - - if (index >= context->getCaps().maxVertexAttributes) - { - context->handleError(Error( - GL_INVALID_VALUE, "index must be less than the value of GL_MAX_VERTEX_ATTRIBUTES.")); - return false; - } - - if (pointer) - { - if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) - { - context->handleError(Error(GL_INVALID_ENUM, "Unknown pname.")); - return false; - } - } - else - { - switch (pname) - { - case GL_VERTEX_ATTRIB_ARRAY_ENABLED: - case GL_VERTEX_ATTRIB_ARRAY_SIZE: - case GL_VERTEX_ATTRIB_ARRAY_STRIDE: - case GL_VERTEX_ATTRIB_ARRAY_TYPE: - case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: - case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: - case GL_CURRENT_VERTEX_ATTRIB: - break; - - case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: - static_assert( - GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE, - "ANGLE extension enums not equal to GL enums."); - if (context->getClientMajorVersion() < 3 && - !context->getExtensions().instancedArrays) - { - context->handleError(Error(GL_INVALID_ENUM, - "GL_VERTEX_ATTRIB_ARRAY_DIVISOR requires OpenGL ES " - "3.0 or GL_ANGLE_instanced_arrays.")); - return false; - } - break; - - case GL_VERTEX_ATTRIB_ARRAY_INTEGER: - if (context->getClientMajorVersion() < 3) - { - context->handleError(Error(GL_INVALID_ENUM, "pname requires OpenGL ES 3.0.")); - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown pname.")); - return false; - } - } - - if (length) - { - if (pname == GL_CURRENT_VERTEX_ATTRIB) - { - *length = 4; - } - else - { - *length = 1; - } - } - - return true; -} - -bool ValidateGetActiveUniformBlockivBase(Context *context, - GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLsizei *length) -{ - if (length) - { - *length = 0; - } - - if (context->getClientMajorVersion() < 3) - { - context->handleError( - Error(GL_INVALID_OPERATION, "Context does not support OpenGL ES 3.0.")); - return false; - } - - Program *programObject = GetValidProgram(context, program); - if (!programObject) - { - return false; - } - - if (uniformBlockIndex >= programObject->getActiveUniformBlockCount()) - { - context->handleError( - Error(GL_INVALID_VALUE, "uniformBlockIndex exceeds active uniform block count.")); - return false; - } - - switch (pname) - { - case GL_UNIFORM_BLOCK_BINDING: - case GL_UNIFORM_BLOCK_DATA_SIZE: - case GL_UNIFORM_BLOCK_NAME_LENGTH: - case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: - case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: - case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: - case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown pname.")); - return false; - } - - if (length) - { - if (pname == GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) - { - const UniformBlock &uniformBlock = - programObject->getUniformBlockByIndex(uniformBlockIndex); - *length = static_cast<GLsizei>(uniformBlock.memberUniformIndexes.size()); - } - else - { - *length = 1; - } - } - - return true; -} - -bool ValidateGetBufferParameterBase(ValidationContext *context, - GLenum target, - GLenum pname, - bool pointerVersion, - GLsizei *numParams) -{ - if (numParams) - { - *numParams = 0; - } - - if (!ValidBufferTarget(context, target)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid buffer target.")); - return false; - } - - const Buffer *buffer = context->getGLState().getTargetBuffer(target); - if (!buffer) - { - // A null buffer means that "0" is bound to the requested buffer target - context->handleError(Error(GL_INVALID_OPERATION, "No buffer bound.")); - return false; - } - - const Extensions &extensions = context->getExtensions(); - - switch (pname) - { - case GL_BUFFER_USAGE: - case GL_BUFFER_SIZE: - break; - - case GL_BUFFER_ACCESS_OES: - if (!extensions.mapBuffer) - { - context->handleError( - Error(GL_INVALID_ENUM, "pname requires OpenGL ES 3.0 or GL_OES_map_buffer.")); - return false; - } - break; - - case GL_BUFFER_MAPPED: - static_assert(GL_BUFFER_MAPPED == GL_BUFFER_MAPPED_OES, "GL enums should be equal."); - if (context->getClientMajorVersion() < 3 && !extensions.mapBuffer && - !extensions.mapBufferRange) - { - context->handleError(Error( - GL_INVALID_ENUM, - "pname requires OpenGL ES 3.0, GL_OES_map_buffer or GL_EXT_map_buffer_range.")); - return false; - } - break; - - case GL_BUFFER_MAP_POINTER: - if (!pointerVersion) - { - context->handleError( - Error(GL_INVALID_ENUM, - "GL_BUFFER_MAP_POINTER can only be queried with GetBufferPointerv.")); - return false; - } - break; - - case GL_BUFFER_ACCESS_FLAGS: - case GL_BUFFER_MAP_OFFSET: - case GL_BUFFER_MAP_LENGTH: - if (context->getClientMajorVersion() < 3 && !extensions.mapBufferRange) - { - context->handleError(Error( - GL_INVALID_ENUM, "pname requires OpenGL ES 3.0 or GL_EXT_map_buffer_range.")); - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown pname.")); - return false; - } - - // All buffer parameter queries return one value. - if (numParams) - { - *numParams = 1; - } - - return true; -} - -bool ValidateGetInternalFormativBase(Context *context, - GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLsizei *numParams) -{ - if (numParams) - { - *numParams = 0; - } - - if (context->getClientMajorVersion() < 3) - { - context->handleError( - Error(GL_INVALID_OPERATION, "Context does not support OpenGL ES 3.0.")); - return false; - } - - const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); - if (!formatCaps.renderable) - { - context->handleError(Error(GL_INVALID_ENUM, "Internal format is not renderable.")); - return false; - } + // EXT_multisample_compatibility + case GL_MULTISAMPLE_EXT: + case GL_SAMPLE_ALPHA_TO_ONE_EXT: + return context->getExtensions().multisampleCompatibility; + + case GL_CULL_FACE: + case GL_POLYGON_OFFSET_FILL: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_COVERAGE: + case GL_SCISSOR_TEST: + case GL_STENCIL_TEST: + case GL_DEPTH_TEST: + case GL_BLEND: + case GL_DITHER: + return true; - switch (target) - { - case GL_RENDERBUFFER: - break; + case GL_PRIMITIVE_RESTART_FIXED_INDEX: + case GL_RASTERIZER_DISCARD: + return (context->getClientMajorVersion() >= 3); - default: - context->handleError(Error(GL_INVALID_ENUM, "Invalid target.")); - return false; - } + case GL_DEBUG_OUTPUT_SYNCHRONOUS: + case GL_DEBUG_OUTPUT: + return context->getExtensions().debug; - if (bufSize < 0) - { - context->handleError(Error(GL_INVALID_VALUE, "bufSize cannot be negative.")); + default: return false; } - - GLsizei maxWriteParams = 0; - switch (pname) - { - case GL_NUM_SAMPLE_COUNTS: - maxWriteParams = 1; - break; - - case GL_SAMPLES: - maxWriteParams = static_cast<GLsizei>(formatCaps.sampleCounts.size()); - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown pname.")); - return false; - } - - if (numParams) - { - // glGetInternalFormativ will not overflow bufSize - *numParams = std::min(bufSize, maxWriteParams); - } - - return true; } -} // anonymous namespace - bool ValidTextureTarget(const ValidationContext *context, GLenum target) { switch (target) @@ -1382,7 +233,7 @@ bool ValidFramebufferTarget(GLenum target) } } -bool ValidBufferTarget(const ValidationContext *context, GLenum target) +bool ValidBufferTarget(const Context *context, GLenum target) { switch (target) { @@ -1406,6 +257,36 @@ bool ValidBufferTarget(const ValidationContext *context, GLenum target) } } +bool ValidBufferParameter(const Context *context, GLenum pname) +{ + const Extensions &extensions = context->getExtensions(); + + switch (pname) + { + case GL_BUFFER_USAGE: + case GL_BUFFER_SIZE: + return true; + + case GL_BUFFER_ACCESS_OES: + return extensions.mapBuffer; + + case GL_BUFFER_MAPPED: + static_assert(GL_BUFFER_MAPPED == GL_BUFFER_MAPPED_OES, "GL enums should be equal."); + return (context->getClientMajorVersion() >= 3) || extensions.mapBuffer || + extensions.mapBufferRange; + + // GL_BUFFER_MAP_POINTER is a special case, and may only be + // queried with GetBufferPointerv + case GL_BUFFER_ACCESS_FLAGS: + case GL_BUFFER_MAP_OFFSET: + case GL_BUFFER_MAP_LENGTH: + return (context->getClientMajorVersion() >= 3) || extensions.mapBufferRange; + + default: + return false; + } +} + bool ValidMipLevel(const ValidationContext *context, GLenum target, GLint level) { const auto &caps = context->getCaps(); @@ -1513,75 +394,6 @@ bool ValidCompressedImageSize(const ValidationContext *context, return true; } -bool ValidImageDataSize(ValidationContext *context, - GLenum textureTarget, - GLsizei width, - GLsizei height, - GLsizei depth, - GLenum internalFormat, - GLenum type, - const GLvoid *pixels, - GLsizei imageSize) -{ - gl::Buffer *pixelUnpackBuffer = context->getGLState().getTargetBuffer(GL_PIXEL_UNPACK_BUFFER); - if (pixelUnpackBuffer == nullptr && imageSize < 0) - { - // Checks are not required - return true; - } - - // ...the data would be unpacked from the buffer object such that the memory reads required - // would exceed the data store size. - GLenum sizedFormat = GetSizedInternalFormat(internalFormat, type); - const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(sizedFormat); - const gl::Extents size(width, height, depth); - const auto &unpack = context->getGLState().getUnpackState(); - - bool targetIs3D = textureTarget == GL_TEXTURE_3D || textureTarget == GL_TEXTURE_2D_ARRAY; - auto endByteOrErr = formatInfo.computePackUnpackEndByte(size, unpack, targetIs3D); - if (endByteOrErr.isError()) - { - context->handleError(endByteOrErr.getError()); - return false; - } - - GLuint endByte = endByteOrErr.getResult(); - - if (pixelUnpackBuffer) - { - CheckedNumeric<size_t> checkedEndByte(endByteOrErr.getResult()); - CheckedNumeric<size_t> checkedOffset(reinterpret_cast<size_t>(pixels)); - checkedEndByte += checkedOffset; - - if (!checkedEndByte.IsValid() || - (checkedEndByte.ValueOrDie() > static_cast<size_t>(pixelUnpackBuffer->getSize()))) - { - // Overflow past the end of the buffer - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - } - else - { - ASSERT(imageSize >= 0); - if (pixels == nullptr && imageSize != 0) - { - context->handleError( - Error(GL_INVALID_OPERATION, "imageSize must be 0 if no texture data is provided.")); - return false; - } - - if (pixels != nullptr && endByte > static_cast<GLuint>(imageSize)) - { - context->handleError( - Error(GL_INVALID_OPERATION, "imageSize must be at least %u.", endByte)); - return false; - } - } - - return true; -} - bool ValidQueryType(const Context *context, GLenum queryType) { static_assert(GL_ANY_SAMPLES_PASSED == GL_ANY_SAMPLES_PASSED_EXT, "GL extension enums not equal."); @@ -1603,7 +415,7 @@ bool ValidQueryType(const Context *context, GLenum queryType) } } -Program *GetValidProgram(ValidationContext *context, GLuint id) +Program *GetValidProgram(Context *context, GLuint id) { // ES3 spec (section 2.11.1) -- "Commands that accept shader or program object names will generate the // error INVALID_VALUE if the provided name is not the name of either a shader or program object and @@ -1627,7 +439,7 @@ Program *GetValidProgram(ValidationContext *context, GLuint id) return validProgram; } -Shader *GetValidShader(ValidationContext *context, GLuint id) +Shader *GetValidShader(Context *context, GLuint id) { // See ValidProgram for spec details. @@ -1670,8 +482,7 @@ bool ValidateAttachmentTarget(gl::Context *context, GLenum attachment) break; case GL_DEPTH_STENCIL_ATTACHMENT: - if (!context->getExtensions().webglCompatibility && - context->getClientMajorVersion() < 3) + if (context->getClientMajorVersion() < 3) { context->handleError(Error(GL_INVALID_ENUM)); return false; @@ -2004,6 +815,264 @@ bool ValidateBlitFramebufferParameters(ValidationContext *context, return true; } +bool ValidateGetVertexAttribParameters(Context *context, GLenum pname) +{ + switch (pname) + { + case GL_VERTEX_ATTRIB_ARRAY_ENABLED: + case GL_VERTEX_ATTRIB_ARRAY_SIZE: + case GL_VERTEX_ATTRIB_ARRAY_STRIDE: + case GL_VERTEX_ATTRIB_ARRAY_TYPE: + case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: + case GL_CURRENT_VERTEX_ATTRIB: + return true; + + case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: + // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses + // the same constant. + static_assert(GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE, + "ANGLE extension enums not equal to GL enums."); + return true; + + case GL_VERTEX_ATTRIB_ARRAY_INTEGER: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } + return true; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } +} + +bool ValidateTexParamParameters(gl::Context *context, GLenum target, GLenum pname, GLint param) +{ + switch (pname) + { + case GL_TEXTURE_WRAP_R: + case GL_TEXTURE_SWIZZLE_R: + case GL_TEXTURE_SWIZZLE_G: + case GL_TEXTURE_SWIZZLE_B: + case GL_TEXTURE_SWIZZLE_A: + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: + case GL_TEXTURE_COMPARE_MODE: + case GL_TEXTURE_COMPARE_FUNC: + case GL_TEXTURE_MIN_LOD: + case GL_TEXTURE_MAX_LOD: + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } + if (target == GL_TEXTURE_EXTERNAL_OES && !context->getExtensions().eglImageExternalEssl3) + { + context->handleError(Error(GL_INVALID_ENUM, + "ES3 texture parameters are not available without " + "GL_OES_EGL_image_external_essl3.")); + return false; + } + break; + + default: break; + } + + switch (pname) + { + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_TEXTURE_WRAP_R: + switch (param) + { + case GL_CLAMP_TO_EDGE: + return true; + case GL_REPEAT: + case GL_MIRRORED_REPEAT: + if (target == GL_TEXTURE_EXTERNAL_OES) + { + // OES_EGL_image_external specifies this error. + context->handleError(Error( + GL_INVALID_ENUM, "external textures only support CLAMP_TO_EDGE wrap mode")); + return false; + } + return true; + default: + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } + + case GL_TEXTURE_MIN_FILTER: + switch (param) + { + case GL_NEAREST: + case GL_LINEAR: + return true; + case GL_NEAREST_MIPMAP_NEAREST: + case GL_LINEAR_MIPMAP_NEAREST: + case GL_NEAREST_MIPMAP_LINEAR: + case GL_LINEAR_MIPMAP_LINEAR: + if (target == GL_TEXTURE_EXTERNAL_OES) + { + // OES_EGL_image_external specifies this error. + context->handleError( + Error(GL_INVALID_ENUM, + "external textures only support NEAREST and LINEAR filtering")); + return false; + } + return true; + default: + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } + break; + + case GL_TEXTURE_MAG_FILTER: + switch (param) + { + case GL_NEAREST: + case GL_LINEAR: + return true; + default: + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } + break; + + case GL_TEXTURE_USAGE_ANGLE: + switch (param) + { + case GL_NONE: + case GL_FRAMEBUFFER_ATTACHMENT_ANGLE: + return true; + default: + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } + break; + + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (!context->getExtensions().textureFilterAnisotropic) + { + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } + + // we assume the parameter passed to this validation method is truncated, not rounded + if (param < 1) + { + context->handleError(Error(GL_INVALID_VALUE)); + return false; + } + return true; + + case GL_TEXTURE_MIN_LOD: + case GL_TEXTURE_MAX_LOD: + // any value is permissible + return true; + + case GL_TEXTURE_COMPARE_MODE: + // Acceptable mode parameters from GLES 3.0.2 spec, table 3.17 + switch (param) + { + case GL_NONE: + case GL_COMPARE_REF_TO_TEXTURE: + return true; + default: + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } + break; + + case GL_TEXTURE_COMPARE_FUNC: + // Acceptable function parameters from GLES 3.0.2 spec, table 3.17 + switch (param) + { + case GL_LEQUAL: + case GL_GEQUAL: + case GL_LESS: + case GL_GREATER: + case GL_EQUAL: + case GL_NOTEQUAL: + case GL_ALWAYS: + case GL_NEVER: + return true; + default: + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } + break; + + case GL_TEXTURE_SWIZZLE_R: + case GL_TEXTURE_SWIZZLE_G: + case GL_TEXTURE_SWIZZLE_B: + case GL_TEXTURE_SWIZZLE_A: + switch (param) + { + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_ZERO: + case GL_ONE: + return true; + default: + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } + break; + + case GL_TEXTURE_BASE_LEVEL: + if (param < 0) + { + context->handleError(Error(GL_INVALID_VALUE)); + return false; + } + if (target == GL_TEXTURE_EXTERNAL_OES && param != 0) + { + context->handleError( + Error(GL_INVALID_OPERATION, "Base level must be 0 for external textures.")); + return false; + } + return true; + + case GL_TEXTURE_MAX_LEVEL: + if (param < 0) + { + context->handleError(Error(GL_INVALID_VALUE)); + return false; + } + return true; + default: + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } +} + +bool ValidateSamplerObjectParameter(gl::Context *context, GLenum pname) +{ + switch (pname) + { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_TEXTURE_WRAP_R: + case GL_TEXTURE_MIN_LOD: + case GL_TEXTURE_MAX_LOD: + case GL_TEXTURE_COMPARE_MODE: + case GL_TEXTURE_COMPARE_FUNC: + return true; + + default: + context->handleError(Error(GL_INVALID_ENUM)); + return false; + } +} + bool ValidateReadPixels(ValidationContext *context, GLint x, GLint y, @@ -2013,33 +1082,53 @@ bool ValidateReadPixels(ValidationContext *context, GLenum type, GLvoid *pixels) { - return ValidateReadPixelsBase(context, x, y, width, height, format, type, -1, nullptr, pixels); -} + if (width < 0 || height < 0) + { + context->handleError(Error(GL_INVALID_VALUE, "width and height must be positive")); + return false; + } -bool ValidateReadPixelsRobustANGLE(ValidationContext *context, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - GLsizei *length, - GLvoid *pixels) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) + auto readFramebuffer = context->getGLState().getReadFramebuffer(); + + if (readFramebuffer->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE) { + context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); return false; } - if (!ValidateReadPixelsBase(context, x, y, width, height, format, type, bufSize, length, - pixels)) + if (readFramebuffer->id() != 0 && readFramebuffer->getSamples(context->getContextState()) != 0) { + context->handleError(Error(GL_INVALID_OPERATION)); return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + const Framebuffer *framebuffer = context->getGLState().getReadFramebuffer(); + ASSERT(framebuffer); + + if (framebuffer->getReadBufferState() == GL_NONE) { + context->handleError(Error(GL_INVALID_OPERATION, "Read buffer is GL_NONE")); + return false; + } + + const FramebufferAttachment *readBuffer = framebuffer->getReadColorbuffer(); + if (!readBuffer) + { + context->handleError(Error(GL_INVALID_OPERATION)); + return false; + } + + GLenum currentFormat = framebuffer->getImplementationColorReadFormat(); + GLenum currentType = framebuffer->getImplementationColorReadType(); + GLenum currentInternalFormat = readBuffer->getFormat().asSized(); + GLuint clientVersion = context->getClientMajorVersion(); + + bool validReadFormat = (clientVersion < 3) ? ValidES2ReadFormatType(context, format, type) : + ValidES3ReadFormatType(context, currentInternalFormat, format, type); + + if (!(currentFormat == format && currentType == type) && !validReadFormat) + { + context->handleError(Error(GL_INVALID_OPERATION)); return false; } @@ -2062,37 +1151,35 @@ bool ValidateReadnPixelsEXT(Context *context, return false; } - return ValidateReadPixelsBase(context, x, y, width, height, format, type, bufSize, nullptr, - pixels); -} + GLenum sizedInternalFormat = GetSizedInternalFormat(format, type); + const InternalFormat &sizedFormatInfo = GetInternalFormatInfo(sizedInternalFormat); -bool ValidateReadnPixelsRobustANGLE(ValidationContext *context, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - GLsizei *length, - GLvoid *data) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) + auto outputPitchOrErr = + sizedFormatInfo.computeRowPitch(type, width, context->getGLState().getPackAlignment(), + context->getGLState().getPackRowLength()); + + if (outputPitchOrErr.isError()) { + context->handleError(outputPitchOrErr.getError()); return false; } - if (!ValidateReadPixelsBase(context, x, y, width, height, format, type, bufSize, length, data)) + CheckedNumeric<GLuint> checkedOutputPitch(outputPitchOrErr.getResult()); + auto checkedRequiredSize = checkedOutputPitch * height; + if (!checkedRequiredSize.IsValid()) { + context->handleError(Error(GL_INVALID_OPERATION, "Unsigned multiplication overflow.")); return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + // sized query sanity check + if (checkedRequiredSize.ValueOrDie() > static_cast<GLuint>(bufSize)) { + context->handleError(Error(GL_INVALID_OPERATION)); return false; } - return true; + return ValidateReadPixels(context, x, y, width, height, format, type, pixels); } bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n) @@ -2247,13 +1334,8 @@ bool ValidateQueryCounterEXT(Context *context, GLuint id, GLenum target) return true; } -bool ValidateGetQueryivBase(Context *context, GLenum target, GLenum pname, GLsizei *numParams) +bool ValidateGetQueryivBase(Context *context, GLenum target, GLenum pname) { - if (numParams) - { - *numParams = 0; - } - if (!ValidQueryType(context, target) && target != GL_TIMESTAMP_EXT) { context->handleError(Error(GL_INVALID_ENUM, "Invalid query type")); @@ -2283,12 +1365,6 @@ bool ValidateGetQueryivBase(Context *context, GLenum target, GLenum pname, GLsiz return false; } - if (numParams) - { - // All queries return only one value - *numParams = 1; - } - return true; } @@ -2301,41 +1377,11 @@ bool ValidateGetQueryivEXT(Context *context, GLenum target, GLenum pname, GLint return false; } - return ValidateGetQueryivBase(context, target, pname, nullptr); + return ValidateGetQueryivBase(context, target, pname); } -bool ValidateGetQueryivRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) +bool ValidateGetQueryObjectValueBase(Context *context, GLuint id, GLenum pname) { - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetQueryivBase(context, target, pname, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetQueryObjectValueBase(Context *context, GLuint id, GLenum pname, GLsizei *numParams) -{ - if (numParams) - { - *numParams = 0; - } - Query *queryObject = context->getQuery(id, false, GL_NONE); if (!queryObject) @@ -2361,11 +1407,6 @@ bool ValidateGetQueryObjectValueBase(Context *context, GLuint id, GLenum pname, return false; } - if (numParams) - { - *numParams = 1; - } - return true; } @@ -2376,38 +1417,7 @@ bool ValidateGetQueryObjectivEXT(Context *context, GLuint id, GLenum pname, GLin context->handleError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); return false; } - return ValidateGetQueryObjectValueBase(context, id, pname, nullptr); -} - -bool ValidateGetQueryObjectivRobustANGLE(Context *context, - GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - if (!context->getExtensions().disjointTimerQuery) - { - context->handleError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); - return false; - } - - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetQueryObjectValueBase(context, id, pname, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; + return ValidateGetQueryObjectValueBase(context, id, pname); } bool ValidateGetQueryObjectuivEXT(Context *context, GLuint id, GLenum pname, GLuint *params) @@ -2418,39 +1428,7 @@ bool ValidateGetQueryObjectuivEXT(Context *context, GLuint id, GLenum pname, GLu context->handleError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); return false; } - return ValidateGetQueryObjectValueBase(context, id, pname, nullptr); -} - -bool ValidateGetQueryObjectuivRobustANGLE(Context *context, - GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint *params) -{ - if (!context->getExtensions().disjointTimerQuery && - !context->getExtensions().occlusionQueryBoolean && !context->getExtensions().syncQuery) - { - context->handleError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); - return false; - } - - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetQueryObjectValueBase(context, id, pname, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; + return ValidateGetQueryObjectValueBase(context, id, pname); } bool ValidateGetQueryObjecti64vEXT(Context *context, GLuint id, GLenum pname, GLint64 *params) @@ -2460,38 +1438,7 @@ bool ValidateGetQueryObjecti64vEXT(Context *context, GLuint id, GLenum pname, GL context->handleError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); return false; } - return ValidateGetQueryObjectValueBase(context, id, pname, nullptr); -} - -bool ValidateGetQueryObjecti64vRobustANGLE(Context *context, - GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint64 *params) -{ - if (!context->getExtensions().disjointTimerQuery) - { - context->handleError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); - return false; - } - - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetQueryObjectValueBase(context, id, pname, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; + return ValidateGetQueryObjectValueBase(context, id, pname); } bool ValidateGetQueryObjectui64vEXT(Context *context, GLuint id, GLenum pname, GLuint64 *params) @@ -2501,38 +1448,7 @@ bool ValidateGetQueryObjectui64vEXT(Context *context, GLuint id, GLenum pname, G context->handleError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); return false; } - return ValidateGetQueryObjectValueBase(context, id, pname, nullptr); -} - -bool ValidateGetQueryObjectui64vRobustANGLE(Context *context, - GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint64 *params) -{ - if (!context->getExtensions().disjointTimerQuery) - { - context->handleError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); - return false; - } - - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetQueryObjectValueBase(context, id, pname, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; + return ValidateGetQueryObjectValueBase(context, id, pname); } static bool ValidateUniformCommonBase(gl::Context *context, @@ -2671,12 +1587,10 @@ bool ValidateStateQuery(ValidationContext *context, case GL_TEXTURE_BINDING_2D_ARRAY: break; case GL_TEXTURE_BINDING_EXTERNAL_OES: - if (!context->getExtensions().eglStreamConsumerExternal && - !context->getExtensions().eglImageExternal) + if (!context->getExtensions().eglStreamConsumerExternal) { - context->handleError(Error(GL_INVALID_ENUM, - "Neither NV_EGL_stream_consumer_external nor " - "GL_OES_EGL_image_external extensions enabled")); + context->handleError( + Error(GL_INVALID_ENUM, "NV_EGL_stream_consumer_external extension not enabled")); return false; } break; @@ -2714,31 +1628,7 @@ bool ValidateStateQuery(ValidationContext *context, } // pname is valid, but there are no parameters to return - if (*numParams == 0) - { - return false; - } - - return true; -} - -bool ValidateRobustStateQuery(ValidationContext *context, - GLenum pname, - GLsizei bufSize, - GLenum *nativeType, - unsigned int *numParams) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateStateQuery(context, pname, nativeType, numParams)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *numParams)) + if (numParams == 0) { return false; } @@ -2882,7 +1772,7 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, return false; } - if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) + if (!formatInfo.textureSupport(context->getClientMajorVersion(), context->getExtensions())) { context->handleError(Error(GL_INVALID_ENUM)); return false; @@ -3219,7 +2109,7 @@ bool ValidateDrawElements(ValidationContext *context, return false; } - if (!ValidateDrawAttribs(context, primcount, static_cast<GLint>(indexRangeOut->end + 1))) + if (!ValidateDrawAttribs(context, primcount, static_cast<GLint>(indexRangeOut->vertexCount()))) { return false; } @@ -3426,28 +2316,13 @@ bool ValidateGetUniformiv(Context *context, GLuint program, GLint location, GLin return ValidateGetUniformBase(context, program, location); } -static bool ValidateSizedGetUniform(Context *context, - GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length) +static bool ValidateSizedGetUniform(Context *context, GLuint program, GLint location, GLsizei bufSize) { - if (length) - { - *length = 0; - } - if (!ValidateGetUniformBase(context, program, location)) { return false; } - if (bufSize < 0) - { - context->handleError(Error(GL_INVALID_VALUE, "bufSize cannot be negative.")); - return false; - } - gl::Program *programObject = context->getProgram(program); ASSERT(programObject); @@ -3456,82 +2331,21 @@ static bool ValidateSizedGetUniform(Context *context, size_t requiredBytes = VariableExternalSize(uniform.type); if (static_cast<size_t>(bufSize) < requiredBytes) { - context->handleError( - Error(GL_INVALID_OPERATION, "bufSize of at least %u is required.", requiredBytes)); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } - if (length) - { - *length = VariableComponentCount(uniform.type); - } - return true; } bool ValidateGetnUniformfvEXT(Context *context, GLuint program, GLint location, GLsizei bufSize, GLfloat* params) { - return ValidateSizedGetUniform(context, program, location, bufSize, nullptr); + return ValidateSizedGetUniform(context, program, location, bufSize); } bool ValidateGetnUniformivEXT(Context *context, GLuint program, GLint location, GLsizei bufSize, GLint* params) { - return ValidateSizedGetUniform(context, program, location, bufSize, nullptr); -} - -bool ValidateGetUniformfvRobustANGLE(Context *context, - GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLfloat *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - // bufSize is validated in ValidateSizedGetUniform - return ValidateSizedGetUniform(context, program, location, bufSize, length); -} - -bool ValidateGetUniformivRobustANGLE(Context *context, - GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - // bufSize is validated in ValidateSizedGetUniform - return ValidateSizedGetUniform(context, program, location, bufSize, length); -} - -bool ValidateGetUniformuivRobustANGLE(Context *context, - GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLuint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (context->getClientMajorVersion() < 3) - { - context->handleError( - Error(GL_INVALID_OPERATION, "Entry point requires at least OpenGL ES 3.0.")); - return false; - } - - // bufSize is validated in ValidateSizedGetUniform - return ValidateSizedGetUniform(context, program, location, bufSize, length); + return ValidateSizedGetUniform(context, program, location, bufSize); } bool ValidateDiscardFramebufferBase(Context *context, GLenum target, GLsizei numAttachments, @@ -3979,56 +2793,32 @@ bool ValidateCopyTexSubImage2D(Context *context, yoffset, 0, x, y, width, height, 0); } -bool ValidateGetBufferPointervBase(Context *context, - GLenum target, - GLenum pname, - GLsizei *length, - void **params) +bool ValidateGetBufferPointervBase(Context *context, GLenum target, GLenum pname, void **params) { - if (length) - { - *length = 0; - } - - if (context->getClientMajorVersion() < 3 && !context->getExtensions().mapBuffer) - { - context->handleError( - Error(GL_INVALID_OPERATION, - "Context does not support OpenGL ES 3.0 or GL_OES_map_buffer is not enabled.")); - return false; - } - if (!ValidBufferTarget(context, target)) { context->handleError(Error(GL_INVALID_ENUM, "Buffer target not valid: 0x%X", target)); return false; } - switch (pname) + if (pname != GL_BUFFER_MAP_POINTER) { - case GL_BUFFER_MAP_POINTER: - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown pname.")); - return false; + context->handleError(Error(GL_INVALID_ENUM, "pname not valid: 0x%X", pname)); + return false; } + Buffer *buffer = context->getGLState().getTargetBuffer(target); + // GLES 3.0 section 2.10.1: "Attempts to attempts to modify or query buffer object state for a // target bound to zero generate an INVALID_OPERATION error." // GLES 3.1 section 6.6 explicitly specifies this error. - if (context->getGLState().getTargetBuffer(target) == nullptr) + if (!buffer) { context->handleError( Error(GL_INVALID_OPERATION, "Can not get pointer for reserved buffer name zero.")); return false; } - if (length) - { - *length = 1; - } - return true; } @@ -4310,981 +3100,4 @@ bool ValidateGenOrDelete(Context *context, GLint n) return true; } -bool ValidateEnable(Context *context, GLenum cap) -{ - if (!ValidCap(context, cap, false)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid cap.")); - return false; - } - - if (context->getLimitations().noSampleAlphaToCoverageSupport && - cap == GL_SAMPLE_ALPHA_TO_COVERAGE) - { - const char *errorMessage = "Current renderer doesn't support alpha-to-coverage"; - context->handleError(Error(GL_INVALID_OPERATION, errorMessage)); - - // We also output an error message to the debugger window if tracing is active, so that - // developers can see the error message. - ERR("%s", errorMessage); - return false; - } - - return true; -} - -bool ValidateDisable(Context *context, GLenum cap) -{ - if (!ValidCap(context, cap, false)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid cap.")); - return false; - } - - return true; -} - -bool ValidateIsEnabled(Context *context, GLenum cap) -{ - if (!ValidCap(context, cap, true)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid cap.")); - return false; - } - - return true; -} - -bool ValidateRobustEntryPoint(ValidationContext *context, GLsizei bufSize) -{ - if (!context->getExtensions().robustClientMemory) - { - context->handleError( - Error(GL_INVALID_OPERATION, "GL_ANGLE_robust_client_memory is not available.")); - return false; - } - - if (bufSize < 0) - { - context->handleError(Error(GL_INVALID_VALUE, "bufSize cannot be negative.")); - return false; - } - - return true; -} - -bool ValidateRobustBufferSize(ValidationContext *context, GLsizei bufSize, GLsizei numParams) -{ - if (bufSize < numParams) - { - context->handleError(Error(GL_INVALID_OPERATION, - "%u parameters are required but %i were provided.", numParams, - bufSize)); - return false; - } - - return true; -} - -bool ValidateGetFramebufferAttachmentParameteriv(ValidationContext *context, - GLenum target, - GLenum attachment, - GLenum pname, - GLsizei *numParams) -{ - // Only one parameter is returned from glGetFramebufferAttachmentParameteriv - *numParams = 1; - - if (!ValidFramebufferTarget(target)) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - - int clientVersion = context->getClientMajorVersion(); - - switch (pname) - { - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: - break; - - case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: - if (clientVersion < 3 && !context->getExtensions().sRGB) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - break; - - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: - if (clientVersion < 3) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - - // Determine if the attachment is a valid enum - switch (attachment) - { - case GL_BACK: - case GL_FRONT: - case GL_DEPTH: - case GL_STENCIL: - case GL_DEPTH_STENCIL_ATTACHMENT: - if (clientVersion < 3) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - break; - - case GL_DEPTH_ATTACHMENT: - case GL_STENCIL_ATTACHMENT: - break; - - default: - if (attachment < GL_COLOR_ATTACHMENT0_EXT || - (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - break; - } - - const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target); - ASSERT(framebuffer); - - if (framebuffer->id() == 0) - { - if (clientVersion < 3) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - - switch (attachment) - { - case GL_BACK: - case GL_DEPTH: - case GL_STENCIL: - break; - - default: - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - } - else - { - if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) - { - // Valid attachment query - } - else - { - switch (attachment) - { - case GL_DEPTH_ATTACHMENT: - case GL_STENCIL_ATTACHMENT: - break; - - case GL_DEPTH_STENCIL_ATTACHMENT: - if (!framebuffer->hasValidDepthStencil()) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - } - } - - const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment); - if (attachmentObject) - { - ASSERT(attachmentObject->type() == GL_RENDERBUFFER || - attachmentObject->type() == GL_TEXTURE || - attachmentObject->type() == GL_FRAMEBUFFER_DEFAULT); - - switch (pname) - { - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: - if (attachmentObject->type() != GL_RENDERBUFFER && - attachmentObject->type() != GL_TEXTURE) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - break; - - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: - if (attachmentObject->type() != GL_TEXTURE) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - break; - - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: - if (attachmentObject->type() != GL_TEXTURE) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - break; - - case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: - if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - break; - - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: - if (attachmentObject->type() != GL_TEXTURE) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - break; - - default: - break; - } - } - else - { - // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE - // is NONE, then querying any other pname will generate INVALID_ENUM. - - // ES 3.0.2 spec pg 235 states that if the attachment type is none, - // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an - // INVALID_OPERATION for all other pnames - - switch (pname) - { - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: - break; - - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: - if (clientVersion < 3) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - break; - - default: - if (clientVersion < 3) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - else - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - } - } - - return true; -} - -bool ValidateGetFramebufferAttachmentParameterivRobustANGLE(ValidationContext *context, - GLenum target, - GLenum attachment, - GLenum pname, - GLsizei bufSize, - GLsizei *numParams) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetFramebufferAttachmentParameteriv(context, target, attachment, pname, numParams)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *numParams)) - { - return false; - } - - return true; -} - -bool ValidateGetBufferParameteriv(ValidationContext *context, - GLenum target, - GLenum pname, - GLint *params) -{ - return ValidateGetBufferParameterBase(context, target, pname, false, nullptr); -} - -bool ValidateGetBufferParameterivRobustANGLE(ValidationContext *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetBufferParameterBase(context, target, pname, false, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetBufferParameteri64v(ValidationContext *context, - GLenum target, - GLenum pname, - GLint64 *params) -{ - return ValidateGetBufferParameterBase(context, target, pname, false, nullptr); -} - -bool ValidateGetBufferParameteri64vRobustANGLE(ValidationContext *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint64 *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetBufferParameterBase(context, target, pname, false, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetProgramiv(Context *context, GLuint program, GLenum pname, GLsizei *numParams) -{ - // Currently, all GetProgramiv queries return 1 parameter - *numParams = 1; - - Program *programObject = GetValidProgram(context, program); - if (!programObject) - { - return false; - } - - switch (pname) - { - case GL_DELETE_STATUS: - case GL_LINK_STATUS: - case GL_VALIDATE_STATUS: - case GL_INFO_LOG_LENGTH: - case GL_ATTACHED_SHADERS: - case GL_ACTIVE_ATTRIBUTES: - case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: - case GL_ACTIVE_UNIFORMS: - case GL_ACTIVE_UNIFORM_MAX_LENGTH: - break; - - case GL_PROGRAM_BINARY_LENGTH: - if (context->getClientMajorVersion() < 3 && !context->getExtensions().getProgramBinary) - { - context->handleError(Error(GL_INVALID_ENUM, - "Querying GL_PROGRAM_BINARY_LENGTH requires " - "GL_OES_get_program_binary or ES 3.0.")); - return false; - } - break; - - case GL_ACTIVE_UNIFORM_BLOCKS: - case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: - case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: - case GL_TRANSFORM_FEEDBACK_VARYINGS: - case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: - case GL_PROGRAM_BINARY_RETRIEVABLE_HINT: - if (context->getClientMajorVersion() < 3) - { - context->handleError(Error(GL_INVALID_ENUM, "Querying requires at least ES 3.0.")); - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown parameter name.")); - return false; - } - - return true; -} - -bool ValidateGetProgramivRobustANGLE(Context *context, - GLuint program, - GLenum pname, - GLsizei bufSize, - GLsizei *numParams) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetProgramiv(context, program, pname, numParams)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *numParams)) - { - return false; - } - - return true; -} - -bool ValidateGetRenderbufferParameteriv(Context *context, - GLenum target, - GLenum pname, - GLint *params) -{ - return ValidateGetRenderbufferParameterivBase(context, target, pname, nullptr); -} - -bool ValidateGetRenderbufferParameterivRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetRenderbufferParameterivBase(context, target, pname, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetShaderiv(Context *context, GLuint shader, GLenum pname, GLint *params) -{ - return ValidateGetShaderivBase(context, shader, pname, nullptr); -} - -bool ValidateGetShaderivRobustANGLE(Context *context, - GLuint shader, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetShaderivBase(context, shader, pname, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetTexParameterfv(Context *context, GLenum target, GLenum pname, GLfloat *params) -{ - return ValidateGetTexParameterBase(context, target, pname, nullptr); -} - -bool ValidateGetTexParameterfvRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetTexParameterBase(context, target, pname, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetTexParameteriv(Context *context, GLenum target, GLenum pname, GLint *params) -{ - return ValidateGetTexParameterBase(context, target, pname, nullptr); -} - -bool ValidateGetTexParameterivRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetTexParameterBase(context, target, pname, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateTexParameterf(Context *context, GLenum target, GLenum pname, GLfloat param) -{ - return ValidateTexParameterBase(context, target, pname, -1, ¶m); -} - -bool ValidateTexParameterfv(Context *context, GLenum target, GLenum pname, const GLfloat *params) -{ - return ValidateTexParameterBase(context, target, pname, -1, params); -} - -bool ValidateTexParameterfvRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - const GLfloat *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - return ValidateTexParameterBase(context, target, pname, bufSize, params); -} - -bool ValidateTexParameteri(Context *context, GLenum target, GLenum pname, GLint param) -{ - return ValidateTexParameterBase(context, target, pname, -1, ¶m); -} - -bool ValidateTexParameteriv(Context *context, GLenum target, GLenum pname, const GLint *params) -{ - return ValidateTexParameterBase(context, target, pname, -1, params); -} - -bool ValidateTexParameterivRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - const GLint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - return ValidateTexParameterBase(context, target, pname, bufSize, params); -} - -bool ValidateGetSamplerParameterfv(Context *context, GLuint sampler, GLenum pname, GLfloat *params) -{ - return ValidateGetSamplerParameterBase(context, sampler, pname, nullptr); -} - -bool ValidateGetSamplerParameterfvRobustANGLE(Context *context, - GLuint sampler, - GLenum pname, - GLuint bufSize, - GLsizei *length, - GLfloat *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetSamplerParameterBase(context, sampler, pname, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetSamplerParameteriv(Context *context, GLuint sampler, GLenum pname, GLint *params) -{ - return ValidateGetSamplerParameterBase(context, sampler, pname, nullptr); -} - -bool ValidateGetSamplerParameterivRobustANGLE(Context *context, - GLuint sampler, - GLenum pname, - GLuint bufSize, - GLsizei *length, - GLint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetSamplerParameterBase(context, sampler, pname, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateSamplerParameterf(Context *context, GLuint sampler, GLenum pname, GLfloat param) -{ - return ValidateSamplerParameterBase(context, sampler, pname, -1, ¶m); -} - -bool ValidateSamplerParameterfv(Context *context, - GLuint sampler, - GLenum pname, - const GLfloat *params) -{ - return ValidateSamplerParameterBase(context, sampler, pname, -1, params); -} - -bool ValidateSamplerParameterfvRobustANGLE(Context *context, - GLuint sampler, - GLenum pname, - GLsizei bufSize, - const GLfloat *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - return ValidateSamplerParameterBase(context, sampler, pname, bufSize, params); -} - -bool ValidateSamplerParameteri(Context *context, GLuint sampler, GLenum pname, GLint param) -{ - return ValidateSamplerParameterBase(context, sampler, pname, -1, ¶m); -} - -bool ValidateSamplerParameteriv(Context *context, GLuint sampler, GLenum pname, const GLint *params) -{ - return ValidateSamplerParameterBase(context, sampler, pname, -1, params); -} - -bool ValidateSamplerParameterivRobustANGLE(Context *context, - GLuint sampler, - GLenum pname, - GLsizei bufSize, - const GLint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - return ValidateSamplerParameterBase(context, sampler, pname, bufSize, params); -} - -bool ValidateGetVertexAttribfv(Context *context, GLuint index, GLenum pname, GLfloat *params) -{ - return ValidateGetVertexAttribBase(context, index, pname, nullptr, false, false); -} - -bool ValidateGetVertexAttribfvRobustANGLE(Context *context, - GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetVertexAttribBase(context, index, pname, length, false, false)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetVertexAttribiv(Context *context, GLuint index, GLenum pname, GLint *params) -{ - return ValidateGetVertexAttribBase(context, index, pname, nullptr, false, false); -} - -bool ValidateGetVertexAttribivRobustANGLE(Context *context, - GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetVertexAttribBase(context, index, pname, length, false, false)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetVertexAttribPointerv(Context *context, GLuint index, GLenum pname, void **pointer) -{ - return ValidateGetVertexAttribBase(context, index, pname, nullptr, true, false); -} - -bool ValidateGetVertexAttribPointervRobustANGLE(Context *context, - GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - void **pointer) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetVertexAttribBase(context, index, pname, length, true, false)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetVertexAttribIiv(Context *context, GLuint index, GLenum pname, GLint *params) -{ - return ValidateGetVertexAttribBase(context, index, pname, nullptr, false, true); -} - -bool ValidateGetVertexAttribIivRobustANGLE(Context *context, - GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetVertexAttribBase(context, index, pname, length, false, true)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetVertexAttribIuiv(Context *context, GLuint index, GLenum pname, GLuint *params) -{ - return ValidateGetVertexAttribBase(context, index, pname, nullptr, false, true); -} - -bool ValidateGetVertexAttribIuivRobustANGLE(Context *context, - GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetVertexAttribBase(context, index, pname, length, false, true)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetActiveUniformBlockiv(Context *context, - GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint *params) -{ - return ValidateGetActiveUniformBlockivBase(context, program, uniformBlockIndex, pname, nullptr); -} - -bool ValidateGetActiveUniformBlockivRobustANGLE(Context *context, - GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetActiveUniformBlockivBase(context, program, uniformBlockIndex, pname, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateGetInternalFormativ(Context *context, - GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint *params) -{ - return ValidateGetInternalFormativBase(context, target, internalformat, pname, bufSize, - nullptr); -} - -bool ValidateGetInternalFormativRobustANGLE(Context *context, - GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateGetInternalFormativBase(context, target, internalformat, pname, bufSize, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - } // namespace gl diff --git a/gfx/angle/src/libANGLE/validationES.h b/gfx/angle/src/libANGLE/validationES.h index 06da37690..d42575311 100755 --- a/gfx/angle/src/libANGLE/validationES.h +++ b/gfx/angle/src/libANGLE/validationES.h @@ -29,6 +29,7 @@ class Program; class Shader; class ValidationContext; +bool ValidCap(const Context *context, GLenum cap); bool ValidTextureTarget(const ValidationContext *context, GLenum target); bool ValidTexture2DTarget(const ValidationContext *context, GLenum target); bool ValidTexture3DTarget(const ValidationContext *context, GLenum target); @@ -36,8 +37,8 @@ bool ValidTextureExternalTarget(const ValidationContext *context, GLenum target) bool ValidTexture2DDestinationTarget(const ValidationContext *context, GLenum target); bool ValidTexture3DDestinationTarget(const ValidationContext *context, GLenum target); bool ValidFramebufferTarget(GLenum target); -bool ValidBufferTarget(const ValidationContext *context, GLenum target); -bool ValidBufferParameter(const ValidationContext *context, GLenum pname, GLsizei *numParams); +bool ValidBufferTarget(const Context *context, GLenum target); +bool ValidBufferParameter(const Context *context, GLenum pname); bool ValidMipLevel(const ValidationContext *context, GLenum target, GLint level); bool ValidImageSizeParameters(const Context *context, GLenum target, @@ -50,27 +51,17 @@ bool ValidCompressedImageSize(const ValidationContext *context, GLenum internalFormat, GLsizei width, GLsizei height); -bool ValidImageDataSize(ValidationContext *context, - GLenum textureTarget, - GLsizei width, - GLsizei height, - GLsizei depth, - GLenum internalFormat, - GLenum type, - const GLvoid *pixels, - GLsizei imageSize); - bool ValidQueryType(const Context *context, GLenum queryType); // Returns valid program if id is a valid program name // Errors INVALID_OPERATION if valid shader is given and returns NULL // Errors INVALID_VALUE otherwise and returns NULL -Program *GetValidProgram(ValidationContext *context, GLuint id); +Program *GetValidProgram(Context *context, GLuint id); // Returns valid shader if id is a valid shader name // Errors INVALID_OPERATION if valid program is given and returns NULL // Errors INVALID_VALUE otherwise and returns NULL -Shader *GetValidShader(ValidationContext *context, GLuint id); +Shader *GetValidShader(Context *context, GLuint id); bool ValidateAttachmentTarget(Context *context, GLenum attachment); bool ValidateRenderbufferStorageParametersBase(Context *context, GLenum target, GLsizei samples, @@ -93,6 +84,12 @@ bool ValidateBlitFramebufferParameters(ValidationContext *context, GLbitfield mask, GLenum filter); +bool ValidateGetVertexAttribParameters(Context *context, GLenum pname); + +bool ValidateTexParamParameters(Context *context, GLenum target, GLenum pname, GLint param); + +bool ValidateSamplerObjectParameter(Context *context, GLenum pname); + bool ValidateReadPixels(ValidationContext *context, GLint x, GLint y, @@ -101,16 +98,6 @@ bool ValidateReadPixels(ValidationContext *context, GLenum format, GLenum type, GLvoid *pixels); -bool ValidateReadPixelsRobustANGLE(ValidationContext *context, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - GLsizei *length, - GLvoid *pixels); bool ValidateReadnPixelsEXT(Context *context, GLint x, GLint y, @@ -120,16 +107,6 @@ bool ValidateReadnPixelsEXT(Context *context, GLenum type, GLsizei bufSize, GLvoid *pixels); -bool ValidateReadnPixelsRobustANGLE(ValidationContext *context, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - GLsizei *length, - GLvoid *data); bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n); bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n); @@ -138,46 +115,13 @@ bool ValidateBeginQueryEXT(Context *context, GLenum target, GLuint id); bool ValidateEndQueryBase(Context *context, GLenum target); bool ValidateEndQueryEXT(Context *context, GLenum target); bool ValidateQueryCounterEXT(Context *context, GLuint id, GLenum target); -bool ValidateGetQueryivBase(Context *context, GLenum target, GLenum pname, GLsizei *numParams); +bool ValidateGetQueryivBase(Context *context, GLenum target, GLenum pname); bool ValidateGetQueryivEXT(Context *context, GLenum target, GLenum pname, GLint *params); -bool ValidateGetQueryivRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); -bool ValidateGetQueryObjectValueBase(Context *context, - GLenum target, - GLenum pname, - GLsizei *numParams); +bool ValidateGetQueryObjectValueBase(Context *context, GLenum target, GLenum pname); bool ValidateGetQueryObjectivEXT(Context *context, GLuint id, GLenum pname, GLint *params); -bool ValidateGetQueryObjectivRobustANGLE(Context *context, - GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); bool ValidateGetQueryObjectuivEXT(Context *context, GLuint id, GLenum pname, GLuint *params); -bool ValidateGetQueryObjectuivRobustANGLE(Context *context, - GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint *params); bool ValidateGetQueryObjecti64vEXT(Context *context, GLuint id, GLenum pname, GLint64 *params); -bool ValidateGetQueryObjecti64vRobustANGLE(Context *context, - GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint64 *params); bool ValidateGetQueryObjectui64vEXT(Context *context, GLuint id, GLenum pname, GLuint64 *params); -bool ValidateGetQueryObjectui64vRobustANGLE(Context *context, - GLuint id, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint64 *params); bool ValidateUniform(Context *context, GLenum uniformType, GLint location, GLsizei count); bool ValidateUniformMatrix(Context *context, GLenum matrixType, GLint location, GLsizei count, @@ -188,12 +132,6 @@ bool ValidateStateQuery(ValidationContext *context, GLenum *nativeType, unsigned int *numParams); -bool ValidateRobustStateQuery(ValidationContext *context, - GLenum pname, - GLsizei bufSize, - GLenum *nativeType, - unsigned int *numParams); - bool ValidateCopyTexImageParametersBase(ValidationContext *context, GLenum target, GLint level, @@ -255,24 +193,6 @@ bool ValidateGetUniformfv(Context *context, GLuint program, GLint location, GLfl bool ValidateGetUniformiv(Context *context, GLuint program, GLint location, GLint* params); bool ValidateGetnUniformfvEXT(Context *context, GLuint program, GLint location, GLsizei bufSize, GLfloat* params); bool ValidateGetnUniformivEXT(Context *context, GLuint program, GLint location, GLsizei bufSize, GLint* params); -bool ValidateGetUniformfvRobustANGLE(Context *context, - GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLfloat *params); -bool ValidateGetUniformivRobustANGLE(Context *context, - GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLint *params); -bool ValidateGetUniformuivRobustANGLE(Context *context, - GLuint program, - GLint location, - GLsizei bufSize, - GLsizei *length, - GLuint *params); bool ValidateDiscardFramebufferBase(Context *context, GLenum target, GLsizei numAttachments, const GLenum *attachments, bool defaultFramebuffer); @@ -325,11 +245,7 @@ bool ValidateCopyTexSubImage2D(Context *context, GLsizei width, GLsizei height); -bool ValidateGetBufferPointervBase(Context *context, - GLenum target, - GLenum pname, - GLsizei *length, - void **params); +bool ValidateGetBufferPointervBase(Context *context, GLenum target, GLenum pname, void **params); bool ValidateUnmapBufferBase(Context *context, GLenum target); bool ValidateMapBufferRangeBase(Context *context, GLenum target, @@ -354,206 +270,6 @@ bool ValidateDeleteTextures(Context *context, GLint n, const GLuint *textures); bool ValidateGenOrDelete(Context *context, GLint n); -bool ValidateEnable(Context *context, GLenum cap); -bool ValidateDisable(Context *context, GLenum cap); -bool ValidateIsEnabled(Context *context, GLenum cap); - -bool ValidateRobustEntryPoint(ValidationContext *context, GLsizei bufSize); -bool ValidateRobustBufferSize(ValidationContext *context, GLsizei bufSize, GLsizei numParams); - -bool ValidateGetFramebufferAttachmentParameteriv(ValidationContext *context, - GLenum target, - GLenum attachment, - GLenum pname, - GLsizei *numParams); -bool ValidateGetFramebufferAttachmentParameterivRobustANGLE(ValidationContext *context, - GLenum target, - GLenum attachment, - GLenum pname, - GLsizei bufSize, - GLsizei *numParams); - -bool ValidateGetBufferParameteriv(ValidationContext *context, - GLenum target, - GLenum pname, - GLint *params); -bool ValidateGetBufferParameterivRobustANGLE(ValidationContext *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); - -bool ValidateGetBufferParameteri64v(ValidationContext *context, - GLenum target, - GLenum pname, - GLint64 *params); -bool ValidateGetBufferParameteri64vRobustANGLE(ValidationContext *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint64 *params); - -bool ValidateGetProgramiv(Context *context, GLuint program, GLenum pname, GLsizei *numParams); -bool ValidateGetProgramivRobustANGLE(Context *context, - GLuint program, - GLenum pname, - GLsizei bufSize, - GLsizei *numParams); - -bool ValidateGetRenderbufferParameteriv(Context *context, - GLenum target, - GLenum pname, - GLint *params); -bool ValidateGetRenderbufferParameterivRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); - -bool ValidateGetShaderiv(Context *context, GLuint shader, GLenum pname, GLint *params); -bool ValidateGetShaderivRobustANGLE(Context *context, - GLuint shader, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); - -bool ValidateGetTexParameterfv(Context *context, GLenum target, GLenum pname, GLfloat *params); -bool ValidateGetTexParameterfvRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params); -bool ValidateGetTexParameteriv(Context *context, GLenum target, GLenum pname, GLint *params); -bool ValidateGetTexParameterivRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); - -bool ValidateTexParameterf(Context *context, GLenum target, GLenum pname, GLfloat param); -bool ValidateTexParameterfv(Context *context, GLenum target, GLenum pname, const GLfloat *params); -bool ValidateTexParameterfvRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - const GLfloat *params); -bool ValidateTexParameteri(Context *context, GLenum target, GLenum pname, GLint param); -bool ValidateTexParameteriv(Context *context, GLenum target, GLenum pname, const GLint *params); -bool ValidateTexParameterivRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - const GLint *params); - -bool ValidateGetSamplerParameterfv(Context *context, GLuint sampler, GLenum pname, GLfloat *params); -bool ValidateGetSamplerParameterfvRobustANGLE(Context *context, - GLuint sampler, - GLenum pname, - GLuint bufSize, - GLsizei *length, - GLfloat *params); -bool ValidateGetSamplerParameteriv(Context *context, GLuint sampler, GLenum pname, GLint *params); -bool ValidateGetSamplerParameterivRobustANGLE(Context *context, - GLuint sampler, - GLenum pname, - GLuint bufSize, - GLsizei *length, - GLint *params); - -bool ValidateSamplerParameterf(Context *context, GLuint sampler, GLenum pname, GLfloat param); -bool ValidateSamplerParameterfv(Context *context, - GLuint sampler, - GLenum pname, - const GLfloat *params); -bool ValidateSamplerParameterfvRobustANGLE(Context *context, - GLuint sampler, - GLenum pname, - GLsizei bufSize, - const GLfloat *params); -bool ValidateSamplerParameteri(Context *context, GLuint sampler, GLenum pname, GLint param); -bool ValidateSamplerParameteriv(Context *context, - GLuint sampler, - GLenum pname, - const GLint *params); -bool ValidateSamplerParameterivRobustANGLE(Context *context, - GLuint sampler, - GLenum pname, - GLsizei bufSize, - const GLint *params); - -bool ValidateGetVertexAttribfv(Context *context, GLuint index, GLenum pname, GLfloat *params); -bool ValidateGetVertexAttribfvRobustANGLE(Context *context, - GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLfloat *params); - -bool ValidateGetVertexAttribiv(Context *context, GLuint index, GLenum pname, GLint *params); -bool ValidateGetVertexAttribivRobustANGLE(Context *context, - GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); - -bool ValidateGetVertexAttribPointerv(Context *context, GLuint index, GLenum pname, void **pointer); -bool ValidateGetVertexAttribPointervRobustANGLE(Context *context, - GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - void **pointer); - -bool ValidateGetVertexAttribIiv(Context *context, GLuint index, GLenum pname, GLint *params); -bool ValidateGetVertexAttribIivRobustANGLE(Context *context, - GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); - -bool ValidateGetVertexAttribIuiv(Context *context, GLuint index, GLenum pname, GLuint *params); -bool ValidateGetVertexAttribIuivRobustANGLE(Context *context, - GLuint index, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLuint *params); - -bool ValidateGetActiveUniformBlockiv(Context *context, - GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint *params); -bool ValidateGetActiveUniformBlockivRobustANGLE(Context *context, - GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); - -bool ValidateGetInternalFormativ(Context *context, - GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint *params); -bool ValidateGetInternalFormativRobustANGLE(Context *context, - GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLint *params); - // Error messages shared here for use in testing. extern const char *g_ExceedsMaxElementErrorMessage; } // namespace gl diff --git a/gfx/angle/src/libANGLE/validationES2.cpp b/gfx/angle/src/libANGLE/validationES2.cpp index 3133102f3..f68958cba 100755 --- a/gfx/angle/src/libANGLE/validationES2.cpp +++ b/gfx/angle/src/libANGLE/validationES2.cpp @@ -10,19 +10,19 @@ #include <cstdint> -#include "common/mathutil.h" -#include "common/string_utils.h" -#include "common/utilities.h" +#include "libANGLE/validationES.h" +#include "libANGLE/validationES3.h" #include "libANGLE/Context.h" #include "libANGLE/Texture.h" #include "libANGLE/Framebuffer.h" -#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/Renderbuffer.h" -#include "libANGLE/Shader.h" -#include "libANGLE/Uniform.h" #include "libANGLE/formatutils.h" -#include "libANGLE/validationES.h" -#include "libANGLE/validationES3.h" +#include "libANGLE/FramebufferAttachment.h" +#include "libANGLE/Uniform.h" + +#include "common/mathutil.h" +#include "common/string_utils.h" +#include "common/utilities.h" namespace gl { @@ -285,21 +285,9 @@ bool IsValidCopyTextureSourceTarget(Context *context, GLenum target) } // anonymous namespace -bool ValidateES2TexImageParameters(Context *context, - GLenum target, - GLint level, - GLenum internalformat, - bool isCompressed, - bool isSubImage, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - GLsizei imageSize, - const GLvoid *pixels) +bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, GLenum internalformat, bool isCompressed, bool isSubImage, + GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, const GLvoid *pixels) { if (!ValidTexture2DDestinationTarget(context, target)) { @@ -368,16 +356,10 @@ bool ValidateES2TexImageParameters(Context *context, if (isSubImage) { - GLenum textureFormat = texture->getFormat(target, level).asSized(); - if (textureFormat == GL_NONE) - { - context->handleError(Error(GL_INVALID_OPERATION, "Texture level does not exist.")); - return false; - } - if (format != GL_NONE) { - if (gl::GetSizedInternalFormat(format, type) != textureFormat) + if (gl::GetSizedInternalFormat(format, type) != + texture->getFormat(target, level).asSized()) { context->handleError(Error(GL_INVALID_OPERATION)); return false; @@ -710,12 +692,6 @@ bool ValidateES2TexImageParameters(Context *context, } } - if (!ValidImageDataSize(context, target, width, height, 1, internalformat, type, pixels, - imageSize)) - { - return false; - } - return true; } @@ -1217,6 +1193,52 @@ bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei le return true; } +// check for combinations of format and type that are valid for ReadPixels +bool ValidES2ReadFormatType(ValidationContext *context, GLenum format, GLenum type) +{ + switch (format) + { + case GL_RGBA: + switch (type) + { + case GL_UNSIGNED_BYTE: + break; + default: + return false; + } + break; + case GL_BGRA_EXT: + switch (type) + { + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: + case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: + break; + default: + return false; + } + break; + case GL_RG_EXT: + case GL_RED_EXT: + if (!context->getExtensions().textureRG) + { + return false; + } + switch (type) + { + case GL_UNSIGNED_BYTE: + break; + default: + return false; + } + break; + + default: + return false; + } + return true; +} + bool ValidateDiscardFramebufferEXT(Context *context, GLenum target, GLsizei numAttachments, const GLenum *attachments) { @@ -1992,43 +2014,12 @@ bool ValidateTexImage2D(Context *context, if (context->getClientMajorVersion() < 3) { return ValidateES2TexImageParameters(context, target, level, internalformat, false, false, - 0, 0, width, height, border, format, type, -1, pixels); + 0, 0, width, height, border, format, type, pixels); } ASSERT(context->getClientMajorVersion() >= 3); return ValidateES3TexImage2DParameters(context, target, level, internalformat, false, false, 0, - 0, 0, width, height, 1, border, format, type, -1, - pixels); -} - -bool ValidateTexImage2DRobust(Context *context, - GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - GLsizei bufSize, - const GLvoid *pixels) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (context->getClientMajorVersion() < 3) - { - return ValidateES2TexImageParameters(context, target, level, internalformat, false, false, - 0, 0, width, height, border, format, type, bufSize, - pixels); - } - - ASSERT(context->getClientMajorVersion() >= 3); - return ValidateES3TexImage2DParameters(context, target, level, internalformat, false, false, 0, - 0, 0, width, height, 1, border, format, type, bufSize, - pixels); + 0, 0, width, height, 1, border, format, type, pixels); } bool ValidateTexSubImage2D(Context *context, @@ -2046,43 +2037,12 @@ bool ValidateTexSubImage2D(Context *context, if (context->getClientMajorVersion() < 3) { return ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, xoffset, - yoffset, width, height, 0, format, type, -1, pixels); + yoffset, width, height, 0, format, type, pixels); } ASSERT(context->getClientMajorVersion() >= 3); return ValidateES3TexImage2DParameters(context, target, level, GL_NONE, false, true, xoffset, - yoffset, 0, width, height, 1, 0, format, type, -1, - pixels); -} - -bool ValidateTexSubImage2DRobustANGLE(Context *context, - GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - const GLvoid *pixels) -{ - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (context->getClientMajorVersion() < 3) - { - return ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, xoffset, - yoffset, width, height, 0, format, type, bufSize, - pixels); - } - - ASSERT(context->getClientMajorVersion() >= 3); - return ValidateES3TexImage2DParameters(context, target, level, GL_NONE, false, true, xoffset, - yoffset, 0, width, height, 1, 0, format, type, bufSize, - pixels); + yoffset, 0, width, height, 1, 0, format, type, pixels); } bool ValidateCompressedTexImage2D(Context *context, @@ -2098,7 +2058,7 @@ bool ValidateCompressedTexImage2D(Context *context, if (context->getClientMajorVersion() < 3) { if (!ValidateES2TexImageParameters(context, target, level, internalformat, true, false, 0, - 0, width, height, border, GL_NONE, GL_NONE, -1, data)) + 0, width, height, border, GL_NONE, GL_NONE, data)) { return false; } @@ -2107,7 +2067,7 @@ bool ValidateCompressedTexImage2D(Context *context, { ASSERT(context->getClientMajorVersion() >= 3); if (!ValidateES3TexImage2DParameters(context, target, level, internalformat, true, false, 0, - 0, 0, width, height, 1, border, GL_NONE, GL_NONE, -1, + 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data)) { return false; @@ -2116,7 +2076,7 @@ bool ValidateCompressedTexImage2D(Context *context, const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat); auto blockSizeOrErr = - formatInfo.computeCompressedImageSize(gl::Extents(width, height, 1)); + formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, 1)); if (blockSizeOrErr.isError()) { context->handleError(blockSizeOrErr.getError()); @@ -2146,7 +2106,7 @@ bool ValidateCompressedTexSubImage2D(Context *context, if (context->getClientMajorVersion() < 3) { if (!ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true, xoffset, - yoffset, width, height, 0, GL_NONE, GL_NONE, -1, data)) + yoffset, width, height, 0, GL_NONE, GL_NONE, data)) { return false; } @@ -2155,7 +2115,7 @@ bool ValidateCompressedTexSubImage2D(Context *context, { ASSERT(context->getClientMajorVersion() >= 3); if (!ValidateES3TexImage2DParameters(context, target, level, GL_NONE, true, true, xoffset, - yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, -1, + yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data)) { return false; @@ -2164,7 +2124,7 @@ bool ValidateCompressedTexSubImage2D(Context *context, const InternalFormat &formatInfo = GetInternalFormatInfo(format); auto blockSizeOrErr = - formatInfo.computeCompressedImageSize(gl::Extents(width, height, 1)); + formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, 1)); if (blockSizeOrErr.isError()) { context->handleError(blockSizeOrErr.getError()); @@ -2182,7 +2142,13 @@ bool ValidateCompressedTexSubImage2D(Context *context, bool ValidateGetBufferPointervOES(Context *context, GLenum target, GLenum pname, void **params) { - return ValidateGetBufferPointervBase(context, target, pname, nullptr, params); + if (!context->getExtensions().mapBuffer) + { + context->handleError(Error(GL_INVALID_OPERATION, "Map buffer extension not available.")); + return false; + } + + return ValidateGetBufferPointervBase(context, target, pname, params); } bool ValidateMapBufferOES(Context *context, GLenum target, GLenum access) @@ -2273,13 +2239,6 @@ bool ValidateBindTexture(Context *context, GLenum target, GLuint texture) return false; } - if (!context->getGLState().isBindGeneratesResourceEnabled() && - !context->isTextureGenerated(texture)) - { - context->handleError(Error(GL_INVALID_OPERATION, "Texture was not generated")); - return false; - } - switch (target) { case GL_TEXTURE_2D: @@ -3356,68 +3315,6 @@ bool ValidateCopySubTextureCHROMIUM(Context *context, return true; } -bool ValidateCompressedCopyTextureCHROMIUM(Context *context, GLuint sourceId, GLuint destId) -{ - if (!context->getExtensions().copyCompressedTexture) - { - context->handleError(Error(GL_INVALID_OPERATION, - "GL_CHROMIUM_copy_compressed_texture extension not available.")); - return false; - } - - const gl::Texture *source = context->getTexture(sourceId); - if (source == nullptr) - { - context->handleError( - Error(GL_INVALID_VALUE, "Source texture is not a valid texture object.")); - return false; - } - - if (source->getTarget() != GL_TEXTURE_2D) - { - context->handleError( - Error(GL_INVALID_VALUE, "Source texture must be of type GL_TEXTURE_2D.")); - return false; - } - - if (source->getWidth(GL_TEXTURE_2D, 0) == 0 || source->getHeight(GL_TEXTURE_2D, 0) == 0) - { - context->handleError(Error(GL_INVALID_VALUE, "Source texture must level 0 defined.")); - return false; - } - - const gl::Format &sourceFormat = source->getFormat(GL_TEXTURE_2D, 0); - if (!sourceFormat.info->compressed) - { - context->handleError( - Error(GL_INVALID_OPERATION, "Source texture must have a compressed internal format.")); - return false; - } - - const gl::Texture *dest = context->getTexture(destId); - if (dest == nullptr) - { - context->handleError( - Error(GL_INVALID_VALUE, "Destination texture is not a valid texture object.")); - return false; - } - - if (dest->getTarget() != GL_TEXTURE_2D) - { - context->handleError( - Error(GL_INVALID_VALUE, "Destination texture must be of type GL_TEXTURE_2D.")); - return false; - } - - if (dest->getImmutableFormat()) - { - context->handleError(Error(GL_INVALID_OPERATION, "Destination cannot be immutable.")); - return false; - } - - return true; -} - bool ValidateCreateShader(Context *context, GLenum type) { switch (type) @@ -3425,442 +3322,15 @@ bool ValidateCreateShader(Context *context, GLenum type) case GL_VERTEX_SHADER: case GL_FRAGMENT_SHADER: break; - case GL_COMPUTE_SHADER: - if (context->getClientVersion() < Version(3, 1)) - { - context->handleError( - Error(GL_INVALID_ENUM, "GL_COMPUTE_SHADER requires OpenGL ES 3.1.")); - return false; - } - break; - - default: - context->handleError(Error(GL_INVALID_ENUM, "Unknown shader type.")); - return false; - } - - return true; -} - -bool ValidateBufferData(ValidationContext *context, - GLenum target, - GLsizeiptr size, - const GLvoid *data, - GLenum usage) -{ - if (size < 0) - { - context->handleError(Error(GL_INVALID_VALUE)); - return false; - } - - switch (usage) - { - case GL_STREAM_DRAW: - case GL_STATIC_DRAW: - case GL_DYNAMIC_DRAW: - break; - - case GL_STREAM_READ: - case GL_STREAM_COPY: - case GL_STATIC_READ: - case GL_STATIC_COPY: - case GL_DYNAMIC_READ: - case GL_DYNAMIC_COPY: - if (context->getClientMajorVersion() < 3) + if (context->getGLVersion().isES31()) { - context->handleError(Error(GL_INVALID_ENUM)); - return false; + break; } - break; - default: context->handleError(Error(GL_INVALID_ENUM)); return false; } - - if (!ValidBufferTarget(context, target)) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - - Buffer *buffer = context->getGLState().getTargetBuffer(target); - - if (!buffer) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - - return true; -} - -bool ValidateBufferSubData(ValidationContext *context, - GLenum target, - GLintptr offset, - GLsizeiptr size, - const GLvoid *data) -{ - if (size < 0 || offset < 0) - { - context->handleError(Error(GL_INVALID_VALUE)); - return false; - } - - if (!ValidBufferTarget(context, target)) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - - Buffer *buffer = context->getGLState().getTargetBuffer(target); - - if (!buffer) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - - if (buffer->isMapped()) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - - // Check for possible overflow of size + offset - angle::CheckedNumeric<size_t> checkedSize(size); - checkedSize += offset; - if (!checkedSize.IsValid()) - { - context->handleError(Error(GL_OUT_OF_MEMORY)); - return false; - } - - if (size + offset > buffer->getSize()) - { - context->handleError(Error(GL_INVALID_VALUE)); - return false; - } - - return true; -} - -bool ValidateEnableExtensionANGLE(ValidationContext *context, const GLchar *name) -{ - if (!context->getExtensions().webglCompatibility) - { - context->handleError( - Error(GL_INVALID_OPERATION, "GL_ANGLE_webgl_compatibility is not available.")); - return false; - } - - const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); - auto extension = extensionInfos.find(name); - if (extension == extensionInfos.end() || !extension->second.Enableable) - { - context->handleError(Error(GL_INVALID_OPERATION, "Extension %s is not enableable.", name)); - return false; - } - - return true; -} - -bool ValidateActiveTexture(ValidationContext *context, GLenum texture) -{ - if (texture < GL_TEXTURE0 || - texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1) - { - context->handleError(Error(GL_INVALID_ENUM)); - return false; - } - - return true; -} - -bool ValidateAttachShader(ValidationContext *context, GLuint program, GLuint shader) -{ - Program *programObject = GetValidProgram(context, program); - if (!programObject) - { - return false; - } - - Shader *shaderObject = GetValidShader(context, shader); - if (!shaderObject) - { - return false; - } - - switch (shaderObject->getType()) - { - case GL_VERTEX_SHADER: - { - if (programObject->getAttachedVertexShader()) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - break; - } - case GL_FRAGMENT_SHADER: - { - if (programObject->getAttachedFragmentShader()) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - break; - } - case GL_COMPUTE_SHADER: - { - if (programObject->getAttachedComputeShader()) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - break; - } - default: - UNREACHABLE(); - break; - } - - return true; -} - -bool ValidateBindAttribLocation(ValidationContext *context, - GLuint program, - GLuint index, - const GLchar *name) -{ - if (index >= MAX_VERTEX_ATTRIBS) - { - context->handleError(Error(GL_INVALID_VALUE, "Index exceeds MAX_VERTEX_ATTRIBS")); - return false; - } - - if (strncmp(name, "gl_", 3) == 0) - { - context->handleError(Error(GL_INVALID_OPERATION, "Cannot Bind built-in attributes")); - return false; - } - - return GetValidProgram(context, program) != nullptr; -} - -bool ValidateBindBuffer(ValidationContext *context, GLenum target, GLuint buffer) -{ - if (!ValidBufferTarget(context, target)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid Buffer target")); - return false; - } - - if (!context->getGLState().isBindGeneratesResourceEnabled() && - !context->isBufferGenerated(buffer)) - { - context->handleError(Error(GL_INVALID_OPERATION, "Buffer was not generated")); - return false; - } - - return true; -} - -bool ValidateBindFramebuffer(ValidationContext *context, GLenum target, GLuint framebuffer) -{ - if (!ValidFramebufferTarget(target)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid Framebuffer target")); - return false; - } - - if (!context->getGLState().isBindGeneratesResourceEnabled() && - !context->isFramebufferGenerated(framebuffer)) - { - context->handleError(Error(GL_INVALID_OPERATION, "Framebuffer was not generated")); - return false; - } - - return true; -} - -bool ValidateBindRenderbuffer(ValidationContext *context, GLenum target, GLuint renderbuffer) -{ - if (target != GL_RENDERBUFFER) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid Renderbuffer target")); - return false; - } - - if (!context->getGLState().isBindGeneratesResourceEnabled() && - !context->isRenderbufferGenerated(renderbuffer)) - { - context->handleError(Error(GL_INVALID_OPERATION, "Renderbuffer was not generated")); - return false; - } - - return true; -} - -static bool ValidBlendEquationMode(GLenum mode) -{ - switch (mode) - { - case GL_FUNC_ADD: - case GL_FUNC_SUBTRACT: - case GL_FUNC_REVERSE_SUBTRACT: - case GL_MIN: - case GL_MAX: - return true; - - default: - return false; - } -} - -bool ValidateBlendEquation(ValidationContext *context, GLenum mode) -{ - if (!ValidBlendEquationMode(mode)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid blend equation")); - return false; - } - - return true; -} - -bool ValidateBlendEquationSeparate(ValidationContext *context, GLenum modeRGB, GLenum modeAlpha) -{ - if (!ValidBlendEquationMode(modeRGB)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid RGB blend equation")); - return false; - } - - if (!ValidBlendEquationMode(modeAlpha)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid alpha blend equation")); - return false; - } - - return true; -} - -bool ValidateBlendFunc(ValidationContext *context, GLenum sfactor, GLenum dfactor) -{ - return ValidateBlendFuncSeparate(context, sfactor, dfactor, sfactor, dfactor); -} - -static bool ValidSrcBlendFunc(GLenum srcBlend) -{ - switch (srcBlend) - { - case GL_ZERO: - case GL_ONE: - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - case GL_DST_COLOR: - case GL_ONE_MINUS_DST_COLOR: - case GL_SRC_ALPHA: - case GL_ONE_MINUS_SRC_ALPHA: - case GL_DST_ALPHA: - case GL_ONE_MINUS_DST_ALPHA: - case GL_CONSTANT_COLOR: - case GL_ONE_MINUS_CONSTANT_COLOR: - case GL_CONSTANT_ALPHA: - case GL_ONE_MINUS_CONSTANT_ALPHA: - case GL_SRC_ALPHA_SATURATE: - return true; - - default: - return false; - } -} - -static bool ValidDstBlendFunc(GLenum dstBlend, GLint contextMajorVersion) -{ - switch (dstBlend) - { - case GL_ZERO: - case GL_ONE: - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - case GL_DST_COLOR: - case GL_ONE_MINUS_DST_COLOR: - case GL_SRC_ALPHA: - case GL_ONE_MINUS_SRC_ALPHA: - case GL_DST_ALPHA: - case GL_ONE_MINUS_DST_ALPHA: - case GL_CONSTANT_COLOR: - case GL_ONE_MINUS_CONSTANT_COLOR: - case GL_CONSTANT_ALPHA: - case GL_ONE_MINUS_CONSTANT_ALPHA: - return true; - - case GL_SRC_ALPHA_SATURATE: - return (contextMajorVersion >= 3); - - default: - return false; - } -} - -bool ValidateBlendFuncSeparate(ValidationContext *context, - GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha) -{ - if (!ValidSrcBlendFunc(srcRGB)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid blend function")); - return false; - } - - if (!ValidDstBlendFunc(dstRGB, context->getClientMajorVersion())) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid blend function")); - return false; - } - - if (!ValidSrcBlendFunc(srcAlpha)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid blend function")); - return false; - } - - if (!ValidDstBlendFunc(dstAlpha, context->getClientMajorVersion())) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid blend function")); - return false; - } - - if (context->getLimitations().noSimultaneousConstantColorAndAlphaBlendFunc) - { - bool constantColorUsed = - (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || - dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); - - bool constantAlphaUsed = - (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || - dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); - - if (constantColorUsed && constantAlphaUsed) - { - ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and " - "GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR not supported by this " - "implementation."); - context->handleError(Error(GL_INVALID_OPERATION, - "Simultaneous use of " - "GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and " - "GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR not " - "supported by this implementation.")); - return false; - } - } - return true; } diff --git a/gfx/angle/src/libANGLE/validationES2.h b/gfx/angle/src/libANGLE/validationES2.h index d40a62606..09451f4c2 100755 --- a/gfx/angle/src/libANGLE/validationES2.h +++ b/gfx/angle/src/libANGLE/validationES2.h @@ -18,21 +18,9 @@ class Context; class ValidationContext; class Texture; -bool ValidateES2TexImageParameters(Context *context, - GLenum target, - GLint level, - GLenum internalformat, - bool isCompressed, - bool isSubImage, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - GLsizei imageSize, - const GLvoid *pixels); +bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, GLenum internalformat, bool isCompressed, bool isSubImage, + GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, const GLvoid *pixels); bool ValidateES2CopyTexImageParameters(ValidationContext *context, GLenum target, @@ -50,6 +38,8 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +bool ValidES2ReadFormatType(ValidationContext *context, GLenum format, GLenum type); + bool ValidateDiscardFramebufferEXT(Context *context, GLenum target, GLsizei numAttachments, const GLenum *attachments); @@ -149,17 +139,6 @@ bool ValidateTexImage2D(Context *context, GLenum format, GLenum type, const GLvoid *pixels); -bool ValidateTexImage2DRobust(Context *context, - GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - GLsizei bufSize, - const GLvoid *pixels); bool ValidateTexSubImage2D(Context *context, GLenum target, GLint level, @@ -170,17 +149,6 @@ bool ValidateTexSubImage2D(Context *context, GLenum format, GLenum type, const GLvoid *pixels); -bool ValidateTexSubImage2DRobustANGLE(Context *context, - GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - const GLvoid *pixels); bool ValidateCompressedTexImage2D(Context *context, GLenum target, GLint level, @@ -336,39 +304,8 @@ bool ValidateCopySubTextureCHROMIUM(Context *context, GLboolean unpackFlipY, GLboolean unpackPremultiplyAlpha, GLboolean unpackUnmultiplyAlpha); -bool ValidateCompressedCopyTextureCHROMIUM(Context *context, GLuint sourceId, GLuint destId); bool ValidateCreateShader(Context *context, GLenum type); -bool ValidateBufferData(ValidationContext *context, - GLenum target, - GLsizeiptr size, - const GLvoid *data, - GLenum usage); -bool ValidateBufferSubData(ValidationContext *context, - GLenum target, - GLintptr offset, - GLsizeiptr size, - const GLvoid *data); - -bool ValidateEnableExtensionANGLE(ValidationContext *context, const GLchar *name); - -bool ValidateActiveTexture(ValidationContext *context, GLenum texture); -bool ValidateAttachShader(ValidationContext *context, GLuint program, GLuint shader); -bool ValidateBindAttribLocation(ValidationContext *context, - GLuint program, - GLuint index, - const GLchar *name); -bool ValidateBindBuffer(ValidationContext *context, GLenum target, GLuint buffer); -bool ValidateBindFramebuffer(ValidationContext *context, GLenum target, GLuint framebuffer); -bool ValidateBindRenderbuffer(ValidationContext *context, GLenum target, GLuint renderbuffer); -bool ValidateBlendEquation(ValidationContext *context, GLenum mode); -bool ValidateBlendEquationSeparate(ValidationContext *context, GLenum modeRGB, GLenum modeAlpha); -bool ValidateBlendFunc(ValidationContext *context, GLenum sfactor, GLenum dfactor); -bool ValidateBlendFuncSeparate(ValidationContext *context, - GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha); } // namespace gl diff --git a/gfx/angle/src/libANGLE/validationES3.cpp b/gfx/angle/src/libANGLE/validationES3.cpp index a4cb71e6a..6f3d8002a 100755 --- a/gfx/angle/src/libANGLE/validationES3.cpp +++ b/gfx/angle/src/libANGLE/validationES3.cpp @@ -8,9 +8,6 @@ #include "libANGLE/validationES3.h" -#include "base/numerics/safe_conversions.h" -#include "common/mathutil.h" -#include "common/utilities.h" #include "libANGLE/validationES.h" #include "libANGLE/Context.h" #include "libANGLE/Texture.h" @@ -19,11 +16,209 @@ #include "libANGLE/formatutils.h" #include "libANGLE/FramebufferAttachment.h" +#include "common/mathutil.h" +#include "common/utilities.h" + using namespace angle; namespace gl { +struct ES3FormatCombination +{ + GLenum internalFormat; + GLenum format; + GLenum type; +}; + +bool operator<(const ES3FormatCombination& a, const ES3FormatCombination& b) +{ + return memcmp(&a, &b, sizeof(ES3FormatCombination)) < 0; +} + +typedef std::set<ES3FormatCombination> ES3FormatCombinationSet; + +static inline void InsertES3FormatCombo(ES3FormatCombinationSet *set, GLenum internalFormat, GLenum format, GLenum type) +{ + ES3FormatCombination info; + info.internalFormat = internalFormat; + info.format = format; + info.type = type; + set->insert(info); +} + +ES3FormatCombinationSet BuildES3FormatSet() +{ + ES3FormatCombinationSet set; + + // Format combinations from ES 3.0.1 spec, table 3.2 + + // clang-format off + // | Internal format | Format | Type | + // | | | | + InsertES3FormatCombo(&set, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RGBA4, GL_RGBA, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RGBA8_SNORM, GL_RGBA, GL_BYTE ); + InsertES3FormatCombo(&set, GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 ); + InsertES3FormatCombo(&set, GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV ); + InsertES3FormatCombo(&set, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV ); + InsertES3FormatCombo(&set, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 ); + InsertES3FormatCombo(&set, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_RGBA32F, GL_RGBA, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_RGBA16F, GL_RGBA, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE ); + InsertES3FormatCombo(&set, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT ); + InsertES3FormatCombo(&set, GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT ); + InsertES3FormatCombo(&set, GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT ); + InsertES3FormatCombo(&set, GL_RGBA32I, GL_RGBA_INTEGER, GL_INT ); + InsertES3FormatCombo(&set, GL_RGB10_A2UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV ); + InsertES3FormatCombo(&set, GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RGB565, GL_RGB, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RGB8_SNORM, GL_RGB, GL_BYTE ); + InsertES3FormatCombo(&set, GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 ); + InsertES3FormatCombo(&set, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV ); + InsertES3FormatCombo(&set, GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV ); + InsertES3FormatCombo(&set, GL_RGB16F, GL_RGB, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_RGB16F, GL_RGB, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_R11F_G11F_B10F, GL_RGB, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_R11F_G11F_B10F, GL_RGB, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_RGB9_E5, GL_RGB, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_RGB9_E5, GL_RGB, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_RGB32F, GL_RGB, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_RGB16F, GL_RGB, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_R11F_G11F_B10F, GL_RGB, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_RGB9_E5, GL_RGB, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RGB8I, GL_RGB_INTEGER, GL_BYTE ); + InsertES3FormatCombo(&set, GL_RGB16UI, GL_RGB_INTEGER, GL_UNSIGNED_SHORT ); + InsertES3FormatCombo(&set, GL_RGB16I, GL_RGB_INTEGER, GL_SHORT ); + InsertES3FormatCombo(&set, GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT ); + InsertES3FormatCombo(&set, GL_RGB32I, GL_RGB_INTEGER, GL_INT ); + InsertES3FormatCombo(&set, GL_RG8, GL_RG, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RG8_SNORM, GL_RG, GL_BYTE ); + InsertES3FormatCombo(&set, GL_RG16F, GL_RG, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_RG16F, GL_RG, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_RG32F, GL_RG, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_RG16F, GL_RG, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RG8I, GL_RG_INTEGER, GL_BYTE ); + InsertES3FormatCombo(&set, GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT ); + InsertES3FormatCombo(&set, GL_RG16I, GL_RG_INTEGER, GL_SHORT ); + InsertES3FormatCombo(&set, GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT ); + InsertES3FormatCombo(&set, GL_RG32I, GL_RG_INTEGER, GL_INT ); + InsertES3FormatCombo(&set, GL_R8, GL_RED, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_R8_SNORM, GL_RED, GL_BYTE ); + InsertES3FormatCombo(&set, GL_R16F, GL_RED, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_R16F, GL_RED, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_R32F, GL_RED, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_R16F, GL_RED, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_R8I, GL_RED_INTEGER, GL_BYTE ); + InsertES3FormatCombo(&set, GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT ); + InsertES3FormatCombo(&set, GL_R16I, GL_RED_INTEGER, GL_SHORT ); + InsertES3FormatCombo(&set, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT ); + InsertES3FormatCombo(&set, GL_R32I, GL_RED_INTEGER, GL_INT ); + + // Unsized formats + InsertES3FormatCombo(&set, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 ); + InsertES3FormatCombo(&set, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 ); + InsertES3FormatCombo(&set, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 ); + InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_SRGB_ALPHA_EXT, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_SRGB_EXT, GL_SRGB_EXT, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RG, GL_RG, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RG, GL_RG, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_RG, GL_RG, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_RG, GL_RG, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_RED, GL_RED, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_RED, GL_RED, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_RED, GL_RED, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_RED, GL_RED, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_DEPTH_STENCIL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8 ); + + // Depth stencil formats + InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT ); + InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT ); + InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT ); + InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8 ); + InsertES3FormatCombo(&set, GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + + // From GL_EXT_sRGB + InsertES3FormatCombo(&set, GL_SRGB8_ALPHA8_EXT, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_SRGB8, GL_SRGB_EXT, GL_UNSIGNED_BYTE ); + + // From GL_OES_texture_float + InsertES3FormatCombo(&set, GL_RGBA, GL_RGBA, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_RGB, GL_RGB, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_LUMINANCE, GL_LUMINANCE, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_ALPHA, GL_ALPHA, GL_FLOAT ); + + // From GL_OES_texture_half_float + InsertES3FormatCombo(&set, GL_RGBA, GL_RGBA, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_RGB, GL_RGB, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_LUMINANCE, GL_LUMINANCE, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_LUMINANCE, GL_LUMINANCE, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_ALPHA, GL_ALPHA, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_ALPHA, GL_ALPHA, GL_HALF_FLOAT_OES ); + + // From GL_EXT_texture_format_BGRA8888 + InsertES3FormatCombo(&set, GL_BGRA_EXT, GL_BGRA_EXT, GL_UNSIGNED_BYTE ); + + // From GL_EXT_texture_storage + // | Internal format | Format | Type | + // | | | | + InsertES3FormatCombo(&set, GL_ALPHA8_EXT, GL_ALPHA, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_LUMINANCE8_EXT, GL_LUMINANCE, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_LUMINANCE8_ALPHA8_EXT, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_ALPHA32F_EXT, GL_ALPHA, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_LUMINANCE32F_EXT, GL_LUMINANCE, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA32F_EXT, GL_LUMINANCE_ALPHA, GL_FLOAT ); + InsertES3FormatCombo(&set, GL_ALPHA16F_EXT, GL_ALPHA, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_ALPHA16F_EXT, GL_ALPHA, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_LUMINANCE16F_EXT, GL_LUMINANCE, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_LUMINANCE16F_EXT, GL_LUMINANCE, GL_HALF_FLOAT_OES ); + InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT ); + InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES ); + + // From GL_EXT_texture_storage and GL_EXT_texture_format_BGRA8888 + InsertES3FormatCombo(&set, GL_BGRA8_EXT, GL_BGRA_EXT, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_BGRA4_ANGLEX, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT); + InsertES3FormatCombo(&set, GL_BGRA4_ANGLEX, GL_BGRA_EXT, GL_UNSIGNED_BYTE ); + InsertES3FormatCombo(&set, GL_BGR5_A1_ANGLEX, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT); + InsertES3FormatCombo(&set, GL_BGR5_A1_ANGLEX, GL_BGRA_EXT, GL_UNSIGNED_BYTE ); + + // From GL_ANGLE_depth_texture and OES_depth_texture + InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT32_OES, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT_24_8_OES ); + InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT ); + InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT ); + + // From GL_EXT_texture_norm16 + InsertES3FormatCombo(&set, GL_R16_EXT, GL_RED, GL_UNSIGNED_SHORT); + InsertES3FormatCombo(&set, GL_RG16_EXT, GL_RG, GL_UNSIGNED_SHORT); + InsertES3FormatCombo(&set, GL_RGB16_EXT, GL_RGB, GL_UNSIGNED_SHORT); + InsertES3FormatCombo(&set, GL_RGBA16_EXT, GL_RGBA, GL_UNSIGNED_SHORT); + InsertES3FormatCombo(&set, GL_R16_SNORM_EXT, GL_RED, GL_SHORT); + InsertES3FormatCombo(&set, GL_RG16_SNORM_EXT, GL_RG, GL_SHORT); + InsertES3FormatCombo(&set, GL_RGB16_SNORM_EXT, GL_RGB, GL_SHORT); + InsertES3FormatCombo(&set, GL_RGBA16_SNORM_EXT, GL_RGBA, GL_SHORT); + // clang-format on + + return set; +} + static bool ValidateTexImageFormatCombination(gl::Context *context, GLenum internalFormat, GLenum format, GLenum type) { // For historical reasons, glTexImage2D and glTexImage3D pass in their internal format as a @@ -31,21 +226,54 @@ static bool ValidateTexImageFormatCombination(gl::Context *context, GLenum inter // error instead of a GL_INVALID_ENUM error. As this validation function is only called in // the validation codepaths for glTexImage2D/3D, we record a GL_INVALID_VALUE error. const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat); - if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) + if (!formatInfo.textureSupport(context->getClientMajorVersion(), context->getExtensions())) { context->handleError(Error(GL_INVALID_VALUE)); return false; } // The type and format are valid if any supported internal format has that type and format - if (!ValidES3Format(format) || !ValidES3Type(type)) + bool formatSupported = false; + bool typeSupported = false; + + static const ES3FormatCombinationSet es3FormatSet = BuildES3FormatSet(); + for (ES3FormatCombinationSet::const_iterator i = es3FormatSet.begin(); i != es3FormatSet.end(); i++) + { + if (i->format == format || i->type == type) + { + const gl::InternalFormat &info = gl::GetInternalFormatInfo(i->internalFormat); + bool supported = + info.textureSupport(context->getClientMajorVersion(), context->getExtensions()); + if (supported && i->type == type) + { + typeSupported = true; + } + if (supported && i->format == format) + { + formatSupported = true; + } + + // Early-out if both type and format are supported now + if (typeSupported && formatSupported) + { + break; + } + } + } + + if (!typeSupported || !formatSupported) { context->handleError(Error(GL_INVALID_ENUM)); return false; } // Check if this is a valid format combination to load texture data - if (!ValidES3FormatCombination(format, type, internalFormat)) + ES3FormatCombination searchFormat; + searchFormat.internalFormat = internalFormat; + searchFormat.format = format; + searchFormat.type = type; + + if (es3FormatSet.find(searchFormat) == es3FormatSet.end()) { context->handleError(Error(GL_INVALID_OPERATION)); return false; @@ -69,7 +297,6 @@ bool ValidateES3TexImageParametersBase(Context *context, GLint border, GLenum format, GLenum type, - GLsizei imageSize, const GLvoid *pixels) { // Validate image size @@ -168,12 +395,6 @@ bool ValidateES3TexImageParametersBase(Context *context, // Validate texture formats GLenum actualInternalFormat = isSubImage ? texture->getFormat(target, level).asSized() : internalformat; - if (isSubImage && actualInternalFormat == GL_NONE) - { - context->handleError(Error(GL_INVALID_OPERATION, "Texture level does not exist.")); - return false; - } - const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(actualInternalFormat); if (isCompressed) { @@ -190,7 +411,8 @@ bool ValidateES3TexImageParametersBase(Context *context, return false; } - if (!actualFormatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) + if (!actualFormatInfo.textureSupport(context->getClientMajorVersion(), + context->getExtensions())) { context->handleError(Error(GL_INVALID_ENUM)); return false; @@ -253,27 +475,70 @@ bool ValidateES3TexImageParametersBase(Context *context, } } - if (!ValidImageDataSize(context, target, width, height, 1, actualInternalFormat, type, pixels, - imageSize)) - { - return false; - } - // Check for pixel unpack buffer related API errors gl::Buffer *pixelUnpackBuffer = context->getGLState().getTargetBuffer(GL_PIXEL_UNPACK_BUFFER); - if (pixelUnpackBuffer != nullptr) + if (pixelUnpackBuffer != NULL) { + // ...the data would be unpacked from the buffer object such that the memory reads required + // would exceed the data store size. + GLenum sizedFormat = GetSizedInternalFormat(actualInternalFormat, type); + const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(sizedFormat); + const gl::Extents size(width, height, depth); + const auto &unpack = context->getGLState().getUnpackState(); + + auto copyBytesOrErr = formatInfo.computeUnpackSize(type, size, unpack); + if (copyBytesOrErr.isError()) + { + context->handleError(copyBytesOrErr.getError()); + return false; + } + CheckedNumeric<size_t> checkedCopyBytes(copyBytesOrErr.getResult()); + CheckedNumeric<size_t> checkedOffset(reinterpret_cast<size_t>(pixels)); + checkedCopyBytes += checkedOffset; + + auto rowPitchOrErr = + formatInfo.computeRowPitch(type, width, unpack.alignment, unpack.rowLength); + if (rowPitchOrErr.isError()) + { + context->handleError(rowPitchOrErr.getError()); + return false; + } + auto depthPitchOrErr = formatInfo.computeDepthPitch(type, width, height, unpack.alignment, + unpack.rowLength, unpack.imageHeight); + if (depthPitchOrErr.isError()) + { + context->handleError(depthPitchOrErr.getError()); + return false; + } + + bool targetIs3D = target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY; + auto skipBytesOrErr = formatInfo.computeSkipBytes( + rowPitchOrErr.getResult(), depthPitchOrErr.getResult(), unpack.skipImages, + unpack.skipRows, unpack.skipPixels, targetIs3D); + if (skipBytesOrErr.isError()) + { + context->handleError(skipBytesOrErr.getError()); + return false; + } + checkedCopyBytes += skipBytesOrErr.getResult(); + + if (!checkedCopyBytes.IsValid() || + (checkedCopyBytes.ValueOrDie() > static_cast<size_t>(pixelUnpackBuffer->getSize()))) + { + // Overflow past the end of the buffer + context->handleError(Error(GL_INVALID_OPERATION)); + return false; + } + // ...data is not evenly divisible into the number of bytes needed to store in memory a datum // indicated by type. if (!isCompressed) { - size_t offset = reinterpret_cast<size_t>(pixels); size_t dataBytesPerPixel = static_cast<size_t>(gl::GetTypeInfo(type).bytes); - if ((offset % dataBytesPerPixel) != 0) + if ((checkedOffset.ValueOrDie() % dataBytesPerPixel) != 0) { - context->handleError( - Error(GL_INVALID_OPERATION, "Reads would overflow the pixel unpack buffer.")); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -281,7 +546,7 @@ bool ValidateES3TexImageParametersBase(Context *context, // ...the buffer object's data store is currently mapped. if (pixelUnpackBuffer->isMapped()) { - context->handleError(Error(GL_INVALID_OPERATION, "Pixel unpack buffer is mapped.")); + context->handleError(Error(GL_INVALID_OPERATION)); return false; } } @@ -304,7 +569,6 @@ bool ValidateES3TexImage2DParameters(Context *context, GLint border, GLenum format, GLenum type, - GLsizei imageSize, const GLvoid *pixels) { if (!ValidTexture2DDestinationTarget(context, target)) @@ -315,7 +579,7 @@ bool ValidateES3TexImage2DParameters(Context *context, return ValidateES3TexImageParametersBase(context, target, level, internalformat, isCompressed, isSubImage, xoffset, yoffset, zoffset, width, height, - depth, border, format, type, imageSize, pixels); + depth, border, format, type, pixels); } bool ValidateES3TexImage3DParameters(Context *context, @@ -333,7 +597,6 @@ bool ValidateES3TexImage3DParameters(Context *context, GLint border, GLenum format, GLenum type, - GLsizei bufSize, const GLvoid *pixels) { if (!ValidTexture3DDestinationTarget(context, target)) @@ -344,115 +607,169 @@ bool ValidateES3TexImage3DParameters(Context *context, return ValidateES3TexImageParametersBase(context, target, level, internalformat, isCompressed, isSubImage, xoffset, yoffset, zoffset, width, height, - depth, border, format, type, bufSize, pixels); + depth, border, format, type, pixels); } struct EffectiveInternalFormatInfo { - GLenum effectiveFormat; - GLenum destFormat; - GLuint minRedBits; - GLuint maxRedBits; - GLuint minGreenBits; - GLuint maxGreenBits; - GLuint minBlueBits; - GLuint maxBlueBits; - GLuint minAlphaBits; - GLuint maxAlphaBits; + GLenum mEffectiveFormat; + GLenum mDestFormat; + GLuint mMinRedBits; + GLuint mMaxRedBits; + GLuint mMinGreenBits; + GLuint mMaxGreenBits; + GLuint mMinBlueBits; + GLuint mMaxBlueBits; + GLuint mMinAlphaBits; + GLuint mMaxAlphaBits; + + EffectiveInternalFormatInfo(GLenum effectiveFormat, GLenum destFormat, GLuint minRedBits, GLuint maxRedBits, + GLuint minGreenBits, GLuint maxGreenBits, GLuint minBlueBits, GLuint maxBlueBits, + GLuint minAlphaBits, GLuint maxAlphaBits) + : mEffectiveFormat(effectiveFormat), mDestFormat(destFormat), mMinRedBits(minRedBits), + mMaxRedBits(maxRedBits), mMinGreenBits(minGreenBits), mMaxGreenBits(maxGreenBits), + mMinBlueBits(minBlueBits), mMaxBlueBits(maxBlueBits), mMinAlphaBits(minAlphaBits), + mMaxAlphaBits(maxAlphaBits) {}; }; -static bool QueryEffectiveFormatList(const InternalFormat &srcFormat, - GLenum targetFormat, - const EffectiveInternalFormatInfo *list, - size_t size, - GLenum *outEffectiveFormat) -{ - for (size_t curFormat = 0; curFormat < size; ++curFormat) - { - const EffectiveInternalFormatInfo &formatInfo = list[curFormat]; - if ((formatInfo.destFormat == targetFormat) && - (formatInfo.minRedBits <= srcFormat.redBits && - formatInfo.maxRedBits >= srcFormat.redBits) && - (formatInfo.minGreenBits <= srcFormat.greenBits && - formatInfo.maxGreenBits >= srcFormat.greenBits) && - (formatInfo.minBlueBits <= srcFormat.blueBits && - formatInfo.maxBlueBits >= srcFormat.blueBits) && - (formatInfo.minAlphaBits <= srcFormat.alphaBits && - formatInfo.maxAlphaBits >= srcFormat.alphaBits)) - { - *outEffectiveFormat = formatInfo.effectiveFormat; - return true; - } - } +typedef std::vector<EffectiveInternalFormatInfo> EffectiveInternalFormatList; - *outEffectiveFormat = GL_NONE; - return false; -} - -bool GetSizedEffectiveInternalFormatInfo(const InternalFormat &srcFormat, - GLenum *outEffectiveFormat) +static EffectiveInternalFormatList BuildSizedEffectiveInternalFormatList() { - // OpenGL ES 3.0.3 Specification, Table 3.17, pg 141: - // Effective internal format coresponding to destination internal format and linear source - // buffer component sizes. - // | Source channel min/max sizes | - // Effective Internal Format | N/A | R | G | B | A | - // clang-format off - constexpr EffectiveInternalFormatInfo list[] = { - { GL_ALPHA8_EXT, GL_NONE, 0, 0, 0, 0, 0, 0, 1, 8 }, - { GL_R8, GL_NONE, 1, 8, 0, 0, 0, 0, 0, 0 }, - { GL_RG8, GL_NONE, 1, 8, 1, 8, 0, 0, 0, 0 }, - { GL_RGB565, GL_NONE, 1, 5, 1, 6, 1, 5, 0, 0 }, - { GL_RGB8, GL_NONE, 6, 8, 7, 8, 6, 8, 0, 0 }, - { GL_RGBA4, GL_NONE, 1, 4, 1, 4, 1, 4, 1, 4 }, - { GL_RGB5_A1, GL_NONE, 5, 5, 5, 5, 5, 5, 1, 1 }, - { GL_RGBA8, GL_NONE, 5, 8, 5, 8, 5, 8, 2, 8 }, - { GL_RGB10_A2, GL_NONE, 9, 10, 9, 10, 9, 10, 2, 2 }, - }; - // clang-format on + EffectiveInternalFormatList list; - return QueryEffectiveFormatList(srcFormat, GL_NONE, list, ArraySize(list), outEffectiveFormat); + // OpenGL ES 3.0.3 Specification, Table 3.17, pg 141: Effective internal format coresponding to destination internal format and + // linear source buffer component sizes. + // | Source channel min/max sizes | + // Effective Internal Format | N/A | R | G | B | A | + list.push_back(EffectiveInternalFormatInfo(GL_ALPHA8_EXT, GL_NONE, 0, 0, 0, 0, 0, 0, 1, 8)); + list.push_back(EffectiveInternalFormatInfo(GL_R8, GL_NONE, 1, 8, 0, 0, 0, 0, 0, 0)); + list.push_back(EffectiveInternalFormatInfo(GL_RG8, GL_NONE, 1, 8, 1, 8, 0, 0, 0, 0)); + list.push_back(EffectiveInternalFormatInfo(GL_RGB565, GL_NONE, 1, 5, 1, 6, 1, 5, 0, 0)); + list.push_back(EffectiveInternalFormatInfo(GL_RGB8, GL_NONE, 6, 8, 7, 8, 6, 8, 0, 0)); + list.push_back(EffectiveInternalFormatInfo(GL_RGBA4, GL_NONE, 1, 4, 1, 4, 1, 4, 1, 4)); + list.push_back(EffectiveInternalFormatInfo(GL_RGB5_A1, GL_NONE, 5, 5, 5, 5, 5, 5, 1, 1)); + list.push_back(EffectiveInternalFormatInfo(GL_RGBA8, GL_NONE, 5, 8, 5, 8, 5, 8, 2, 8)); + list.push_back(EffectiveInternalFormatInfo(GL_RGB10_A2, GL_NONE, 9, 10, 9, 10, 9, 10, 2, 2)); + + return list; } -bool GetUnsizedEffectiveInternalFormatInfo(const InternalFormat &srcFormat, - const InternalFormat &destFormat, - GLenum *outEffectiveFormat) +static EffectiveInternalFormatList BuildUnsizedEffectiveInternalFormatList() { - constexpr GLuint umax = UINT_MAX; + EffectiveInternalFormatList list; - // OpenGL ES 3.0.3 Specification, Table 3.17, pg 141: - // Effective internal format coresponding to destination internal format andlinear source buffer - // component sizes. - // | Source channel min/max sizes | - // Effective Internal Format | Dest Format | R | G | B | A | - // clang-format off - constexpr EffectiveInternalFormatInfo list[] = { - { GL_ALPHA8_EXT, GL_ALPHA, 0, umax, 0, umax, 0, umax, 1, 8 }, - { GL_LUMINANCE8_EXT, GL_LUMINANCE, 1, 8, 0, umax, 0, umax, 0, umax }, - { GL_LUMINANCE8_ALPHA8_EXT, GL_LUMINANCE_ALPHA, 1, 8, 0, umax, 0, umax, 1, 8 }, - { GL_RGB565, GL_RGB, 1, 5, 1, 6, 1, 5, 0, umax }, - { GL_RGB8, GL_RGB, 6, 8, 7, 8, 6, 8, 0, umax }, - { GL_RGBA4, GL_RGBA, 1, 4, 1, 4, 1, 4, 1, 4 }, - { GL_RGB5_A1, GL_RGBA, 5, 5, 5, 5, 5, 5, 1, 1 }, - { GL_RGBA8, GL_RGBA, 5, 8, 5, 8, 5, 8, 5, 8 }, - }; - // clang-format on + // OpenGL ES 3.0.3 Specification, Table 3.17, pg 141: Effective internal format coresponding to destination internal format and + // linear source buffer component sizes. + // | Source channel min/max sizes | + // Effective Internal Format | Dest Format | R | G | B | A | + list.push_back(EffectiveInternalFormatInfo(GL_ALPHA8_EXT, GL_ALPHA, 0, UINT_MAX, 0, UINT_MAX, 0, UINT_MAX, 1, 8)); + list.push_back(EffectiveInternalFormatInfo(GL_LUMINANCE8_EXT, GL_LUMINANCE, 1, 8, 0, UINT_MAX, 0, UINT_MAX, 0, UINT_MAX)); + list.push_back(EffectiveInternalFormatInfo(GL_LUMINANCE8_ALPHA8_EXT, GL_LUMINANCE_ALPHA, 1, 8, 0, UINT_MAX, 0, UINT_MAX, 1, 8)); + list.push_back(EffectiveInternalFormatInfo(GL_RGB565, GL_RGB, 1, 5, 1, 6, 1, 5, 0, UINT_MAX)); + list.push_back(EffectiveInternalFormatInfo(GL_RGB8, GL_RGB, 6, 8, 7, 8, 6, 8, 0, UINT_MAX)); + list.push_back(EffectiveInternalFormatInfo(GL_RGBA4, GL_RGBA, 1, 4, 1, 4, 1, 4, 1, 4)); + list.push_back(EffectiveInternalFormatInfo(GL_RGB5_A1, GL_RGBA, 5, 5, 5, 5, 5, 5, 1, 1)); + list.push_back(EffectiveInternalFormatInfo(GL_RGBA8, GL_RGBA, 5, 8, 5, 8, 5, 8, 5, 8)); - return QueryEffectiveFormatList(srcFormat, destFormat.format, list, ArraySize(list), - outEffectiveFormat); + return list; } static bool GetEffectiveInternalFormat(const InternalFormat &srcFormat, const InternalFormat &destFormat, GLenum *outEffectiveFormat) { + const EffectiveInternalFormatList *list = NULL; + GLenum targetFormat = GL_NONE; + if (destFormat.pixelBytes > 0) { - return GetSizedEffectiveInternalFormatInfo(srcFormat, outEffectiveFormat); + static const EffectiveInternalFormatList sizedList = BuildSizedEffectiveInternalFormatList(); + list = &sizedList; } else { - return GetUnsizedEffectiveInternalFormatInfo(srcFormat, destFormat, outEffectiveFormat); + static const EffectiveInternalFormatList unsizedList = BuildUnsizedEffectiveInternalFormatList(); + list = &unsizedList; + targetFormat = destFormat.format; } + + for (size_t curFormat = 0; curFormat < list->size(); ++curFormat) + { + const EffectiveInternalFormatInfo& formatInfo = list->at(curFormat); + if ((formatInfo.mDestFormat == targetFormat) && + (formatInfo.mMinRedBits <= srcFormat.redBits && formatInfo.mMaxRedBits >= srcFormat.redBits) && + (formatInfo.mMinGreenBits <= srcFormat.greenBits && formatInfo.mMaxGreenBits >= srcFormat.greenBits) && + (formatInfo.mMinBlueBits <= srcFormat.blueBits && formatInfo.mMaxBlueBits >= srcFormat.blueBits) && + (formatInfo.mMinAlphaBits <= srcFormat.alphaBits && formatInfo.mMaxAlphaBits >= srcFormat.alphaBits)) + { + *outEffectiveFormat = formatInfo.mEffectiveFormat; + return true; + } + } + + return false; +} + +struct CopyConversion +{ + GLenum mTextureFormat; + GLenum mFramebufferFormat; + + CopyConversion(GLenum textureFormat, GLenum framebufferFormat) + : mTextureFormat(textureFormat), mFramebufferFormat(framebufferFormat) { } + + bool operator<(const CopyConversion& other) const + { + return memcmp(this, &other, sizeof(CopyConversion)) < 0; + } +}; + +typedef std::set<CopyConversion> CopyConversionSet; + +static CopyConversionSet BuildValidES3CopyTexImageCombinations() +{ + CopyConversionSet set; + + // From ES 3.0.1 spec, table 3.15 + set.insert(CopyConversion(GL_ALPHA, GL_RGBA)); + set.insert(CopyConversion(GL_LUMINANCE, GL_RED)); + set.insert(CopyConversion(GL_LUMINANCE, GL_RG)); + set.insert(CopyConversion(GL_LUMINANCE, GL_RGB)); + set.insert(CopyConversion(GL_LUMINANCE, GL_RGBA)); + set.insert(CopyConversion(GL_LUMINANCE_ALPHA, GL_RGBA)); + set.insert(CopyConversion(GL_RED, GL_RED)); + set.insert(CopyConversion(GL_RED, GL_RG)); + set.insert(CopyConversion(GL_RED, GL_RGB)); + set.insert(CopyConversion(GL_RED, GL_RGBA)); + set.insert(CopyConversion(GL_RG, GL_RG)); + set.insert(CopyConversion(GL_RG, GL_RGB)); + set.insert(CopyConversion(GL_RG, GL_RGBA)); + set.insert(CopyConversion(GL_RGB, GL_RGB)); + set.insert(CopyConversion(GL_RGB, GL_RGBA)); + set.insert(CopyConversion(GL_RGBA, GL_RGBA)); + + // Necessary for ANGLE back-buffers + set.insert(CopyConversion(GL_ALPHA, GL_BGRA_EXT)); + set.insert(CopyConversion(GL_LUMINANCE, GL_BGRA_EXT)); + set.insert(CopyConversion(GL_LUMINANCE_ALPHA, GL_BGRA_EXT)); + set.insert(CopyConversion(GL_RED, GL_BGRA_EXT)); + set.insert(CopyConversion(GL_RG, GL_BGRA_EXT)); + set.insert(CopyConversion(GL_RGB, GL_BGRA_EXT)); + set.insert(CopyConversion(GL_RGBA, GL_BGRA_EXT)); + set.insert(CopyConversion(GL_BGRA_EXT, GL_BGRA_EXT)); + + set.insert(CopyConversion(GL_RED_INTEGER, GL_RED_INTEGER)); + set.insert(CopyConversion(GL_RED_INTEGER, GL_RG_INTEGER)); + set.insert(CopyConversion(GL_RED_INTEGER, GL_RGB_INTEGER)); + set.insert(CopyConversion(GL_RED_INTEGER, GL_RGBA_INTEGER)); + set.insert(CopyConversion(GL_RG_INTEGER, GL_RG_INTEGER)); + set.insert(CopyConversion(GL_RG_INTEGER, GL_RGB_INTEGER)); + set.insert(CopyConversion(GL_RG_INTEGER, GL_RGBA_INTEGER)); + set.insert(CopyConversion(GL_RGB_INTEGER, GL_RGB_INTEGER)); + set.insert(CopyConversion(GL_RGB_INTEGER, GL_RGBA_INTEGER)); + set.insert(CopyConversion(GL_RGBA_INTEGER, GL_RGBA_INTEGER)); + + return set; } static bool EqualOrFirstZero(GLuint first, GLuint second) @@ -467,129 +784,129 @@ static bool IsValidES3CopyTexImageCombination(const Format &textureFormat, const auto &textureFormatInfo = *textureFormat.info; const auto &framebufferFormatInfo = *framebufferFormat.info; - if (!ValidES3CopyConversion(textureFormatInfo.format, framebufferFormatInfo.format)) + static const CopyConversionSet conversionSet = BuildValidES3CopyTexImageCombinations(); + if (conversionSet.find(CopyConversion(textureFormatInfo.format, + framebufferFormatInfo.format)) != conversionSet.end()) { - return false; - } - - // Section 3.8.5 of the GLES 3.0.3 spec states that source and destination formats - // must both be signed, unsigned, or fixed point and both source and destinations - // must be either both SRGB or both not SRGB. EXT_color_buffer_float adds allowed - // conversion between fixed and floating point. + // Section 3.8.5 of the GLES 3.0.3 spec states that source and destination formats + // must both be signed, unsigned, or fixed point and both source and destinations + // must be either both SRGB or both not SRGB. EXT_color_buffer_float adds allowed + // conversion between fixed and floating point. - if ((textureFormatInfo.colorEncoding == GL_SRGB) != - (framebufferFormatInfo.colorEncoding == GL_SRGB)) - { - return false; - } - - if (((textureFormatInfo.componentType == GL_INT) != - (framebufferFormatInfo.componentType == GL_INT)) || - ((textureFormatInfo.componentType == GL_UNSIGNED_INT) != - (framebufferFormatInfo.componentType == GL_UNSIGNED_INT))) - { - return false; - } - - if ((textureFormatInfo.componentType == GL_UNSIGNED_NORMALIZED || - textureFormatInfo.componentType == GL_SIGNED_NORMALIZED || - textureFormatInfo.componentType == GL_FLOAT) && - !(framebufferFormatInfo.componentType == GL_UNSIGNED_NORMALIZED || - framebufferFormatInfo.componentType == GL_SIGNED_NORMALIZED || - framebufferFormatInfo.componentType == GL_FLOAT)) - { - return false; - } + if ((textureFormatInfo.colorEncoding == GL_SRGB) != + (framebufferFormatInfo.colorEncoding == GL_SRGB)) + { + return false; + } - // GLES specification 3.0.3, sec 3.8.5, pg 139-140: - // The effective internal format of the source buffer is determined with the following rules - // applied in order: - // * If the source buffer is a texture or renderbuffer that was created with a sized internal - // format then the effective internal format is the source buffer's sized internal format. - // * If the source buffer is a texture that was created with an unsized base internal format, - // then the effective internal format is the source image array's effective internal - // format, as specified by table 3.12, which is determined from the <format> and <type> - // that were used when the source image array was specified by TexImage*. - // * Otherwise the effective internal format is determined by the row in table 3.17 or 3.18 - // where Destination Internal Format matches internalformat and where the [source channel - // sizes] are consistent with the values of the source buffer's [channel sizes]. Table 3.17 - // is used if the FRAMEBUFFER_ATTACHMENT_ENCODING is LINEAR and table 3.18 is used if the - // FRAMEBUFFER_ATTACHMENT_ENCODING is SRGB. - const InternalFormat *sourceEffectiveFormat = NULL; - if (readBufferHandle != 0) - { - // Not the default framebuffer, therefore the read buffer must be a user-created texture or - // renderbuffer - if (framebufferFormat.sized) + if (((textureFormatInfo.componentType == GL_INT) != + (framebufferFormatInfo.componentType == GL_INT)) || + ((textureFormatInfo.componentType == GL_UNSIGNED_INT) != + (framebufferFormatInfo.componentType == GL_UNSIGNED_INT))) { - sourceEffectiveFormat = &framebufferFormatInfo; + return false; } - else + + if ((textureFormatInfo.componentType == GL_UNSIGNED_NORMALIZED || + textureFormatInfo.componentType == GL_SIGNED_NORMALIZED || + textureFormatInfo.componentType == GL_FLOAT) && + !(framebufferFormatInfo.componentType == GL_UNSIGNED_NORMALIZED || + framebufferFormatInfo.componentType == GL_SIGNED_NORMALIZED || + framebufferFormatInfo.componentType == GL_FLOAT)) { - // Renderbuffers cannot be created with an unsized internal format, so this must be an - // unsized-format texture. We can use the same table we use when creating textures to - // get its effective sized format. - GLenum sizedInternalFormat = - GetSizedInternalFormat(framebufferFormatInfo.format, framebufferFormatInfo.type); - sourceEffectiveFormat = &GetInternalFormatInfo(sizedInternalFormat); + return false; } - } - else - { - // The effective internal format must be derived from the source framebuffer's channel - // sizes. This is done in GetEffectiveInternalFormat for linear buffers (table 3.17) - if (framebufferFormatInfo.colorEncoding == GL_LINEAR) + + // GLES specification 3.0.3, sec 3.8.5, pg 139-140: + // The effective internal format of the source buffer is determined with the following rules applied in order: + // * If the source buffer is a texture or renderbuffer that was created with a sized internal format then the + // effective internal format is the source buffer's sized internal format. + // * If the source buffer is a texture that was created with an unsized base internal format, then the + // effective internal format is the source image array's effective internal format, as specified by table + // 3.12, which is determined from the <format> and <type> that were used when the source image array was + // specified by TexImage*. + // * Otherwise the effective internal format is determined by the row in table 3.17 or 3.18 where + // Destination Internal Format matches internalformat and where the [source channel sizes] are consistent + // with the values of the source buffer's [channel sizes]. Table 3.17 is used if the + // FRAMEBUFFER_ATTACHMENT_ENCODING is LINEAR and table 3.18 is used if the FRAMEBUFFER_ATTACHMENT_ENCODING + // is SRGB. + const InternalFormat *sourceEffectiveFormat = NULL; + if (readBufferHandle != 0) { - GLenum effectiveFormat; - if (GetEffectiveInternalFormat(framebufferFormatInfo, textureFormatInfo, - &effectiveFormat)) + // Not the default framebuffer, therefore the read buffer must be a user-created texture or renderbuffer + if (framebufferFormat.sized) { - sourceEffectiveFormat = &GetInternalFormatInfo(effectiveFormat); + sourceEffectiveFormat = &framebufferFormatInfo; } else { - return false; + // Renderbuffers cannot be created with an unsized internal format, so this must be an unsized-format + // texture. We can use the same table we use when creating textures to get its effective sized format. + GLenum sizedInternalFormat = GetSizedInternalFormat(framebufferFormatInfo.format, + framebufferFormatInfo.type); + sourceEffectiveFormat = &GetInternalFormatInfo(sizedInternalFormat); } } - else if (framebufferFormatInfo.colorEncoding == GL_SRGB) + else { - // SRGB buffers can only be copied to sized format destinations according to table 3.18 - if (textureFormat.sized && - (framebufferFormatInfo.redBits >= 1 && framebufferFormatInfo.redBits <= 8) && - (framebufferFormatInfo.greenBits >= 1 && framebufferFormatInfo.greenBits <= 8) && - (framebufferFormatInfo.blueBits >= 1 && framebufferFormatInfo.blueBits <= 8) && - (framebufferFormatInfo.alphaBits >= 1 && framebufferFormatInfo.alphaBits <= 8)) + // The effective internal format must be derived from the source framebuffer's channel sizes. + // This is done in GetEffectiveInternalFormat for linear buffers (table 3.17) + if (framebufferFormatInfo.colorEncoding == GL_LINEAR) { - sourceEffectiveFormat = &GetInternalFormatInfo(GL_SRGB8_ALPHA8); + GLenum effectiveFormat; + if (GetEffectiveInternalFormat(framebufferFormatInfo, textureFormatInfo, + &effectiveFormat)) + { + sourceEffectiveFormat = &GetInternalFormatInfo(effectiveFormat); + } + else + { + return false; + } + } + else if (framebufferFormatInfo.colorEncoding == GL_SRGB) + { + // SRGB buffers can only be copied to sized format destinations according to table 3.18 + if (textureFormat.sized && + (framebufferFormatInfo.redBits >= 1 && framebufferFormatInfo.redBits <= 8) && + (framebufferFormatInfo.greenBits >= 1 && + framebufferFormatInfo.greenBits <= 8) && + (framebufferFormatInfo.blueBits >= 1 && framebufferFormatInfo.blueBits <= 8) && + (framebufferFormatInfo.alphaBits >= 1 && framebufferFormatInfo.alphaBits <= 8)) + { + sourceEffectiveFormat = &GetInternalFormatInfo(GL_SRGB8_ALPHA8); + } + else + { + return false; + } } else { + UNREACHABLE(); return false; } } - else - { - UNREACHABLE(); - return false; - } - } - if (textureFormat.sized) - { - // Section 3.8.5 of the GLES 3.0.3 spec, pg 139, requires that, if the destination format is - // sized, component sizes of the source and destination formats must exactly match if the - // destination format exists. - if (!EqualOrFirstZero(textureFormatInfo.redBits, sourceEffectiveFormat->redBits) || - !EqualOrFirstZero(textureFormatInfo.greenBits, sourceEffectiveFormat->greenBits) || - !EqualOrFirstZero(textureFormatInfo.blueBits, sourceEffectiveFormat->blueBits) || - !EqualOrFirstZero(textureFormatInfo.alphaBits, sourceEffectiveFormat->alphaBits)) + if (textureFormat.sized) { - return false; + // Section 3.8.5 of the GLES 3.0.3 spec, pg 139, requires that, if the destination + // format is sized, component sizes of the source and destination formats must exactly + // match if the destination format exists. + if (!EqualOrFirstZero(textureFormatInfo.redBits, sourceEffectiveFormat->redBits) || + !EqualOrFirstZero(textureFormatInfo.greenBits, sourceEffectiveFormat->greenBits) || + !EqualOrFirstZero(textureFormatInfo.blueBits, sourceEffectiveFormat->blueBits) || + !EqualOrFirstZero(textureFormatInfo.alphaBits, sourceEffectiveFormat->alphaBits)) + { + return false; + } } + + return true; // A conversion function exists, and no rule in the specification has precluded conversion + // between these formats. } - return true; // A conversion function exists, and no rule in the specification has precluded - // conversion between these formats. + return false; } bool ValidateES3CopyTexImageParametersBase(ValidationContext *context, @@ -808,7 +1125,7 @@ bool ValidateES3TexStorageParametersBase(Context *context, } const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat); - if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) + if (!formatInfo.textureSupport(context->getClientMajorVersion(), context->getExtensions())) { context->handleError(Error(GL_INVALID_ENUM)); return false; @@ -889,7 +1206,7 @@ bool ValidateGetQueryiv(Context *context, GLenum target, GLenum pname, GLint *pa return false; } - return ValidateGetQueryivBase(context, target, pname, nullptr); + return ValidateGetQueryivBase(context, target, pname); } bool ValidateGetQueryObjectuiv(Context *context, GLuint id, GLenum pname, GLuint *params) @@ -900,7 +1217,7 @@ bool ValidateGetQueryObjectuiv(Context *context, GLuint id, GLenum pname, GLuint return false; } - return ValidateGetQueryObjectValueBase(context, id, pname, nullptr); + return ValidateGetQueryObjectValueBase(context, id, pname); } bool ValidateFramebufferTextureLayer(Context *context, GLenum target, GLenum attachment, @@ -979,6 +1296,100 @@ bool ValidateFramebufferTextureLayer(Context *context, GLenum target, GLenum att return true; } +bool ValidES3ReadFormatType(ValidationContext *context, + GLenum internalFormat, + GLenum format, + GLenum type) +{ + const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat); + + switch (format) + { + case GL_RGBA: + switch (type) + { + case GL_UNSIGNED_BYTE: + break; + case GL_UNSIGNED_SHORT: + if (internalFormatInfo.componentType != GL_UNSIGNED_NORMALIZED && + internalFormatInfo.type != GL_UNSIGNED_SHORT) + { + return false; + } + break; + case GL_UNSIGNED_INT_2_10_10_10_REV: + if (internalFormat != GL_RGB10_A2) + { + return false; + } + break; + case GL_FLOAT: + if (internalFormatInfo.componentType != GL_FLOAT) + { + return false; + } + break; + default: + return false; + } + break; + case GL_RGBA_INTEGER: + switch (type) + { + case GL_INT: + if (internalFormatInfo.componentType != GL_INT) + { + return false; + } + break; + case GL_UNSIGNED_INT: + if (internalFormatInfo.componentType != GL_UNSIGNED_INT) + { + return false; + } + break; + default: + return false; + } + break; + case GL_BGRA_EXT: + switch (type) + { + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: + case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: + break; + default: + return false; + } + break; + case GL_RG_EXT: + case GL_RED_EXT: + if (!context->getExtensions().textureRG) + { + return false; + } + switch (type) + { + case GL_UNSIGNED_BYTE: + break; + case GL_UNSIGNED_SHORT: + if (internalFormatInfo.componentType != GL_UNSIGNED_NORMALIZED && + internalFormatInfo.type != GL_UNSIGNED_SHORT) + { + return false; + } + break; + default: + return false; + } + break; + default: + return false; + } + return true; +} + bool ValidateES3RenderbufferStorageParameters(gl::Context *context, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) { @@ -1191,7 +1602,7 @@ bool ValidateCompressedTexImage3D(Context *context, } auto blockSizeOrErr = - formatInfo.computeCompressedImageSize(gl::Extents(width, height, depth)); + formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, depth)); if (blockSizeOrErr.isError()) { context->handleError(Error(GL_INVALID_VALUE)); @@ -1213,8 +1624,7 @@ bool ValidateCompressedTexImage3D(Context *context, // validateES3TexImageFormat sets the error code if there is an error if (!ValidateES3TexImage3DParameters(context, target, level, internalformat, true, false, 0, 0, - 0, width, height, depth, border, GL_NONE, GL_NONE, -1, - data)) + 0, width, height, depth, border, GL_NONE, GL_NONE, data)) { return false; } @@ -1492,37 +1902,8 @@ bool ValidateTexImage3D(Context *context, } return ValidateES3TexImage3DParameters(context, target, level, internalformat, false, false, 0, - 0, 0, width, height, depth, border, format, type, -1, - pixels); -} - -bool ValidateTexImage3DRobustANGLE(Context *context, - GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - GLsizei bufSize, - const GLvoid *pixels) -{ - if (context->getClientMajorVersion() < 3) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - return ValidateES3TexImage3DParameters(context, target, level, internalformat, false, false, 0, 0, 0, width, height, depth, border, format, type, - bufSize, pixels); + pixels); } bool ValidateTexSubImage3D(Context *context, @@ -1546,37 +1927,7 @@ bool ValidateTexSubImage3D(Context *context, return ValidateES3TexImage3DParameters(context, target, level, GL_NONE, false, true, xoffset, yoffset, zoffset, width, height, depth, 0, format, type, - -1, pixels); -} - -bool ValidateTexSubImage3DRobustANGLE(Context *context, - GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLsizei width, - GLsizei height, - GLsizei depth, - GLenum format, - GLenum type, - GLsizei bufSize, - const GLvoid *pixels) -{ - if (context->getClientMajorVersion() < 3) - { - context->handleError(Error(GL_INVALID_OPERATION)); - return false; - } - - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - return ValidateES3TexImage3DParameters(context, target, level, GL_NONE, false, true, xoffset, - yoffset, zoffset, width, height, depth, 0, format, type, - bufSize, pixels); + pixels); } bool ValidateCompressedTexSubImage3D(Context *context, @@ -1600,7 +1951,7 @@ bool ValidateCompressedTexSubImage3D(Context *context, const InternalFormat &formatInfo = GetInternalFormatInfo(format); auto blockSizeOrErr = - formatInfo.computeCompressedImageSize(gl::Extents(width, height, depth)); + formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, depth)); if (blockSizeOrErr.isError()) { context->handleError(blockSizeOrErr.getError()); @@ -1619,7 +1970,7 @@ bool ValidateCompressedTexSubImage3D(Context *context, } return ValidateES3TexImage3DParameters(context, target, level, GL_NONE, true, true, 0, 0, 0, - width, height, depth, 0, GL_NONE, GL_NONE, -1, data); + width, height, depth, 0, GL_NONE, GL_NONE, data); } bool ValidateGenQueries(Context *context, GLint n, GLuint *) @@ -1732,36 +2083,50 @@ bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode) return true; } -bool ValidateGetBufferPointerv(Context *context, GLenum target, GLenum pname, GLvoid **params) -{ - return ValidateGetBufferPointervBase(context, target, pname, nullptr, params); -} - -bool ValidateGetBufferPointervRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLvoid **params) +bool ValidateSamplerParameteri(Context *context, GLuint sampler, GLenum pname, GLint param) { - if (!ValidateRobustEntryPoint(context, bufSize)) + if (context->getClientMajorVersion() < 3) { + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); return false; } - if (!ValidateGetBufferPointervBase(context, target, pname, length, params)) + if (!context->isSampler(sampler)) { + context->handleError(Error(GL_INVALID_OPERATION)); return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateSamplerObjectParameter(context, pname)) { return false; } + if (!ValidateTexParamParameters(context, GL_TEXTURE_2D, pname, param)) + { + return false; + } return true; } +bool ValidateSamplerParameterf(Context *context, GLuint sampler, GLenum pname, GLfloat param) +{ + // The only float parameters are MIN_LOD and MAX_LOD. For these any value is permissible, so + // ValidateSamplerParameteri can be used for validation here. + return ValidateSamplerParameteri(context, sampler, pname, static_cast<GLint>(param)); +} + +bool ValidateGetBufferPointerv(Context *context, GLenum target, GLenum pname, GLvoid **params) +{ + if (context->getClientMajorVersion() < 3) + { + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.")); + return false; + } + + return ValidateGetBufferPointervBase(context, target, pname, params); +} + bool ValidateUnmapBuffer(Context *context, GLenum target) { if (context->getClientMajorVersion() < 3) @@ -1802,16 +2167,8 @@ bool ValidateFlushMappedBufferRange(Context *context, return ValidateFlushMappedBufferRangeBase(context, target, offset, length); } -bool ValidateIndexedStateQuery(ValidationContext *context, - GLenum pname, - GLuint index, - GLsizei *length) +bool ValidateIndexedStateQuery(ValidationContext *context, GLenum pname, GLuint index) { - if (length) - { - *length = 0; - } - GLenum nativeType; unsigned int numParams; if (!context->getIndexedQueryParameterInfo(pname, &nativeType, &numParams)) @@ -1855,9 +2212,10 @@ bool ValidateIndexedStateQuery(ValidationContext *context, return false; } - if (length) + // pname is valid, but there are no parameters to return + if (numParams == 0) { - *length = 1; + return false; } return true; @@ -1865,174 +2223,22 @@ bool ValidateIndexedStateQuery(ValidationContext *context, bool ValidateGetIntegeri_v(ValidationContext *context, GLenum target, GLuint index, GLint *data) { - if (context->getClientVersion() < ES_3_0) - { - context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.0")); - return false; - } - return ValidateIndexedStateQuery(context, target, index, nullptr); -} - -bool ValidateGetIntegeri_vRobustANGLE(ValidationContext *context, - GLenum target, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLint *data) -{ - if (context->getClientVersion() < ES_3_0) + if (!context->getGLVersion().isES3OrGreater()) { context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.0")); return false; } - - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateIndexedStateQuery(context, target, index, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; + return ValidateIndexedStateQuery(context, target, index); } bool ValidateGetInteger64i_v(ValidationContext *context, GLenum target, GLuint index, GLint64 *data) { - if (context->getClientVersion() < ES_3_0) + if (!context->getGLVersion().isES3OrGreater()) { context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.0")); return false; } - return ValidateIndexedStateQuery(context, target, index, nullptr); -} - -bool ValidateGetInteger64i_vRobustANGLE(ValidationContext *context, - GLenum target, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLint64 *data) -{ - if (context->getClientVersion() < ES_3_0) - { - context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.0")); - return false; - } - - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateIndexedStateQuery(context, target, index, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) - { - return false; - } - - return true; -} - -bool ValidateCopyBufferSubData(ValidationContext *context, - GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size) -{ - if (context->getClientMajorVersion() < 3) - { - context->handleError( - Error(GL_INVALID_OPERATION, "CopyBufferSubData requires ES 3 or greater")); - return false; - } - - if (!ValidBufferTarget(context, readTarget) || !ValidBufferTarget(context, writeTarget)) - { - context->handleError(Error(GL_INVALID_ENUM, "Invalid buffer target")); - return false; - } - - Buffer *readBuffer = context->getGLState().getTargetBuffer(readTarget); - Buffer *writeBuffer = context->getGLState().getTargetBuffer(writeTarget); - - if (!readBuffer || !writeBuffer) - { - context->handleError(Error(GL_INVALID_OPERATION, "No buffer bound to target")); - return false; - } - - // Verify that readBuffer and writeBuffer are not currently mapped - if (readBuffer->isMapped() || writeBuffer->isMapped()) - { - context->handleError( - Error(GL_INVALID_OPERATION, "Cannot call CopyBufferSubData on a mapped buffer")); - return false; - } - - CheckedNumeric<GLintptr> checkedReadOffset(readOffset); - CheckedNumeric<GLintptr> checkedWriteOffset(writeOffset); - CheckedNumeric<GLintptr> checkedSize(size); - - auto checkedReadSum = checkedReadOffset + checkedSize; - auto checkedWriteSum = checkedWriteOffset + checkedSize; - - if (!checkedReadSum.IsValid() || !checkedWriteSum.IsValid() || - !IsValueInRangeForNumericType<GLintptr>(readBuffer->getSize()) || - !IsValueInRangeForNumericType<GLintptr>(writeBuffer->getSize())) - { - context->handleError( - Error(GL_INVALID_VALUE, "Integer overflow when validating copy offsets.")); - return false; - } - - if (readOffset < 0 || writeOffset < 0 || size < 0) - { - context->handleError( - Error(GL_INVALID_VALUE, "readOffset, writeOffset and size must all be non-negative")); - return false; - } - - if (checkedReadSum.ValueOrDie() > readBuffer->getSize() || - checkedWriteSum.ValueOrDie() > writeBuffer->getSize()) - { - context->handleError( - Error(GL_INVALID_VALUE, "Buffer offset overflow in CopyBufferSubData")); - return false; - } - - if (readBuffer == writeBuffer) - { - auto checkedOffsetDiff = (checkedReadOffset - checkedWriteOffset).Abs(); - if (!checkedOffsetDiff.IsValid()) - { - // This shold not be possible. - UNREACHABLE(); - context->handleError( - Error(GL_INVALID_VALUE, "Integer overflow when validating same buffer copy.")); - return false; - } - - if (checkedOffsetDiff.ValueOrDie() < size) - { - context->handleError(Error(GL_INVALID_VALUE)); - return false; - } - } - - return true; + return ValidateIndexedStateQuery(context, target, index); } } // namespace gl diff --git a/gfx/angle/src/libANGLE/validationES3.h b/gfx/angle/src/libANGLE/validationES3.h index ba98c998a..eeef800a8 100755 --- a/gfx/angle/src/libANGLE/validationES3.h +++ b/gfx/angle/src/libANGLE/validationES3.h @@ -32,7 +32,6 @@ bool ValidateES3TexImageParametersBase(ValidationContext *context, GLint border, GLenum format, GLenum type, - GLsizei imageSize, const GLvoid *pixels); bool ValidateES3TexStorageParameters(Context *context, @@ -58,7 +57,6 @@ bool ValidateES3TexImage2DParameters(Context *context, GLint border, GLenum format, GLenum type, - GLsizei imageSize, const GLvoid *pixels); bool ValidateES3TexImage3DParameters(Context *context, @@ -76,7 +74,6 @@ bool ValidateES3TexImage3DParameters(Context *context, GLint border, GLenum format, GLenum type, - GLsizei bufSize, const GLvoid *pixels); bool ValidateES3CopyTexImageParametersBase(ValidationContext *context, @@ -156,6 +153,11 @@ bool ValidateGetQueryObjectuiv(Context *context, GLuint id, GLenum pname, GLuint bool ValidateFramebufferTextureLayer(Context *context, GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +bool ValidES3ReadFormatType(ValidationContext *context, + GLenum internalFormat, + GLenum format, + GLenum type); + bool ValidateES3RenderbufferStorageParameters(Context *context, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); @@ -253,18 +255,6 @@ bool ValidateTexImage3D(Context *context, GLenum format, GLenum type, const GLvoid *pixels); -bool ValidateTexImage3DRobustANGLE(Context *context, - GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - GLsizei bufSize, - const GLvoid *pixels); bool ValidateTexSubImage3D(Context *context, GLenum target, GLint level, @@ -277,19 +267,6 @@ bool ValidateTexSubImage3D(Context *context, GLenum format, GLenum type, const GLvoid *pixels); -bool ValidateTexSubImage3DRobustANGLE(Context *context, - GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLsizei width, - GLsizei height, - GLsizei depth, - GLenum format, - GLenum type, - GLsizei bufSize, - const GLvoid *pixels); bool ValidateCompressedTexSubImage3D(Context *context, GLenum target, GLint level, @@ -317,13 +294,10 @@ bool ValidateGenOrDeleteCountES3(Context *context, GLint count); bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode); +bool ValidateSamplerParameteri(Context *context, GLuint sampler, GLenum pname, GLint param); +bool ValidateSamplerParameterf(Context *context, GLuint sampler, GLenum pname, GLfloat param); + bool ValidateGetBufferPointerv(Context *context, GLenum target, GLenum pname, GLvoid **params); -bool ValidateGetBufferPointervRobustANGLE(Context *context, - GLenum target, - GLenum pname, - GLsizei bufSize, - GLsizei *length, - GLvoid **params); bool ValidateUnmapBuffer(Context *context, GLenum target); bool ValidateMapBufferRange(Context *context, GLenum target, @@ -335,35 +309,12 @@ bool ValidateFlushMappedBufferRange(Context *context, GLintptr offset, GLsizeiptr length); -bool ValidateIndexedStateQuery(ValidationContext *context, - GLenum pname, - GLuint index, - GLsizei *length); +bool ValidateIndexedStateQuery(ValidationContext *context, GLenum pname, GLuint index); bool ValidateGetIntegeri_v(ValidationContext *context, GLenum target, GLuint index, GLint *data); -bool ValidateGetIntegeri_vRobustANGLE(ValidationContext *context, - GLenum target, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLint *data); bool ValidateGetInteger64i_v(ValidationContext *context, GLenum target, GLuint index, GLint64 *data); -bool ValidateGetInteger64i_vRobustANGLE(ValidationContext *context, - GLenum target, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLint64 *data); - -bool ValidateCopyBufferSubData(ValidationContext *context, - GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size); - } // namespace gl #endif // LIBANGLE_VALIDATION_ES3_H_ diff --git a/gfx/angle/src/libANGLE/validationES31.cpp b/gfx/angle/src/libANGLE/validationES31.cpp index 4cea05e47..f7406090d 100755 --- a/gfx/angle/src/libANGLE/validationES31.cpp +++ b/gfx/angle/src/libANGLE/validationES31.cpp @@ -6,11 +6,10 @@ // validationES31.cpp: Validation functions for OpenGL ES 3.1 entry point parameters +#include "libANGLE/validationES3.h" #include "libANGLE/validationES31.h" #include "libANGLE/Context.h" -#include "libANGLE/validationES.h" -#include "libANGLE/validationES3.h" using namespace angle; @@ -19,44 +18,13 @@ namespace gl bool ValidateGetBooleani_v(Context *context, GLenum target, GLuint index, GLboolean *data) { - if (context->getClientVersion() < ES_3_1) + if (!context->getGLVersion().isES31()) { context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.1")); return false; } - if (!ValidateIndexedStateQuery(context, target, index, nullptr)) - { - return false; - } - - return true; -} - -bool ValidateGetBooleani_vRobustANGLE(Context *context, - GLenum target, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLboolean *data) -{ - if (context->getClientVersion() < ES_3_1) - { - context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.1")); - return false; - } - - if (!ValidateRobustEntryPoint(context, bufSize)) - { - return false; - } - - if (!ValidateIndexedStateQuery(context, target, index, length)) - { - return false; - } - - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateIndexedStateQuery(context, target, index)) { return false; } diff --git a/gfx/angle/src/libANGLE/validationES31.h b/gfx/angle/src/libANGLE/validationES31.h index 63ca0db5b..517720cae 100755 --- a/gfx/angle/src/libANGLE/validationES31.h +++ b/gfx/angle/src/libANGLE/validationES31.h @@ -16,12 +16,6 @@ namespace gl class Context; bool ValidateGetBooleani_v(Context *context, GLenum target, GLuint index, GLboolean *data); -bool ValidateGetBooleani_vRobustANGLE(Context *context, - GLenum target, - GLuint index, - GLsizei bufSize, - GLsizei *length, - GLboolean *data); } // namespace gl diff --git a/gfx/angle/src/libANGLE/validationES_unittest.cpp b/gfx/angle/src/libANGLE/validationES_unittest.cpp index 925005a6e..9d99c32a8 100755 --- a/gfx/angle/src/libANGLE/validationES_unittest.cpp +++ b/gfx/angle/src/libANGLE/validationES_unittest.cpp @@ -29,36 +29,36 @@ namespace class MockValidationContext : public ValidationContext { public: - MockValidationContext(const Version &version, + MockValidationContext(GLint majorClientVersion, + GLint minorClientVersion, State *state, const Caps &caps, const TextureCapsMap &textureCaps, const Extensions &extensions, const ResourceManager *resourceManager, const Limitations &limitations, - const ResourceMap<Framebuffer> &framebufferMap, bool skipValidation); MOCK_METHOD1(handleError, void(const Error &)); }; -MockValidationContext::MockValidationContext(const Version &version, +MockValidationContext::MockValidationContext(GLint majorClientVersion, + GLint minorClientVersion, State *state, const Caps &caps, const TextureCapsMap &textureCaps, const Extensions &extensions, const ResourceManager *resourceManager, const Limitations &limitations, - const ResourceMap<Framebuffer> &framebufferMap, bool skipValidation) - : ValidationContext(version, + : ValidationContext(majorClientVersion, + minorClientVersion, state, caps, textureCaps, extensions, resourceManager, limitations, - framebufferMap, skipValidation) { } @@ -82,13 +82,12 @@ TEST(ValidationESTest, DrawElementsWithMaxIndexGivesError) TextureCapsMap textureCaps; Extensions extensions; Limitations limitations; - ResourceMap<Framebuffer> framebufferMap; // Set some basic caps. caps.maxElementIndex = 100; caps.maxDrawBuffers = 1; caps.maxColorAttachments = 1; - state.initialize(caps, extensions, Version(3, 0), false, true); + state.initialize(caps, extensions, 3, false); NiceMock<MockTextureImpl> *textureImpl = new NiceMock<MockTextureImpl>(); EXPECT_CALL(mockFactory, createTexture(_)).WillOnce(Return(textureImpl)); @@ -109,9 +108,8 @@ TEST(ValidationESTest, DrawElementsWithMaxIndexGivesError) state.setDrawFramebufferBinding(framebuffer); state.setProgram(program); - NiceMock<MockValidationContext> testContext(Version(3, 0), &state, caps, textureCaps, - extensions, nullptr, limitations, framebufferMap, - false); + NiceMock<MockValidationContext> testContext(3, 0, &state, caps, textureCaps, extensions, + nullptr, limitations, false); // Set the expectation for the validation error here. Error expectedError(GL_INVALID_OPERATION, g_ExceedsMaxElementErrorMessage); |