Commit 8e7c8a13 by Jamie Madill

Fix texture format support queries on AMD-D3D9.

We were allowing calls to the device to check support for D3DFMT_NULL, which AMD reports as a usable texture type. This was causing crashes with the WebGL CTS and angle_end2end_tests, when the user tries to use an sRGB or other type, which we incorrectly reported as available. BUG=angle:839 Change-Id: I4941baac6a2b14a09c0ad2c924f29189ccfc6a07 Reviewed-on: https://chromium-review.googlesource.com/232728Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 130e6e8f
...@@ -61,9 +61,6 @@ ...@@ -61,9 +61,6 @@
#define ANGLE_SUPPORT_SHADER_MODEL_2 0 #define ANGLE_SUPPORT_SHADER_MODEL_2 0
#endif #endif
const D3DFORMAT D3DFMT_INTZ = ((D3DFORMAT)(MAKEFOURCC('I','N','T','Z')));
const D3DFORMAT D3DFMT_NULL = ((D3DFORMAT)(MAKEFOURCC('N','U','L','L')));
namespace rx namespace rx
{ {
static const D3DFORMAT RenderTargetFormats[] = static const D3DFORMAT RenderTargetFormats[] =
......
...@@ -192,8 +192,8 @@ typedef std::pair<GLenum, TextureFormat> D3D9FormatPair; ...@@ -192,8 +192,8 @@ typedef std::pair<GLenum, TextureFormat> D3D9FormatPair;
typedef std::map<GLenum, TextureFormat> D3D9FormatMap; typedef std::map<GLenum, TextureFormat> D3D9FormatMap;
TextureFormat::TextureFormat() TextureFormat::TextureFormat()
: texFormat(D3DFMT_NULL), : texFormat(D3DFMT_UNKNOWN),
renderFormat(D3DFMT_NULL), renderFormat(D3DFMT_UNKNOWN),
dataInitializerFunction(NULL), dataInitializerFunction(NULL),
loadFunction(UnreachableLoad) loadFunction(UnreachableLoad)
{ {
......
...@@ -275,30 +275,38 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, IDirect3 ...@@ -275,30 +275,38 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, IDirect3
gl::TextureCaps textureCaps; gl::TextureCaps textureCaps;
const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(internalFormat); const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(internalFormat);
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0) if (d3dFormatInfo.texFormat != D3DFMT_UNKNOWN)
{
textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat));
}
else
{ {
textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat)) && const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_CUBETEXTURE, d3dFormatInfo.texFormat)); if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0)
} {
textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat));
}
else
{
textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat)) &&
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_CUBETEXTURE, d3dFormatInfo.texFormat));
}
textureCaps.filterable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat)); textureCaps.filterable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat));
textureCaps.renderable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat)) || }
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat));
textureCaps.sampleCounts.insert(1); if (d3dFormatInfo.renderFormat != D3DFMT_UNKNOWN)
for (size_t i = D3DMULTISAMPLE_2_SAMPLES; i <= D3DMULTISAMPLE_16_SAMPLES; i++)
{ {
D3DMULTISAMPLE_TYPE multisampleType = D3DMULTISAMPLE_TYPE(i); textureCaps.renderable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat)) ||
SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat));
HRESULT result = d3d9->CheckDeviceMultiSampleType(adapter, deviceType, d3dFormatInfo.renderFormat, TRUE, multisampleType, NULL); textureCaps.sampleCounts.insert(1);
if (SUCCEEDED(result)) for (size_t i = D3DMULTISAMPLE_2_SAMPLES; i <= D3DMULTISAMPLE_16_SAMPLES; i++)
{ {
textureCaps.sampleCounts.insert(i); D3DMULTISAMPLE_TYPE multisampleType = D3DMULTISAMPLE_TYPE(i);
HRESULT result = d3d9->CheckDeviceMultiSampleType(adapter, deviceType, d3dFormatInfo.renderFormat, TRUE, multisampleType, NULL);
if (SUCCEEDED(result))
{
textureCaps.sampleCounts.insert(i);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment