From 56fe52ca3cff3e1cecf8aeef012929abe44bd432 Mon Sep 17 00:00:00 2001
From: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Date: Fri, 17 Jul 2020 10:15:00 +0200
Subject: [PATCH] [d3d11] Move D3D11Shader implementation to its own file

And resolve some include madness. Necessary because D3D11Shader::GetDevice
needs to know the full definition of D3D11Device, but D3D11Device needs
to know the full definition of the other shader-related classes.
---
 src/d3d11/d3d11_context_state.h |  2 +-
 src/d3d11/d3d11_device.cpp      |  2 +-
 src/d3d11/d3d11_initializer.h   |  1 +
 src/d3d11/d3d11_shader.h        | 66 -----------------------------
 src/d3d11/d3d11_shader_types.h  | 73 +++++++++++++++++++++++++++++++++
 5 files changed, 76 insertions(+), 68 deletions(-)
 create mode 100644 src/d3d11/d3d11_shader_types.h

diff --git a/src/d3d11/d3d11_context_state.h b/src/d3d11/d3d11_context_state.h
index eca2a3c9..59c13ccb 100644
--- a/src/d3d11/d3d11_context_state.h
+++ b/src/d3d11/d3d11_context_state.h
@@ -6,7 +6,7 @@
 #include "d3d11_input_layout.h"
 #include "d3d11_query.h"
 #include "d3d11_sampler.h"
-#include "d3d11_shader.h"
+#include "d3d11_shader_types.h"
 #include "d3d11_state.h"
 #include "d3d11_view_dsv.h"
 #include "d3d11_view_rtv.h"
diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp
index 13db3b60..914a572c 100644
--- a/src/d3d11/d3d11_device.cpp
+++ b/src/d3d11/d3d11_device.cpp
@@ -17,7 +17,7 @@
 #include "d3d11_query.h"
 #include "d3d11_resource.h"
 #include "d3d11_sampler.h"
-#include "d3d11_shader.h"
+#include "d3d11_shader_types.h"
 #include "d3d11_state_object.h"
 #include "d3d11_swapchain.h"
 #include "d3d11_texture.h"
diff --git a/src/d3d11/d3d11_initializer.h b/src/d3d11/d3d11_initializer.h
index de6e6099..46656d4c 100644
--- a/src/d3d11/d3d11_initializer.h
+++ b/src/d3d11/d3d11_initializer.h
@@ -2,6 +2,7 @@
 
 #include "d3d11_buffer.h"
 #include "d3d11_texture.h"
