summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp')
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp104
1 files changed, 68 insertions, 36 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp
index 8622dc4d13..fd451a6e51 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.cpp
@@ -17,7 +17,9 @@
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#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 "platform/Platform.h"
+#include "platform/WorkaroundsD3D.h"
#include "third_party/systeminfo/SystemInfo.h"
@@ -133,21 +135,22 @@ D3DTEXTUREADDRESS ConvertTextureWrap(GLenum wrap)
return d3dWrap;
}
-D3DCULL ConvertCullMode(GLenum cullFace, GLenum frontFace)
+D3DCULL ConvertCullMode(gl::CullFaceMode cullFace, GLenum frontFace)
{
D3DCULL cull = D3DCULL_CCW;
switch (cullFace)
{
- case GL_FRONT:
- cull = (frontFace == GL_CCW ? D3DCULL_CW : D3DCULL_CCW);
- break;
- case GL_BACK:
- cull = (frontFace == GL_CCW ? D3DCULL_CCW : D3DCULL_CW);
- break;
- case GL_FRONT_AND_BACK:
- cull = D3DCULL_NONE; // culling will be handled during draw
- break;
- default: UNREACHABLE();
+ case gl::CullFaceMode::Front:
+ cull = (frontFace == GL_CCW ? D3DCULL_CW : D3DCULL_CCW);
+ break;
+ case gl::CullFaceMode::Back:
+ cull = (frontFace == GL_CCW ? D3DCULL_CCW : D3DCULL_CW);
+ break;
+ case gl::CullFaceMode::FrontAndBack:
+ cull = D3DCULL_NONE; // culling will be handled during draw
+ break;
+ default:
+ UNREACHABLE();
}
return cull;
@@ -264,6 +267,21 @@ void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DT
}
}
+D3DQUERYTYPE ConvertQueryType(GLenum queryType)
+{
+ switch (queryType)
+ {
+ case GL_ANY_SAMPLES_PASSED_EXT:
+ case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
+ return D3DQUERYTYPE_OCCLUSION;
+ case GL_COMMANDS_COMPLETED_CHROMIUM:
+ return D3DQUERYTYPE_EVENT;
+ default:
+ UNREACHABLE();
+ return static_cast<D3DQUERYTYPE>(0);
+ }
+}
+
D3DMULTISAMPLE_TYPE GetMultisampleType(GLuint samples)
{
return (samples > 1) ? static_cast<D3DMULTISAMPLE_TYPE>(samples) : D3DMULTISAMPLE_NONE;
@@ -291,8 +309,8 @@ GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type)
bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format)
{
- GLenum internalFormat = d3d9::GetD3DFormatInfo(d3dformat).internalFormat;
- GLenum convertedFormat = gl::GetInternalFormatInfo(internalFormat).format;
+ GLenum internalFormat = d3d9::GetD3DFormatInfo(d3dformat).info().glInternalFormat;
+ GLenum convertedFormat = gl::GetSizedInternalFormatInfo(internalFormat).format;
return convertedFormat == format;
}
@@ -302,7 +320,7 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, IDirect3
gl::TextureCaps textureCaps;
const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(internalFormat);
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
+ const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalFormat);
if (d3dFormatInfo.texFormat != D3DFMT_UNKNOWN)
{
@@ -333,7 +351,8 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, IDirect3
{
D3DMULTISAMPLE_TYPE multisampleType = D3DMULTISAMPLE_TYPE(i);
- HRESULT result = d3d9->CheckDeviceMultiSampleType(adapter, deviceType, d3dFormatInfo.renderFormat, TRUE, multisampleType, NULL);
+ HRESULT result = d3d9->CheckDeviceMultiSampleType(
+ adapter, deviceType, d3dFormatInfo.renderFormat, TRUE, multisampleType, nullptr);
if (SUCCEEDED(result))
{
textureCaps.sampleCounts.insert(i);
@@ -364,18 +383,17 @@ void GenerateCaps(IDirect3D9 *d3d9,
d3d9->GetAdapterDisplayMode(adapter, &currentDisplayMode);
GLuint maxSamples = 0;
- const gl::FormatSet &allFormats = gl::GetAllSizedInternalFormats();
- for (gl::FormatSet::const_iterator internalFormat = allFormats.begin(); internalFormat != allFormats.end(); ++internalFormat)
+ for (GLenum internalFormat : gl::GetAllSizedInternalFormats())
{
- gl::TextureCaps textureCaps = GenerateTextureFormatCaps(*internalFormat, d3d9, deviceType, adapter,
- currentDisplayMode.Format);
- textureCapsMap->insert(*internalFormat, textureCaps);
+ gl::TextureCaps textureCaps = GenerateTextureFormatCaps(internalFormat, d3d9, deviceType,
+ adapter, currentDisplayMode.Format);
+ textureCapsMap->insert(internalFormat, textureCaps);
maxSamples = std::max(maxSamples, textureCaps.getMaxSamples());
- if (gl::GetInternalFormatInfo(*internalFormat).compressed)
+ if (gl::GetSizedInternalFormatInfo(internalFormat).compressed)
{
- caps->compressedTextureFormats.push_back(*internalFormat);
+ caps->compressedTextureFormats.push_back(internalFormat);
}
}
@@ -444,6 +462,8 @@ void GenerateCaps(IDirect3D9 *d3d9,
// Vertex shader limits
caps->maxVertexAttributes = 16;
+ // Vertex Attrib Binding not supported.
+ caps->maxVertexAttribBindings = caps->maxVertexAttributes;
const size_t MAX_VERTEX_CONSTANT_VECTORS_D3D9 = 256;
caps->maxVertexUniformVectors =
@@ -525,12 +545,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() && adapterId.VendorId == VENDOR_ID_AMD);
+ !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP_POW2) &&
+ !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) &&
+ !(!isWindowsVistaOrGreater() && IsAMD(adapterId.VendorId));
// Disable depth texture support on AMD cards (See ANGLE issue 839)
- if (adapterId.VendorId == VENDOR_ID_AMD)
+ if (IsAMD(adapterId.VendorId))
{
extensions->depthTextures = false;
}
@@ -548,18 +568,21 @@ void GenerateCaps(IDirect3D9 *d3d9,
extensions->maxTextureAnisotropy = static_cast<GLfloat>(deviceCaps.MaxAnisotropy);
// Check occlusion query support by trying to create one
- IDirect3DQuery9 *occlusionQuery = NULL;
+ IDirect3DQuery9 *occlusionQuery = nullptr;
extensions->occlusionQueryBoolean = SUCCEEDED(device->CreateQuery(D3DQUERYTYPE_OCCLUSION, &occlusionQuery)) && occlusionQuery;
SafeRelease(occlusionQuery);
// Check event query support by trying to create one
- IDirect3DQuery9 *eventQuery = NULL;
+ IDirect3DQuery9 *eventQuery = nullptr;
extensions->fence = SUCCEEDED(device->CreateQuery(D3DQUERYTYPE_EVENT, &eventQuery)) && eventQuery;
SafeRelease(eventQuery);
- extensions->timerQuery = false; // Unimplemented
extensions->disjointTimerQuery = false;
extensions->robustness = true;
+ // It seems that only DirectX 10 and higher enforce the well-defined behavior of always
+ // returning zero values when out-of-bounds reads. See
+ // https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_robustness.txt
+ extensions->robustBufferAccessBehavior = false;
extensions->blendMinMax = true;
extensions->framebufferBlit = true;
extensions->framebufferMultisample = true;
@@ -575,10 +598,11 @@ void GenerateCaps(IDirect3D9 *d3d9,
extensions->colorBufferFloat = false;
extensions->debugMarker = true;
extensions->eglImage = true;
+ extensions->eglImageExternal = true;
extensions->unpackSubimage = true;
extensions->packSubimage = true;
- extensions->vertexArrayObject = true;
- extensions->noError = true;
+ extensions->syncQuery = extensions->fence;
+ extensions->copyTexture = true;
// D3D9 has no concept of separate masks and refs for front and back faces in the depth stencil
// state.
@@ -625,15 +649,23 @@ void MakeValidSize(bool isImage, D3DFORMAT format, GLsizei *requestWidth, GLsize
*levelOffset = upsampleCount;
}
-WorkaroundsD3D GenerateWorkarounds()
+angle::WorkaroundsD3D GenerateWorkarounds()
{
- WorkaroundsD3D workarounds;
+ angle::WorkaroundsD3D workarounds;
workarounds.mrtPerfWorkaround = true;
workarounds.setDataFasterThanImageUpload = false;
workarounds.useInstancedPointSpriteEmulation = false;
+
+ // TODO(jmadill): Disable workaround when we have a fixed compiler DLL.
+ workarounds.expandIntegerPowExpressions = true;
+
+ // Call platform hooks for testing overrides.
+ auto *platform = ANGLEPlatformCurrent();
+ platform->overrideWorkaroundsD3D(platform, &workarounds);
+
return workarounds;
}
-}
+} // namespace d3d9
-}
+} // namespace rx