在某些 Intel GPU 上从多重采样纹理加载失败 [英] Load from multisampled texture fails on some Intel GPUs

查看:42
本文介绍了在某些 Intel GPU 上从多重采样纹理加载失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过使用模板缓冲区在我的应用中实现了鼠标拾取.

I’ve implemented mouse picking in my app by using a stencil buffer.

这是在鼠标下读取值的像素着色器:

Here’s the pixel shader that reads value under the mouse:

Texture2DMS<uint2> depthStencilTexture : register( t0 );

cbuffer ReadDepthInput : register( b2 )
{
    int2 readPosition;
}

// Produces vector3( x, y, stencilValue )
float4 main() : SV_Target0
{
    uint2 res = depthStencilTexture.Load( readPosition, 1 );
    float stencil = res.y;
    // Scale the result from integers to 0..1
    stencil /= 255.0f;
    return float4( float( readPosition.x ) / 65535.0f, float( readPosition.y ) / 65535.0f, stencil, 0 );
}

代码适用于 nVidia 和 AMD GPU,适用于 Intel Iris 550.

The code works on nVidia and AMD GPUs, works on Intel Iris 550.

代码在 Intel Haswell GPU(Intel HD 5000、Intel HD 4600)上失败.Texture2DMS.Load 只返回 0.任何想法可能是错误的?

The code fails on Intel Haswell GPUs (Intel HD 5000, Intel HD 4600). Texture2DMS.Load just returns 0. Any ideas what might be wrong?

更新:仅适用于 8x MSAA.即使在那些受影响的英特尔 GPU 上,将其降低到 4 倍也可以正常工作.

Update: Only happens with 8x MSAA. Decreasing it to 4x works OK even on those affected Intel GPUs.

推荐答案

看起来 Intel GPU 驱动程序或硬件存在错误.

Looks like there’s a bug in Intel GPU driver or hardware.

这里有一个解决方法:

HRESULT isIntelHaswellGPU( ID3D11Device* device )
{
    CComQIPtr<IDXGIDevice> dxgiDev = device;
    if( !dxgiDev )
        return E_NOINTERFACE;

    CComPtr<IDXGIAdapter> adapter;
    CHECK( dxgiDev->GetAdapter( &adapter ) );

    DXGI_ADAPTER_DESC desc;
    CHECK( adapter->GetDesc( &desc ) );

    if( desc.VendorId != 0x8086 )
        return S_FALSE; // nVidia or AMD GPU

    // https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units#Seventh_generation
    // https://github.com/GameTechDev/gpudetect/blob/master/DeviceId.cpp
    const UINT maskedDeviceId = ( desc.DeviceId & 0xFF00 );
    if( maskedDeviceId == 0x0400 || maskedDeviceId == 0x0A00 || maskedDeviceId == 0x0D00 )
        return S_OK;    // Detected Intel Haswell GPU
    return S_FALSE;
}

如果这个函数返回 S_OK,我会限制最大值.MSAA 级别为 4.

If this function returns S_OK, I limit max. MSAA level to 4.

这篇关于在某些 Intel GPU 上从多重采样纹理加载失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