changeset 2518:3a1b56ab8749

d3d11 accepts RGBTexture
author a.parshin
date Thu, 09 Oct 2014 00:06:47 +0300
parents 09c3114c6e4e
children b36b858a5175
files Engine/Game.cpp Engine/Graphics/GammaControl.cpp Engine/Graphics/IRender.h Engine/Graphics/Render.cpp Engine/Graphics/Render.h Engine/Graphics/RenderD3D11.cpp Engine/Graphics/RenderD3D11.h Engine/Graphics/Texture.cpp Engine/Graphics/Texture.h Engine/MMT.cpp Scripts/Keep this folder
diffstat 10 files changed, 316 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/Engine/Game.cpp	Wed Oct 08 22:32:54 2014 +0600
+++ b/Engine/Game.cpp	Thu Oct 09 00:06:47 2014 +0300
@@ -4606,7 +4606,7 @@
 	static_assert(sizeof(RenderVertexSoft) == 0x30, "Wrong type size");
 	static_assert(sizeof(RenderBillboard) == 0x34, "Wrong type size");
 	static_assert(sizeof(Texture) == 0x48, "Wrong type size");
-	static_assert(sizeof(RGBTexture) == 0x28, "Wrong type size");
+	//static_assert(sizeof(RGBTexture) == 0x28, "Wrong type size");
 	//static_assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4, "Wrong type size"); // + virtual dtor ptr
 	static_assert(sizeof(AudioPlayer) == 0xC84, "Wrong type size");
 	static_assert(sizeof(SoundDesc) == 0x78, "Wrong type size");
@@ -4697,10 +4697,10 @@
 	static_assert(sizeof(Party) == 0x16238, "Wrong type size");
 	static_assert(sizeof(GUIButton) == 0xBC, "Wrong type size");
 	static_assert(sizeof(GUIWindow) == 0x54, "Wrong type size");
-	static_assert(sizeof(GUIProgressBar) == 0x1B8, "Wrong type size");
+	//static_assert(sizeof(GUIProgressBar) == 0x1B8, "Wrong type size");
 	static_assert(sizeof(GUIFont) == 0x1020, "Wrong type size");
 	// static_assert(sizeof(stru262_TurnBased) == 0x40, "Wrong type size");
-	static_assert(sizeof(ArcomageGame) == 0xFB, "Wrong type size");
+	//static_assert(sizeof(ArcomageGame) == 0xFB, "Wrong type size");
 	static_assert(sizeof(CastSpellInfo) == 0x14, "Wrong type size");
 	static_assert(sizeof(ArcomageCard) == 0x6C, "Wrong type size");
 	static_assert(sizeof(stru320) == 0x3FC, "Wrong type size");
--- a/Engine/Graphics/GammaControl.cpp	Wed Oct 08 22:32:54 2014 +0600
+++ b/Engine/Graphics/GammaControl.cpp	Thu Oct 09 00:06:47 2014 +0300
@@ -17,8 +17,6 @@
 {
   if (pGammaControl)
     ErrD3D(pGammaControl->GetGammaRamp(0, &pDefaultRamp));
-  else
-    MessageBoxW(nullptr, L"Gamma control not active", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\GammaControl.cpp:83", 0);
 }
 
 //----- (0044F377) --------------------------------------------------------
@@ -53,8 +51,6 @@
 {
   if (pGammaControl)
     ErrD3D(pGammaControl->SetGammaRamp(0, pRamp));
-  else
-    MessageBoxW(nullptr, L"Gamma control not active", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\GammaControl.cpp:120", 0);
 }
 
 //----- (0044F45B) --------------------------------------------------------
--- a/Engine/Graphics/IRender.h	Wed Oct 08 22:32:54 2014 +0600
+++ b/Engine/Graphics/IRender.h	Thu Oct 09 00:06:47 2014 +0300
@@ -66,8 +66,11 @@
 
     virtual void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) = 0;
     virtual void ResetTextureClipRect() = 0;
+    virtual void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) = 0;
+
+    virtual void DrawTextureNew(float u, float v, struct Texture *) = 0;
+    virtual void DrawTextureNew(float u, float v, struct RGBTexture *) = 0;
     virtual void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) = 0;