+#include "d3d11_view_uav.h"
 
 namespace dxvk {
 
diff --git a/src/d3d11/d3d11_shader.h b/src/d3d11/d3d11_shader.h
index 3a26a46c..4d3da55c 100644
--- a/src/d3d11/d3d11_shader.h
+++ b/src/d3d11/d3d11_shader.h
@@ -59,72 +59,6 @@ namespace dxvk {
   };
   
   
-  /**
-   * \brief Common shader interface
-   * 
-   * Implements methods for all D3D11*Shader
-   * interfaces and stores the actual shader
-   * module object.
-   */
-  template<typename D3D11Interface, typename D3D10Interface>
-  class D3D11Shader : public D3D11DeviceChild<D3D11Interface> {
-    using D3D10ShaderClass = D3D10Shader<D3D10Interface, D3D11Interface>;
-  public:
-    
-    D3D11Shader(D3D11Device* device, const D3D11CommonShader& shader)
-    : m_device(device), m_shader(shader), m_d3d10(this) { }
-    
-    ~D3D11Shader() { }
-    
-    HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) final {
-      *ppvObject = nullptr;
-      
-      if (riid == __uuidof(IUnknown)
-       || riid == __uuidof(ID3D11DeviceChild)
-       || riid == __uuidof(D3D11Interface)) {
-        *ppvObject = ref(this);
-        return S_OK;
-      }
-      
-      if (riid == __uuidof(IUnknown)
-       || riid == __uuidof(ID3D10DeviceChild)
-       || riid == __uuidof(D3D10Interface)) {
-        *ppvObject = ref(&m_d3d10);
-        return S_OK;
-      }
-      
-      Logger::warn("D3D11Shader::QueryInterface: Unknown interface query");
-      return E_NOINTERFACE;
-    }
-    
-    void STDMETHODCALLTYPE GetDevice(ID3D11Device **ppDevice) final {
-      *ppDevice = m_device.ref();
-    }
-    
-    const D3D11CommonShader* GetCommonShader() const {
-      return &m_shader;
-    }
-
-    D3D10ShaderClass* GetD3D10Iface() {
-      return &m_d3d10;
-    }
-
-  private:
-    
-    Com<D3D11Device>  m_device;
-    D3D11CommonShader m_shader;
-    D3D10ShaderClass  m_d3d10;
-    
-  };
-  
-  using D3D11VertexShader   = D3D11Shader<ID3D11VertexShader,   ID3D10VertexShader>;
-  using D3D11HullShader     = D3D11Shader<ID3D11HullShader,     ID3D10DeviceChild>;
-  using D3D11DomainShader   = D3D11Shader<ID3D11DomainShader,   ID3D10DeviceChild>;
-  using D3D11GeometryShader = D3D11Shader<ID3D11GeometryShader, ID3D10GeometryShader>;
-  using D3D11PixelShader    = D3D11Shader<ID3D11PixelShader,    ID3D10PixelShader>;
-  using D3D11ComputeShader  = D3D11Shader<ID3D11ComputeShader,  ID3D10DeviceChild>;
-  
-  
   /**
    * \brief Shader module set
    * 
diff --git a/src/d3d11/d3d11_shader_types.h b/src/d3d11/d3d11_shader_types.h
new file mode 100644
index 00000000..2510c1c8
--- /dev/null
+++ b/src/d3d11/d3d11_shader_types.h
@@ -0,0 +1,73 @@
+#pragma once
+
+#include "d3d11_device.h"
+#include "d3d11_shader.h"
+
+namespace dxvk {
+
+  /**
+   * \brief Common shader interface
+   * 
+   * Implements methods for all D3D11*Shader
+   * interfaces and stores the actual shader
+   * module object.
+   */
+  template<typename D3D11Interface, typename D3D10Interface>
+  class D3D11Shader : public D3D11DeviceChild<D3D11Interface> {
+    using D3D10ShaderClass = D3D10Shader<D3D10Interface, D3D11Interface>;
+  public:
+    
+    D3D11Shader(D3D11Device* device, const D3D11CommonShader& shader)
+    : m_device(device), m_shader(shader), m_d3d10(this) { }
+    
+    ~D3D11Shader() { }
+    
+    HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) final {
+      *ppvObject = nullptr;
+      
+      if (riid == __uuidof(IUnknown)
+       || riid == __uuidof(ID3D11DeviceChild)
+       || riid == __uuidof(D3D11Interface)) {
+        *ppvObject = ref(this);
+        return S_OK;
+      }
+      
+      if (riid == __uuidof(IUnknown)
+       || riid == __uuidof(ID3D10DeviceChild)
+       || riid == __uuidof(D3D10Interface)) {
+        *ppvObject = ref(&m_d3d10);
+        return S_OK;
+      }
+      
+      Logger::warn("D3D11Shader::QueryInterface: Unknown interface query");
+      return E_NOINTERFACE;
+    }
+    
+    void STDMETHODCALLTYPE GetDevice(ID3D11Device **ppDevice) final {
+      *ppDevice = m_device.ref();
+    }
+    
+    const D3D11CommonShader* GetCommonShader() const {
+      return &m_shader;
+    }
+
+    D3D10ShaderClass* GetD3D10Iface() {
+      return &m_d3d10;
+    }
+
+  private:
+    
+    Com<D3D11Device>  m_device;
+    D3D11CommonShader m_shader;
+    D3D10ShaderClass  m_d3d10;
+    
+  };
+  
+  using D3D11VertexShader   = D3D11Shader<ID3D11VertexShader,   ID3D10VertexShader>;
+  using D3D11HullShader     = D3D11Shader<ID3D11HullShader,     ID3D10DeviceChild>;
+  using D3D11DomainShader   = D3D11Shader<ID3D11DomainShader,   ID3D10DeviceChild>;
+  using D3D11GeometryShader = D3D11Shader<ID3D11GeometryShader, ID3D10GeometryShader>;
+  using D3D11PixelShader    = D3D11Shader<ID3D11PixelShader,    ID3D10PixelShader>;
+  using D3D11ComputeShader  = D3D11Shader<ID3D11ComputeShader,  ID3D10DeviceChild>;
+
+}
\ No newline at end of file