Commit 74a0000f by Martin Radev Committed by Jamie Madill

Request a D3D11.1 device and D3D11.3 context

The patch extends Renderer11 so that a D3D11.1 device and D3D11.3 context can be created. This is necessary for using the D3D11.3 feature called VPAndRTArrayIndexFromAnyShaderFeedingRasterizer. BUG=angleproject:2062 BUG=angleproject:2145 TEST=angle_end2end_tests Change-Id: I84c761b2897d7d911686f5b6d79cb93e233015a0 Reviewed-on: https://chromium-review.googlesource.com/591448Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 1a1ae0f8
...@@ -59,12 +59,12 @@ ...@@ -59,12 +59,12 @@
# endif # endif
# if defined(ANGLE_ENABLE_D3D11) # if defined(ANGLE_ENABLE_D3D11)
# include <d3d10_1.h> #include <d3d10_1.h>
# include <d3d11.h> #include <d3d11.h>
# include <d3d11_1.h> #include <d3d11_3.h>
# include <dxgi.h> #include <d3dcompiler.h>
# include <dxgi1_2.h> #include <dxgi.h>
# include <d3dcompiler.h> #include <dxgi1_2.h>
# endif # endif
#if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_D3D11) #if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_D3D11)
......
...@@ -120,8 +120,6 @@ ANGLEFeatureLevel GetANGLEFeatureLevel(D3D_FEATURE_LEVEL d3dFeatureLevel) ...@@ -120,8 +120,6 @@ ANGLEFeatureLevel GetANGLEFeatureLevel(D3D_FEATURE_LEVEL d3dFeatureLevel)
return ANGLE_FEATURE_LEVEL_10_1; return ANGLE_FEATURE_LEVEL_10_1;
case D3D_FEATURE_LEVEL_11_0: case D3D_FEATURE_LEVEL_11_0:
return ANGLE_FEATURE_LEVEL_11_0; return ANGLE_FEATURE_LEVEL_11_0;
// Note: we don't ever request a 11_1 device, because this gives
// an E_INVALIDARG error on systems that don't have the platform update.
case D3D_FEATURE_LEVEL_11_1: case D3D_FEATURE_LEVEL_11_1:
return ANGLE_FEATURE_LEVEL_11_1; return ANGLE_FEATURE_LEVEL_11_1;
default: default:
...@@ -442,6 +440,7 @@ Renderer11::Renderer11(egl::Display *display) ...@@ -442,6 +440,7 @@ Renderer11::Renderer11(egl::Display *display)
mDevice = nullptr; mDevice = nullptr;
mDeviceContext = nullptr; mDeviceContext = nullptr;
mDeviceContext1 = nullptr; mDeviceContext1 = nullptr;
mDeviceContext3 = nullptr;
mDxgiAdapter = nullptr; mDxgiAdapter = nullptr;
mDxgiFactory = nullptr; mDxgiFactory = nullptr;
...@@ -460,6 +459,14 @@ Renderer11::Renderer11(egl::Display *display) ...@@ -460,6 +459,14 @@ Renderer11::Renderer11(egl::Display *display)
if (requestedMajorVersion == EGL_DONT_CARE || requestedMajorVersion >= 11) if (requestedMajorVersion == EGL_DONT_CARE || requestedMajorVersion >= 11)
{ {
if (requestedMinorVersion == EGL_DONT_CARE || requestedMinorVersion >= 1)
{
// This could potentially lead to failed context creation if done on a system
// without the platform update which installs DXGI 1.2. Currently, for Chrome users
// D3D11 contexts are only created if the platform update is available, so this
// should not cause any issues.
mAvailableFeatureLevels.push_back(D3D_FEATURE_LEVEL_11_1);
}
if (requestedMinorVersion == EGL_DONT_CARE || requestedMinorVersion >= 0) if (requestedMinorVersion == EGL_DONT_CARE || requestedMinorVersion >= 0)
{ {
mAvailableFeatureLevels.push_back(D3D_FEATURE_LEVEL_11_0); mAvailableFeatureLevels.push_back(D3D_FEATURE_LEVEL_11_0);
...@@ -592,10 +599,11 @@ egl::Error Renderer11::initialize() ...@@ -592,10 +599,11 @@ egl::Error Renderer11::initialize()
{ {
TRACE_EVENT0("gpu.angle", "Renderer11::initialize (ComQueries)"); TRACE_EVENT0("gpu.angle", "Renderer11::initialize (ComQueries)");
// Cast the DeviceContext to a DeviceContext1. // Cast the DeviceContext to a DeviceContext1 and DeviceContext3.
// This could fail on Windows 7 without the Platform Update. // This could fail on Windows 7 without the Platform Update.
// Don't error in this case- just don't use mDeviceContext1. // Don't error in this case- just don't use mDeviceContext1 or mDeviceContext3.
mDeviceContext1 = d3d11::DynamicCastComObject<ID3D11DeviceContext1>(mDeviceContext); mDeviceContext1 = d3d11::DynamicCastComObject<ID3D11DeviceContext1>(mDeviceContext);
mDeviceContext3 = d3d11::DynamicCastComObject<ID3D11DeviceContext3>(mDeviceContext);
IDXGIDevice *dxgiDevice = nullptr; IDXGIDevice *dxgiDevice = nullptr;
result = mDevice->QueryInterface(__uuidof(IDXGIDevice), (void **)&dxgiDevice); result = mDevice->QueryInterface(__uuidof(IDXGIDevice), (void **)&dxgiDevice);
...@@ -2422,6 +2430,7 @@ void Renderer11::release() ...@@ -2422,6 +2430,7 @@ void Renderer11::release()
SafeRelease(mDxgiFactory); SafeRelease(mDxgiFactory);
SafeRelease(mDxgiAdapter); SafeRelease(mDxgiAdapter);
SafeRelease(mDeviceContext3);
SafeRelease(mDeviceContext1); SafeRelease(mDeviceContext1);
if (mDeviceContext) if (mDeviceContext)
...@@ -2632,6 +2641,7 @@ int Renderer11::getMajorShaderModel() const ...@@ -2632,6 +2641,7 @@ int Renderer11::getMajorShaderModel() const
{ {
switch (mRenderer11DeviceCaps.featureLevel) switch (mRenderer11DeviceCaps.featureLevel)
{ {
case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0: case D3D_FEATURE_LEVEL_11_0:
return D3D11_SHADER_MAJOR_VERSION; // 5 return D3D11_SHADER_MAJOR_VERSION; // 5
case D3D_FEATURE_LEVEL_10_1: case D3D_FEATURE_LEVEL_10_1:
...@@ -2650,6 +2660,7 @@ int Renderer11::getMinorShaderModel() const ...@@ -2650,6 +2660,7 @@ int Renderer11::getMinorShaderModel() const
{ {
switch (mRenderer11DeviceCaps.featureLevel) switch (mRenderer11DeviceCaps.featureLevel)
{ {
case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0: case D3D_FEATURE_LEVEL_11_0:
return D3D11_SHADER_MINOR_VERSION; // 0 return D3D11_SHADER_MINOR_VERSION; // 0
case D3D_FEATURE_LEVEL_10_1: case D3D_FEATURE_LEVEL_10_1:
...@@ -2668,6 +2679,7 @@ std::string Renderer11::getShaderModelSuffix() const ...@@ -2668,6 +2679,7 @@ std::string Renderer11::getShaderModelSuffix() const
{ {
switch (mRenderer11DeviceCaps.featureLevel) switch (mRenderer11DeviceCaps.featureLevel)
{ {
case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0: case D3D_FEATURE_LEVEL_11_0:
return ""; return "";
case D3D_FEATURE_LEVEL_10_1: case D3D_FEATURE_LEVEL_10_1:
......
...@@ -599,6 +599,7 @@ class Renderer11 : public RendererD3D ...@@ -599,6 +599,7 @@ class Renderer11 : public RendererD3D
Renderer11DeviceCaps mRenderer11DeviceCaps; Renderer11DeviceCaps mRenderer11DeviceCaps;
ID3D11DeviceContext *mDeviceContext; ID3D11DeviceContext *mDeviceContext;
ID3D11DeviceContext1 *mDeviceContext1; ID3D11DeviceContext1 *mDeviceContext1;
ID3D11DeviceContext3 *mDeviceContext3;
IDXGIAdapter *mDxgiAdapter; IDXGIAdapter *mDxgiAdapter;
DXGI_ADAPTER_DESC mAdapterDescription; DXGI_ADAPTER_DESC mAdapterDescription;
char mDescription[128]; char mDescription[128];
......
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
# Code generation for the DXGI support tables. Determines which formats # Code generation for the DXGI support tables. Determines which formats
# are natively support in D3D10+. # are natively support in D3D10+.
# #
# TODO: The "never supported" formats should not be combined with the
# "supported" and "optional" ones. At the moment, this does not cause
# any issues as ANGLE does not internally check for "never supported".
#
# MSDN links: # MSDN links:
# 10Level9 9_3: https://msdn.microsoft.com/en-us/library/windows/desktop/mt790740.aspx # 10Level9 9_3: https://msdn.microsoft.com/en-us/library/windows/desktop/mt790740.aspx
# 10_0: https://msdn.microsoft.com/en-us/library/windows/desktop/cc627090.aspx # 10_0: https://msdn.microsoft.com/en-us/library/windows/desktop/cc627090.aspx
...@@ -115,6 +119,19 @@ const DXGISupport &GetDXGISupport_11_0(DXGI_FORMAT dxgiFormat) ...@@ -115,6 +119,19 @@ const DXGISupport &GetDXGISupport_11_0(DXGI_FORMAT dxgiFormat)
// clang-format on // clang-format on
}} }}
const DXGISupport &GetDXGISupport_11_1(DXGI_FORMAT dxgiFormat)
{{
// clang-format off
switch (dxgiFormat)
{{
{table_data_11_1}
default:
UNREACHABLE();
return GetDefaultSupport();
}}
// clang-format on
}}
}} }}
#undef {prefix}2D #undef {prefix}2D
...@@ -138,6 +155,8 @@ const DXGISupport &GetDXGISupport(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL feat ...@@ -138,6 +155,8 @@ const DXGISupport &GetDXGISupport(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL feat
return GetDXGISupport_10_1(dxgiFormat); return GetDXGISupport_10_1(dxgiFormat);
case D3D_FEATURE_LEVEL_11_0: case D3D_FEATURE_LEVEL_11_0:
return GetDXGISupport_11_0(dxgiFormat); return GetDXGISupport_11_0(dxgiFormat);
case D3D_FEATURE_LEVEL_11_1:
return GetDXGISupport_11_1(dxgiFormat);
default: default:
return GetDefaultSupport(); return GetDefaultSupport();
}} }}
...@@ -151,7 +170,7 @@ const DXGISupport &GetDXGISupport(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL feat ...@@ -151,7 +170,7 @@ const DXGISupport &GetDXGISupport(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL feat
table_init = "" table_init = ""
def do_format(format_data): def do_format(format_data):
table_data = {'9_3': '', '10_0': '', '10_1': '', '11_0': ''} table_data = {'9_3': '', '10_0': '', '10_1': '', '11_0': '', '11_1': ''}
json_flag_to_d3d = { json_flag_to_d3d = {
'texture2D': macro_prefix + '2D', 'texture2D': macro_prefix + '2D',
...@@ -175,6 +194,7 @@ def do_format(format_data): ...@@ -175,6 +194,7 @@ def do_format(format_data):
fl_10_1_supported = set() fl_10_1_supported = set()
fl_11_0_supported = set() fl_11_0_supported = set()
fl_11_0_check = set() fl_11_0_check = set()
fl_11_1_supported = set()
fl_10_0_check_10_1_supported = set() fl_10_0_check_10_1_supported = set()
fl_10_0_check_11_0_supported = set() fl_10_0_check_11_0_supported = set()
...@@ -195,8 +215,7 @@ def do_format(format_data): ...@@ -195,8 +215,7 @@ def do_format(format_data):
elif support == '11_0': elif support == '11_0':
fl_11_0_supported.update(d3d_flag) fl_11_0_supported.update(d3d_flag)
elif support == '11_1': elif support == '11_1':
# TODO(jmadill): D3D 11.1 handling fl_11_1_supported.update(d3d_flag)
never_supported.update(d3d_flag)
elif support == 'dxgi1_2': elif support == 'dxgi1_2':
# TODO(jmadill): DXGI 1.2 handling. # TODO(jmadill): DXGI 1.2 handling.
always_supported.update(d3d_flag) always_supported.update(d3d_flag)
...@@ -216,7 +235,7 @@ def do_format(format_data): ...@@ -216,7 +235,7 @@ def do_format(format_data):
print("Data specification error: " + support) print("Data specification error: " + support)
sys.exit(1) sys.exit(1)
for feature_level in ['9_3', '10_0', '10_1', '11_0']: for feature_level in ['9_3', '10_0', '10_1', '11_0', '11_1']:
always_for_fl = always_supported always_for_fl = always_supported
optional_for_fl = optionally_supported optional_for_fl = optionally_supported
if feature_level == '9_3': if feature_level == '9_3':
...@@ -237,6 +256,13 @@ def do_format(format_data): ...@@ -237,6 +256,13 @@ def do_format(format_data):
always_for_fl = fl_10_0_check_11_0_supported.union(always_for_fl) always_for_fl = fl_10_0_check_11_0_supported.union(always_for_fl)
always_for_fl = fl_10_1_supported.union(always_for_fl) always_for_fl = fl_10_1_supported.union(always_for_fl)
always_for_fl = fl_11_0_supported.union(always_for_fl) always_for_fl = fl_11_0_supported.union(always_for_fl)
elif feature_level == '11_1':
always_for_fl = fl_10_0_supported.union(always_for_fl)
always_for_fl = fl_10_0_check_10_1_supported.union(always_for_fl)
always_for_fl = fl_10_0_check_11_0_supported.union(always_for_fl)
always_for_fl = fl_10_1_supported.union(always_for_fl)
always_for_fl = fl_11_0_supported.union(always_for_fl)
always_for_fl = fl_11_1_supported.union(always_for_fl)
always = ' | '.join(sorted(always_for_fl)) always = ' | '.join(sorted(always_for_fl))
never = ' | '.join(sorted(never_supported)) never = ' | '.join(sorted(never_supported))
...@@ -258,14 +284,15 @@ def join_table_data(table_data_1, table_data_2): ...@@ -258,14 +284,15 @@ def join_table_data(table_data_1, table_data_2):
return {'9_3': table_data_1['9_3'] + table_data_2['9_3'], return {'9_3': table_data_1['9_3'] + table_data_2['9_3'],
'10_0': table_data_1['10_0'] + table_data_2['10_0'], '10_0': table_data_1['10_0'] + table_data_2['10_0'],
'10_1': table_data_1['10_1'] + table_data_2['10_1'], '10_1': table_data_1['10_1'] + table_data_2['10_1'],
'11_0': table_data_1['11_0'] + table_data_2['11_0']} '11_0': table_data_1['11_0'] + table_data_2['11_0'],
'11_1': table_data_1['11_1'] + table_data_2['11_1']}
with open('dxgi_support_data.json') as dxgi_file: with open('dxgi_support_data.json') as dxgi_file:
file_data = dxgi_file.read() file_data = dxgi_file.read()
dxgi_file.close() dxgi_file.close()
json_data = json.loads(file_data) json_data = json.loads(file_data)
table_data = {'9_3': '', '10_0': '', '10_1': '', '11_0': ''} table_data = {'9_3': '', '10_0': '', '10_1': '', '11_0': '', '11_1': ''}
for format_data in json_data: for format_data in json_data:
table_data = join_table_data(table_data, do_format(format_data)) table_data = join_table_data(table_data, do_format(format_data))
...@@ -274,7 +301,8 @@ with open('dxgi_support_data.json') as dxgi_file: ...@@ -274,7 +301,8 @@ with open('dxgi_support_data.json') as dxgi_file:
table_data_9_3=table_data['9_3'], table_data_9_3=table_data['9_3'],
table_data_10_0=table_data['10_0'], table_data_10_0=table_data['10_0'],
table_data_10_1=table_data['10_1'], table_data_10_1=table_data['10_1'],
table_data_11_0=table_data['11_0']) table_data_11_0=table_data['11_0'],
table_data_11_1=table_data['11_1'])
with open('dxgi_support_table.cpp', 'wt') as out_file: with open('dxgi_support_table.cpp', 'wt') as out_file:
out_file.write(out_data) out_file.write(out_data)
......
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