-    virtual void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) = 0;
     virtual void DrawTextureIndexed(unsigned int uX, unsigned int uY, struct Texture *a4) = 0;
 
     virtual void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5) = 0;
--- a/Engine/Graphics/Render.cpp	Wed Oct 08 22:32:54 2014 +0600
+++ b/Engine/Graphics/Render.cpp	Thu Oct 09 00:06:47 2014 +0300
@@ -6408,6 +6408,15 @@
          0xF800 & (r << (6 + 5 + 5 - 8));
 }
 
+void Render::DrawTextureNew(float u, float v, Texture *a4)
+{
+  __debugbreak();
+}
+
+void Render::DrawTextureNew(float u, float v, RGBTexture *a4)
+{
+  DrawTextureRGB(640 * u, 480 * v, a4);
+}
 
 //----- (004A5BE3) --------------------------------------------------------
 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4)
--- a/Engine/Graphics/Render.h	Wed Oct 08 22:32:54 2014 +0600
+++ b/Engine/Graphics/Render.h	Thu Oct 09 00:06:47 2014 +0300
@@ -250,8 +250,11 @@
 
   virtual void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
   virtual void ResetTextureClipRect();
+  virtual void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture);
+
+  virtual void DrawTextureNew(float u, float v, struct Texture *);
+  virtual void DrawTextureNew(float u, float v, struct RGBTexture *);
   virtual void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4);
-  virtual void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture);
   virtual void DrawTextureIndexed(unsigned int uX, unsigned int uY, struct Texture *a4);
 
   virtual void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5);
--- a/Engine/Graphics/RenderD3D11.cpp	Wed Oct 08 22:32:54 2014 +0600
+++ b/Engine/Graphics/RenderD3D11.cpp	Thu Oct 09 00:06:47 2014 +0300
@@ -4,6 +4,8 @@
 #include "../ErrorHandling.h"
 #include "RenderD3D11.h"
 #include "../mm7_data.h"
+#include "Texture.h"
+#include "../Log.h"
 
 #define ErrorD3D(x)\
 {\
@@ -20,6 +22,10 @@
 RenderD3D11::~RenderD3D11() {}
 
 
+bool CompileShader(ID3D11Device *d3dd, const wchar_t *pShaderSourceFile, D3D11_INPUT_ELEMENT_DESC *input_desc, int input_desc_size,
+                   ID3D11VertexShader **vertex_out, ID3D11PixelShader **pixel_out, ID3D11InputLayout **layout_out);
+
+
 void RenderD3D11::ClearBlack() {__debugbreak();}
 void RenderD3D11::SaveWinnersCertificate(const char *a1) {__debugbreak();}
 void RenderD3D11::Present() {__debugbreak();}
@@ -36,8 +42,8 @@
 void RenderD3D11::UnlockBackBuffer() {__debugbreak();}
 void RenderD3D11::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) {__debugbreak();}
 void RenderD3D11::UnlockFrontBuffer() {__debugbreak();}
-void RenderD3D11::RestoreFrontBuffer() {__debugbreak();}
-void RenderD3D11::RestoreBackBuffer() {__debugbreak();}
+void RenderD3D11::RestoreFrontBuffer() {}
+void RenderD3D11::RestoreBackBuffer() {}
 void RenderD3D11::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) {__debugbreak();}
 void RenderD3D11::BltBackToFontFast(int a2, int a3, RECT *a4) {__debugbreak();}
 void RenderD3D11::BeginSceneD3D() {__debugbreak();}
@@ -136,6 +142,73 @@
   __debugbreak();
 }
 
