1 // 2 // Copyright (c) 2015 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // WorkaroundsD3D.h: Workarounds for D3D driver bugs and other issues. 8 9 #ifndef ANGLE_PLATFORM_WORKAROUNDSD3D_H_ 10 #define ANGLE_PLATFORM_WORKAROUNDSD3D_H_ 11 12 // TODO(jmadill,zmo,geofflang): make a workarounds library that can operate 13 // independent of ANGLE's renderer. Workarounds should also be accessible 14 // outside of the Renderer. 15 16 namespace angle 17 { 18 struct CompilerWorkaroundsD3D 19 { 20 bool skipOptimization = false; 21 bool useMaxOptimization = false; 22 23 // IEEE strictness needs to be enabled for NANs to work. 24 bool enableIEEEStrictness = false; 25 }; 26 27 struct WorkaroundsD3D 28 { 29 // On some systems, having extra rendertargets than necessary slows down the shader. 30 // We can fix this by optimizing those out of the shader. At the same time, we can 31 // work around a bug on some nVidia drivers that they ignore "null" render targets 32 // in D3D11, by compacting the active color attachments list to omit null entries. 33 bool mrtPerfWorkaround = false; 34 35 bool setDataFasterThanImageUpload = false; 36 37 // Some renderers can't disable mipmaps on a mipmapped texture (i.e. solely sample from level 38 // zero, and ignore the other levels). D3D11 Feature Level 10+ does this by setting MaxLOD to 39 // 0.0f in the Sampler state. D3D9 sets D3DSAMP_MIPFILTER to D3DTEXF_NONE. There is no 40 // equivalent to this in D3D11 Feature Level 9_3. This causes problems when (for example) an 41 // application creates a mipmapped texture2D, but sets GL_TEXTURE_MIN_FILTER to GL_NEAREST 42 // (i.e disables mipmaps). To work around this, D3D11 FL9_3 has to create two copies of the 43 // texture. The textures' level zeros are identical, but only one texture has mips. 44 bool zeroMaxLodWorkaround = false; 45 46 // Some renderers do not support Geometry Shaders so the Geometry Shader-based PointSprite 47 // emulation will not work. To work around this, D3D11 FL9_3 has to use a different pointsprite 48 // emulation that is implemented using instanced quads. 49 bool useInstancedPointSpriteEmulation = false; 50 51 // A bug fixed in NVIDIA driver version 347.88 < x <= 368.81 triggers a TDR when using 52 // CopySubresourceRegion from a staging texture to a depth/stencil in D3D11. The workaround 53 // is to use UpdateSubresource to trigger an extra copy. We disable this workaround on newer 54 // NVIDIA driver versions because of a second driver bug present with the workaround enabled. 55 // (See: http://anglebug.com/1452) 56 bool depthStencilBlitExtraCopy = false; 57 58 // The HLSL optimizer has a bug with optimizing "pow" in certain integer-valued expressions. 59 // We can work around this by expanding the pow into a series of multiplies if we're running 60 // under the affected compiler. 61 bool expandIntegerPowExpressions = false; 62 63 // NVIDIA drivers sometimes write out-of-order results to StreamOut buffers when transform 64 // feedback is used to repeatedly write to the same buffer positions. 65 bool flushAfterEndingTransformFeedback = false; 66 67 // Some drivers (NVIDIA) do not take into account the base level of the texture in the results 68 // of the HLSL GetDimensions builtin. 69 bool getDimensionsIgnoresBaseLevel = false; 70 71 // On some Intel drivers, HLSL's function texture.Load returns 0 when the parameter Location 72 // is negative, even if the sum of Offset and Location is in range. This may cause errors when 73 // translating GLSL's function texelFetchOffset into texture.Load, as it is valid for 74 // texelFetchOffset to use negative texture coordinates as its parameter P when the sum of P 75 // and Offset is in range. To work around this, we translate texelFetchOffset into texelFetch 76 // by adding Offset directly to Location before reading the texture. 77 bool preAddTexelFetchOffsets = false; 78 79 // On some AMD drivers, 1x1 and 2x2 mips of depth/stencil textures aren't sampled correctly. 80 // We can work around this bug by doing an internal blit to a temporary single-channel texture 81 // before we sample. 82 bool emulateTinyStencilTextures = false; 83 84 // In Intel driver, the data with format DXGI_FORMAT_B5G6R5_UNORM will be parsed incorrectly. 85 // This workaroud will disable B5G6R5 support when it's Intel driver. By default, it will use 86 // R8G8B8A8 format. This bug is fixed in version 4539 on Intel drivers. 87 bool disableB5G6R5Support = false; 88 89 // On some Intel drivers, evaluating unary minus operator on integer may get wrong answer in 90 // vertex shaders. To work around this bug, we translate -(int) into ~(int)+1. 91 // This driver bug is fixed in 20.19.15.4624. 92 bool rewriteUnaryMinusOperator = false; 93 94 // On some Intel drivers, using isnan() on highp float will get wrong answer. To work around 95 // this bug, we use an expression to emulate function isnan(). 96 // Tracking bug: https://crbug.com/650547 97 // This driver bug is fixed in 21.20.16.4542. 98 bool emulateIsnanFloat = false; 99 100 // On some Intel drivers, using clear() may not take effect. To work around this bug, we call 101 // clear() twice on these platforms. 102 // Tracking bug: https://crbug.com/655534 103 bool callClearTwice = false; 104 105 // On some Intel drivers, copying from staging storage to constant buffer storage does not 106 // seem to work. Work around this by keeping system memory storage as a canonical reference 107 // for buffer data. 108 // D3D11-only workaround. See http://crbug.com/593024. 109 bool useSystemMemoryForConstantBuffers = false; 110 111 // This workaround is for the ANGLE_multiview extension. If enabled the viewport or render 112 // target slice will be selected in the geometry shader stage. The workaround flag is added to 113 // make it possible to select the code path in end2end and performance tests. 114 bool selectViewInGeometryShader = false; 115 116 // When rendering with no render target on D3D, two bugs lead to incorrect behavior on Intel 117 // drivers < 4815. The rendering samples always pass neglecting discard statements in pixel 118 // shader. 119 // 1. If rendertarget is not set, the pixel shader will be recompiled to drop 'SV_TARGET'. 120 // When using a pixel shader with no 'SV_TARGET' in a draw, the pixels are always generated even 121 // if they should be discard by 'discard' statements. 122 // 2. If ID3D11BlendState.RenderTarget[].RenderTargetWriteMask is 0 and rendertarget is not set, 123 // then rendering samples also pass neglecting discard statements in pixel shader. 124 // So we add a dummy texture as render target in such case. See http://anglebug.com/2152 125 bool addDummyTextureNoRenderTarget = false; 126 }; 127 128 } // namespace angle 129 130 #endif // ANGLE_PLATFORM_WORKAROUNDSD3D_H_ 131