From a43223256e32142f92bf2a091e5059f8f8f8a005 Mon Sep 17 00:00:00 2001
From: Joshua Ashton <joshua@froggi.es>
Date: Mon, 27 Jan 2020 01:06:48 +0000
Subject: [PATCH] [d3d9] Fix GetTextureStageState using unmapped types

Closes #1378
---
 src/d3d9/d3d9_device.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp
index 9acf4164..e03881af 100644
--- a/src/d3d9/d3d9_device.cpp
+++ b/src/d3d9/d3d9_device.cpp
@@ -2067,6 +2067,8 @@ namespace dxvk {
           DWORD                    Stage,
           D3DTEXTURESTAGESTATETYPE Type,
           DWORD*                   pValue) {
+    auto dxvkType = RemapTextureStageStateType(Type);
+
     if (unlikely(pValue == nullptr))
       return D3DERR_INVALIDCALL;
 
@@ -2075,10 +2077,10 @@ namespace dxvk {
     if (unlikely(Stage >= caps::TextureStageCount))
       return D3DERR_INVALIDCALL;
 
-    if (unlikely(Type >= TextureStageStateCount))
+    if (unlikely(dxvkType >= TextureStageStateCount))
       return D3DERR_INVALIDCALL;
 
-    *pValue = m_state.textureStages[Stage][Type];
+    *pValue = m_state.textureStages[Stage][dxvkType];
 
     return D3D_OK;
   }