+void RenderD3D11::DrawTextureNew(float u, float v, Texture *tex)
+{
+  d3dc->OMSetRenderTargets(1, &primary_srv, nullptr);
+
+  d3dc->VSSetShader(vs_test, nullptr, 0);
+  d3dc->PSSetShader(ps_test, nullptr, 0);
+
+  uint uOffset = 0;
+  uint uStride = 4 * sizeof(float);
+  d3dc->IASetVertexBuffers(0, 1, &vb_test, &uStride, &uOffset);
+  d3dc->IASetInputLayout(layout_test);
+  d3dc->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+  d3dc->Draw(6, 0);
+
+  pSwapChain->Present(0, 0);
+}
+
+void RenderD3D11::DrawTextureNew(float u, float v, RGBTexture *tex)
+{
+  if (!tex->d3d11_srv)
+  {
+    auto desc = tex->d3d11_desc = new D3D11_TEXTURE2D_DESC;
+    desc->Width = tex->uWidth;
+    desc->Height = tex->uHeight;
+    desc->ArraySize = 1;
+    desc->MipLevels = 1;
+    desc->Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+    desc->SampleDesc.Count = 1;
+    desc->SampleDesc.Quality = 0;
+    desc->Usage = D3D11_USAGE_DEFAULT;
+    desc->BindFlags = D3D11_BIND_SHADER_RESOURCE;
+    desc->CPUAccessFlags = 0;
+    desc->MiscFlags = 0;
+    
+    ID3D11Texture2D *vram_texture = nullptr;
+    ErrD3D(d3dd->CreateTexture2D(desc, nullptr, &vram_texture));
+
+    D3D11_TEXTURE2D_DESC ram_desc;
+    memcpy(&ram_desc, desc, sizeof(ram_desc));
+    ram_desc.Usage = D3D11_USAGE_STAGING;
+    ram_desc.BindFlags = 0;
+    ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+    
+    ID3D11Texture2D *ram_texture = nullptr;
+    ErrD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
+
+    D3D11_MAPPED_SUBRESOURCE map;
+    ErrD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
+    for (unsigned int y = 0; y < desc->Height; ++y)
+      for (unsigned int x = 0; x < desc->Width; ++x)
+      {
+        auto src = tex->pPixels + y * tex->uWidth + x;
+        auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
+
+        extern unsigned __int32 Color32(unsigned __int16 color16);
+        *dst = Color32(*src);
+      }
+
+    d3dc->Unmap(ram_texture, 0);
+    d3dc->CopyResource(vram_texture, ram_texture);
+    ram_texture->Release();
+    
+    ErrD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, (ID3D11ShaderResourceView **)&tex->d3d11_srv));
+    vram_texture->Release();
+  }
+}
+
 bool RenderD3D11::IsGammaSupported()
 {
   return false;
@@ -231,8 +304,8 @@
 
   unsigned int device_flags = 0;//D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT;
   #ifndef NODEBUG
-    device_flags |= 0/*D3D11_CREATE_DEVICE_DEBUG | D3D11_CREATE_DEVICE_DEBUGGABLE*/;
-   #endif
+    device_flags |= D3D11_CREATE_DEVICE_DEBUG;
+  #endif
 
   HRESULT (__stdcall *dll_D3D11CreateDeviceAndSwapChain)(IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, CONST DXGI_SWAP_CHAIN_DESC* pSwapChainDesc, IDXGISwapChain** ppSwapChain, ID3D11Device** ppDevice, D3D_FEATURE_LEVEL* pFeatureLevel, ID3D11DeviceContext** ppImmediateContext);
   dll_D3D11CreateDeviceAndSwapChain = (decltype(dll_D3D11CreateDeviceAndSwapChain))GetProcAddress(d3d_lib, "D3D11CreateDeviceAndSwapChain");
@@ -321,5 +394,195 @@
   viewport.MaxDepth = 1;
   d3dc->RSSetViewports(1, &viewport);
 
+
+  D3D11_INPUT_ELEMENT_DESC layout_desc[] =
+  {
+    { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0,  0, D3D11_INPUT_PER_VERTEX_DATA, 0 },  
+    { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT,       0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 },  
+  };
+  CompileShader(d3dd, L"data/shaders/SimpleTexture.shader", layout_desc, 2, &vs_test, &ps_test, &layout_test);
+
+      {
+        uint uVertexSize = 4 * sizeof(float);
+
+        float test_mesh[] =
+        {
+          -1,  1, 0.5, 1,
+           1,  1, 0.5, 1,
+          -1, -1, 0.5, 1,
+
+          -1, -1, 0.5, 1,
+           1,  1, 0.5, 1,
+           1, -1, 0.5, 1
+        };
+
+        D3D11_BUFFER_DESC vbdesc;
+        vbdesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
+        vbdesc.ByteWidth = 6 * uVertexSize;
+        vbdesc.CPUAccessFlags = 0;
+        vbdesc.MiscFlags = 0;
+        vbdesc.StructureByteStride = 0;
+        vbdesc.Usage = D3D11_USAGE_DEFAULT;
+
+        D3D11_SUBRESOURCE_DATA vbdata;
+        vbdata.pSysMem = test_mesh;
+        vbdata.SysMemPitch = 0;
+        vbdata.SysMemSlicePitch = 0;
+
+        d3dd->CreateBuffer(&vbdesc, &vbdata, &vb_test);
+      }
+
   return true;
+}
+
+
+
+
+
+
+ID3DBlob *DoD3DCompiling(const wchar_t *shader_name, const char *pShaderSource, uint uShaderSourceLen, const char *pEntry, const char *pVersionString, uint uCompileOptions);
+void DoCompile(const wchar_t *pFilename, const char *pShaderSource, unsigned int uShaderSourceLen,
+               unsigned char **vs, unsigned int *vs_size, unsigned char **ps, unsigned int *ps_size);
+bool CompileShader(ID3D11Device *d3dd, const wchar_t *pShaderSourceFile, D3D11_INPUT_ELEMENT_DESC *input_desc, int input_desc_size,
+                   ID3D11VertexShader **vertex_out, ID3D11PixelShader **pixel_out, ID3D11InputLayout **layout_out)
+{
+  unsigned char *vs, *ps;
+  unsigned int vs_size, ps_size;
+
+  HANDLE hSourceFile = CreateFileW(pShaderSourceFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
+  if (hSourceFile == INVALID_HANDLE_VALUE)
+    Error("%S:\n\nCannot read shader file", pShaderSourceFile);
+
+  char *pShaderSource = nullptr;
+  int   uShaderSourceLen = 0;
+  uint uFileSize = GetFileSize(hSourceFile, nullptr);
+  {
+    DWORD w;
+    char *p = new char[uFileSize + 1];
+    ReadFile(hSourceFile, p, uFileSize, &w, nullptr);
+    CloseHandle(hSourceFile);
+    p[uFileSize] = 0;
+
+    pShaderSource = p;
+    uShaderSourceLen = uFileSize;
+  }
+
+  DoCompile(pShaderSourceFile, pShaderSource, uShaderSourceLen, &vs, &vs_size, &ps, &ps_size);
+
+  ErrD3D(d3dd->CreateVertexShader(vs, vs_size, nullptr, vertex_out));
+  ErrD3D(d3dd->CreatePixelShader(ps, ps_size, nullptr, pixel_out));
+  ErrD3D(d3dd->CreateInputLayout(input_desc, input_desc_size, vs, vs_size, layout_out));
+
+  delete [] vs;
+  delete [] ps;
+
+  return true;
+}
+
+
+
+static HMODULE compiler_dll = nullptr;
+void DoCompile(const wchar_t *pFilename, const char *pSahderSource, unsigned int uShaderSourceLen,
+               unsigned char **vs, unsigned int *vs_size, unsigned char **ps, unsigned int *ps_size)
+{
+  const char *pVSEntry = "vs",
+             *pVSVersionString = "vs_4_0";
+  const char *pPSEntry = "main",
+             *pPSVersionString = "ps_4_0";
+
+
+  uint uVSCompileOptions =
+  #ifndef NDEBUG
+    D3D10_SHADER_SKIP_VALIDATION     |
+    D3D10_SHADER_SKIP_OPTIMIZATION   |
+    D3D10_SHADER_PREFER_FLOW_CONTROL;
+  #else
+    D3D10_SHADER_SKIP_VALIDATION     |
+    D3D10_SHADER_OPTIMIZATION_LEVEL3 |
+    D3D10_SHADER_WARNINGS_ARE_ERRORS |
+    D3D10_SHADER_AVOID_FLOW_CONTROL  |
+    D3D10_SHADER_ENABLE_STRICTNESS   |
+    D3D10_SHADER_IEEE_STRICTNESS;
+  #endif
+  
+  *vs_size = 0;
+  *vs = nullptr;
+  {
+    auto pVSBlob = DoD3DCompiling(pFilename, pSahderSource, uShaderSourceLen, pVSEntry, pVSVersionString, uVSCompileOptions);
+    if (pVSBlob)
+    {
+      *vs = new unsigned char[*vs_size = pVSBlob->GetBufferSize()];
+      memcpy(*vs, pVSBlob->GetBufferPointer(), *vs_size);
+
+      pVSBlob->Release();
+    }
+  }
+
+
+  uint uPSCompileOptions =
+  #ifndef NDEBUG
+    D3D10_SHADER_SKIP_VALIDATION     |
+    D3D10_SHADER_SKIP_OPTIMIZATION   |
+    D3D10_SHADER_PREFER_FLOW_CONTROL;
+  #else
+    D3D10_SHADER_SKIP_VALIDATION     |
+    D3D10_SHADER_OPTIMIZATION_LEVEL3 |
+    D3D10_SHADER_WARNINGS_ARE_ERRORS |
+    D3D10_SHADER_AVOID_FLOW_CONTROL  |
+    D3D10_SHADER_ENABLE_STRICTNESS   |
+    D3D10_SHADER_IEEE_STRICTNESS;
+  #endif
+
+  *ps_size = 0;
+  *ps = nullptr;
+  {
+    auto pPSBlob = DoD3DCompiling(pFilename, pSahderSource, uShaderSourceLen, pPSEntry, pPSVersionString, uPSCompileOptions);
+    if (pPSBlob)
+    {
+      *ps = new unsigned char[*ps_size = pPSBlob->GetBufferSize()];
+      memcpy(*ps, pPSBlob->GetBufferPointer(), *ps_size);
+
+      pPSBlob->Release();
+    }
+  }
+}
+
+ID3DBlob *DoD3DCompiling(const wchar_t *shader_name, const char *pShaderSource, uint uShaderSourceLen, const char *pEntry, const char *pVersionString, uint uCompileOptions)
+{
+  ID3DBlob *pShader,
+           *pErrors;
+
+  if (!compiler_dll)
+    for (int i = 45; i >= 38; --i)
+    {
+      wchar_t dll_name[64];
+      swprintf(dll_name, L"d3dcompiler_%u.dll", i);
+
+      compiler_dll = LoadLibraryW(dll_name);
+      if (compiler_dll)
+        break;
+    }
+
+  if (!compiler_dll)
+    Error("Cannot find any suitable d3dcompiler.dll");
+
+  typedef HRESULT (__stdcall *fnD3DCompile)(const void * pSrcData, SIZE_T SrcDataSize, LPCSTR pSourceName, CONST D3D_SHADER_MACRO* pDefines, ID3DInclude* pInclude, LPCSTR pEntrypoint, LPCSTR pTarget, UINT Flags1, UINT Flags2, ID3DBlob** ppCode, ID3DBlob** ppErrorMsgs);
+  auto pD3DCompile  = (fnD3DCompile)GetProcAddress(compiler_dll, "D3DCompile");
+
+  HRESULT hr = pD3DCompile(pShaderSource, uShaderSourceLen, nullptr, nullptr, nullptr, pEntry, pVersionString, uCompileOptions, 0, &pShader, &pErrors);
+
+  if (FAILED(hr))
+  {
+    if (pErrors)
+      Error("%S (%s) build failed:\n\n%s", shader_name, pVersionString, pErrors->GetBufferPointer());
+    else
+      Error("%S (%s) build failed", shader_name, pVersionString);
+  }
+  else if (pErrors)
+  {
+    Log::Warning(L"%s (%S) build warnings:\n\n%S", shader_name, pVersionString, pErrors->GetBufferPointer());
+    pErrors->Release();
+  }
+
+  return pShader;
 }
\ No newline at end of file
--- a/Engine/Graphics/RenderD3D11.h	Wed Oct 08 22:32:54 2014 +0600
+++ b/Engine/Graphics/RenderD3D11.h	Thu Oct 09 00:06:47 2014 +0300
@@ -76,8 +76,11 @@
 
   virtual void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
   virtual void ResetTextureClipRect();
+  virtual void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture);
+  
+  virtual void DrawTextureNew(float u, float v, struct Texture *);
+  virtual void DrawTextureNew(float u, float v, struct RGBTexture *);
   virtual void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4);
