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 @@
# endif
# if defined(ANGLE_ENABLE_D3D11)
# include <d3d10_1.h>
# include <d3d11.h>
# include <d3d11_1.h>
# include <dxgi.h>
# include <dxgi1_2.h>
# include <d3dcompiler.h>
#include <d3d10_1.h>
#include <d3d11.h>
#include <d3d11_3.h>
#include <d3dcompiler.h>
#include <dxgi.h>
#include <dxgi1_2.h>
# endif
#if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_D3D11)
......
......@@ -120,8 +120,6 @@ ANGLEFeatureLevel GetANGLEFeatureLevel(D3D_FEATURE_LEVEL d3dFeatureLevel)
return ANGLE_FEATURE_LEVEL_10_1;
case D3D_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:
return ANGLE_FEATURE_LEVEL_11_1;
default:
......@@ -442,6 +440,7 @@ Renderer11::Renderer11(egl::Display *display)
mDevice = nullptr;
mDeviceContext = nullptr;
mDeviceContext1 = nullptr;
mDeviceContext3 = nullptr;
mDxgiAdapter = nullptr;
mDxgiFactory = nullptr;
......@@ -460,6 +459,14 @@ Renderer11::Renderer11(egl::Display *display)
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)
{
mAvailableFeatureLevels.push_back(D3D_FEATURE_LEVEL_11_0);
......@@ -592,10 +599,11 @@ egl::Error Renderer11::initialize()
{
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.
// 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);
mDeviceContext3 = d3d11::DynamicCastComObject<ID3D11DeviceContext3>(mDeviceContext);
IDXGIDevice *dxgiDevice = nullptr;
result = mDevice->QueryInterface(__uuidof(IDXGIDevice), (void **)&dxgiDevice);
......@@ -2422,6 +2430,7 @@ void Renderer11::release()
SafeRelease(mDxgiFactory);
SafeRelease(mDxgiAdapter);
SafeRelease(mDeviceContext3);
SafeRelease(mDeviceContext1);
if (mDeviceContext)
......@@ -2632,6 +2641,7 @@ int Renderer11::getMajorShaderModel() const
{
switch (mRenderer11DeviceCaps.featureLevel)
{
case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
return D3D11_SHADER_MAJOR_VERSION; // 5
case D3D_FEATURE_LEVEL_10_1:
......@@ -2650,6 +2660,7 @@ int Renderer11::getMinorShaderModel() const
{
switch (mRenderer11DeviceCaps.featureLevel)
{
case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
return D3D11_SHADER_MINOR_VERSION; // 0
case D3D_FEATURE_LEVEL_10_1:
......@@ -2668,6 +2679,7 @@ std::string Renderer11::getShaderModelSuffix() const
{
switch (mRenderer11DeviceCaps.featureLevel)
{
case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
return "";
case D3D_FEATURE_LEVEL_10_1:
......
......@@ -599,6 +599,7 @@ class Renderer11 : public RendererD3D
Renderer11DeviceCaps mRenderer11DeviceCaps;
ID3D11DeviceContext *mDeviceContext;
ID3D11DeviceContext1 *mDeviceContext1;
ID3D11DeviceContext3 *mDeviceContext3;
IDXGIAdapter *mDxgiAdapter;
DXGI_ADAPTER_DESC mAdapterDescription;
char mDescription[128];
......
......@@ -7,6 +7,10 @@
# Code generation for the DXGI support tables. Determines which formats
# 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:
# 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
......@@ -115,6 +119,19 @@ const DXGISupport &GetDXGISupport_11_0(DXGI_FORMAT dxgiFormat)
// 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
......@@ -138,6 +155,8 @@ const DXGISupport &GetDXGISupport(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL feat
return GetDXGISupport_10_1(dxgiFormat);
case D3D_FEATURE_LEVEL_11_0:
return GetDXGISupport_11_0(dxgiFormat);
case D3D_FEATURE_LEVEL_11_1:
return GetDXGISupport_11_1(dxgiFormat);
default:
return GetDefaultSupport();
}}
......@@ -151,7 +170,7 @@ const DXGISupport &GetDXGISupport(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL feat
table_init = ""
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 = {
'texture2D': macro_prefix + '2D',
......@@ -175,6 +194,7 @@ def do_format(format_data):
fl_10_1_supported = set()
fl_11_0_supported = set()
fl_11_0_check = set()
fl_11_1_supported = set()
fl_10_0_check_10_1_supported = set()
fl_10_0_check_11_0_supported = set()
......@@ -195,8 +215,7 @@ def do_format(format_data):
elif support == '11_0':
fl_11_0_supported.update(d3d_flag)
elif support == '11_1':
# TODO(jmadill): D3D 11.1 handling
never_supported.update(d3d_flag)
fl_11_1_supported.update(d3d_flag)
elif support == 'dxgi1_2':
# TODO(jmadill): DXGI 1.2 handling.
always_supported.update(d3d_flag)
......@@ -216,7 +235,7 @@ def do_format(format_data):
print("Data specification error: " + support)
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
optional_for_fl = optionally_supported
if feature_level == '9_3':
......@@ -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_1_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))
never = ' | '.join(sorted(never_supported))
......@@ -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'],
'10_0': table_data_1['10_0'] + table_data_2['10_0'],
'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:
file_data = dxgi_file.read()
dxgi_file.close()
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:
table_data = join_table_data(table_data, do_format(format_data))
......@@ -274,7 +301,8 @@ with open('dxgi_support_data.json') as dxgi_file:
table_data_9_3=table_data['9_3'],
table_data_10_0=table_data['10_0'],
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:
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