From 4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 11 Jul 2018 18:11:13 +0200 Subject: Roll back to ANGLE/2845 --- gfx/angle/src/libANGLE/renderer/d3d/d3d9/Blit9.cpp | 73 +++--- .../src/libANGLE/renderer/d3d/d3d9/Buffer9.cpp | 9 +- gfx/angle/src/libANGLE/renderer/d3d/d3d9/Buffer9.h | 19 +- .../src/libANGLE/renderer/d3d/d3d9/Context9.cpp | 10 +- .../src/libANGLE/renderer/d3d/d3d9/Context9.h | 2 +- .../libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp | 4 +- .../src/libANGLE/renderer/d3d/d3d9/Image9.cpp | 21 +- .../src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp | 143 +----------- .../src/libANGLE/renderer/d3d/d3d9/Renderer9.h | 13 -- .../libANGLE/renderer/d3d/d3d9/StateManager9.cpp | 2 +- .../src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp | 46 ++-- .../src/libANGLE/renderer/d3d/d3d9/SwapChain9.h | 1 - .../libANGLE/renderer/d3d/d3d9/TextureStorage9.cpp | 4 + .../renderer/d3d/d3d9/VertexDeclarationCache.cpp | 2 +- .../libANGLE/renderer/d3d/d3d9/formatutils9.cpp | 251 +++++++-------------- .../src/libANGLE/renderer/d3d/d3d9/formatutils9.h | 17 +- .../libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp | 11 +- 17 files changed, 178 insertions(+), 450 deletions(-) (limited to 'gfx/angle/src/libANGLE/renderer/d3d/d3d9') 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(shaderCode), shaderSize, &shader)); + + gl::Error error = (mRenderer->*createShader)(reinterpret_cast(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(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..1c90fffa1 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) @@ -137,7 +137,7 @@ gl::Error Context9::finish() gl::Error Context9::drawArrays(GLenum mode, GLint first, GLsizei count) { - return mRenderer->genericDrawArrays(this, mode, first, count, 1); + return mRenderer->genericDrawArrays(this, mode, first, count, 0); } gl::Error Context9::drawArraysInstanced(GLenum mode, @@ -154,7 +154,7 @@ gl::Error Context9::drawElements(GLenum mode, const GLvoid *indices, const gl::IndexRange &indexRange) { - return mRenderer->genericDrawElements(this, mode, count, type, indices, 1, indexRange); + return mRenderer->genericDrawElements(this, mode, count, type, indices, 0, indexRange); } gl::Error Context9::drawElementsInstanced(GLenum mode, @@ -175,7 +175,7 @@ gl::Error Context9::drawRangeElements(GLenum mode, const GLvoid *indices, const gl::IndexRange &indexRange) { - return mRenderer->genericDrawElements(this, mode, count, type, indices, 1, indexRange); + return mRenderer->genericDrawElements(this, mode, count, type, indices, 0, indexRange); } GLenum Context9::getResetStatus() 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(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(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(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(desc.Width); - } - if (height) - { - *height = static_cast(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(width) || - desc.Height != static_cast(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(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(lodBias)); if (getNativeExtensions().textureFilterAnisotropic) { - DWORD maxAnisotropy = - std::min(mDeviceCaps.MaxAnisotropy, static_cast(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 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 InternalFormatInitialzerPair; typedef std::map 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; } -- cgit v1.2.3