-  virtual void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture);
   virtual void DrawTextureIndexed(unsigned int uX, unsigned int uY, struct Texture *a4);
 
   virtual void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5);
@@ -169,4 +172,9 @@
     ID3D11DeviceContext     *d3dc;
     ID3D11RenderTargetView  *primary_srv;
     ID3D11DepthStencilView  *depth_srv;
+
+    ID3D11VertexShader *vs_test;
+    ID3D11PixelShader  *ps_test;
+    ID3D11InputLayout  *layout_test;
+    ID3D11Buffer       *vb_test;
 };
--- a/Engine/Graphics/Texture.cpp	Wed Oct 08 22:32:54 2014 +0600
+++ b/Engine/Graphics/Texture.cpp	Thu Oct 09 00:06:47 2014 +0300
@@ -1278,6 +1278,8 @@
   //if ( !(this->_allocation_flags & 1) )
     //free(this->pPixels);
   //else
+    //free(this->pPixels);
+  if (this->pPixels)
     free(this->pPixels);
   this->_allocation_flags = 0;
   this->pPixels = 0;
@@ -1286,6 +1288,10 @@
   this->uWidth = 0;
   this->field_1A = 0;
   this->field_18 = 0;
+
+  if (d3d11_srv)
+    __debugbreak(); // should properly release this stuff
+  d3d11_srv = nullptr;
 }
 
 //----- (0040E55E) --------------------------------------------------------
@@ -1487,6 +1493,9 @@
   field_1A = 0;
   field_18 = 0;
   _allocation_flags = 0;
+
+  d3d11_srv = nullptr;
+  d3d11_desc = nullptr;
 }
 //----- (0044E1EC) --------------------------------------------------------
 int TextureFrameTable::FromFileTxt(const char *Args)
--- a/Engine/Graphics/Texture.h	Wed Oct 08 22:32:54 2014 +0600
+++ b/Engine/Graphics/Texture.h	Thu Oct 09 00:06:47 2014 +0300
@@ -1,6 +1,6 @@
 #pragma once
 #include <stdio.h>
-#include<array>
+#include <array>
 
 
 
@@ -26,6 +26,9 @@
   __int16 field_1E;
   int _allocation_flags; // & 1 - malloc, else custom allocator
   unsigned __int16 *pPixels;
+
+  struct ID3D11ShaderResourceView *d3d11_srv;
+  struct D3D11_TEXTURE2D_DESC     *d3d11_desc;
 };
 #pragma pack(pop)
 
--- a/Engine/MMT.cpp	Wed Oct 08 22:32:54 2014 +0600
+++ b/Engine/MMT.cpp	Thu Oct 09 00:06:47 2014 +0300
@@ -57,24 +57,22 @@
       }
     }
   }
-  char pContainerName[64];
 
   if (use_MMT)
-  {
-    sprintf(pContainerName, "data\\New_Icons/%s", "MMTTITLE.pcx");
-    tex.LoadPCXFile(pContainerName, 0);
-  }
+    tex.LoadPCXFile("data/New_Icons/MMTTITLE.pcx", 0);
   else
     tex.Load("mm6title.pcx", 2);
 
   pRenderer->BeginScene();
-  pRenderer->DrawTextureRGB(0, 0, &tex);
-  free(tex.pPixels);
-  tex.pPixels = 0;
+  pRenderer->DrawTextureNew(0, 0, &tex);
+  Sleep(5000);
+
+  tex.Release();
+
   MainMenuUI_LoadFontsAndSomeStuff();
 
   if (use_MMT)
-    DrawMMTCopyrightWindow();//Text message in ÌÌÒ menu
+    DrawMMTCopyrightWindow();
   else
     DrawMM7CopyrightWindow();