annotate Engine/Graphics/RenderD3D11.cpp @ 2572:d87bfbd3bb3b

Step towards unification of Texture and RGBTexture (class Image)
author a.parshin
date Sat, 05 Mar 2016 01:51:54 +0200
parents c674d547cc7c
children 0c67be4ec900
rev   line source
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
1 #include <d3dcompiler.h>
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
2 #include <comdef.h> // _com_error
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
3
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2536
diff changeset
4 #include "Engine/Engine.h"
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
5 #include "RenderD3D11.h"
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
6 #include "Texture.h"
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
7 #include "Sprites.h"
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
8
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
9 #define ErrorD3D(x)\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
10 {\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
11 HRESULT hr = x;\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
12 if (FAILED(hr))\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
13 {\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
14 _com_error com_error(hr);\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
15 Error("HRESULT = %08X\n%S", hr, com_error.ErrorMessage());\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
16 }\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
17 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
18
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
19
2526
b1c516bf1102 IRender c-tor
a.parshin
parents: 2525
diff changeset
20 RenderD3D11::RenderD3D11(): IRender() {}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
21 RenderD3D11::~RenderD3D11() {}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
22
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
23
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
24 bool CompileShader(ID3D11Device *d3dd, const wchar_t *pShaderSourceFile, D3D11_INPUT_ELEMENT_DESC *input_desc, int input_desc_size,
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
25 ID3D11VertexShader **vertex_out, ID3D11PixelShader **pixel_out, ID3D11InputLayout **layout_out);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
26
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
27
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
28 void RenderD3D11::ClearBlack() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
29 void RenderD3D11::SaveWinnersCertificate(const char *a1) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
30 void RenderD3D11::_49FD3A_fullscreen() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
31 bool RenderD3D11::InitializeFullscreen() {__debugbreak(); return 0;}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
32 void RenderD3D11::CreateZBuffer() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
33 void RenderD3D11::Release() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
34 void RenderD3D11::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
35 void RenderD3D11::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
36 bool RenderD3D11::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) {__debugbreak(); return 0;}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
37 void RenderD3D11::GetTargetPixelFormat(DDPIXELFORMAT *pOut) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
38 void RenderD3D11::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
39 void RenderD3D11::UnlockBackBuffer() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
40 void RenderD3D11::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
41 void RenderD3D11::UnlockFrontBuffer() {__debugbreak();}
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
42 void RenderD3D11::RestoreFrontBuffer() {}
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
43 void RenderD3D11::RestoreBackBuffer() {}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
44 void RenderD3D11::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
45 void RenderD3D11::BltBackToFontFast(int a2, int a3, RECT *a4) {__debugbreak();}
2526
b1c516bf1102 IRender c-tor
a.parshin
parents: 2525
diff changeset
46 void RenderD3D11::BeginSceneD3D() {}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
47 unsigned int RenderD3D11::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) {__debugbreak(); return 0;}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
48 void RenderD3D11::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
49 void RenderD3D11::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
50 void RenderD3D11::DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, struct Texture *pTex, int uPackedID, unsigned int uColor, int a8) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
51 void RenderD3D11::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
52 void RenderD3D11::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
53 void RenderD3D11::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
54 void RenderD3D11::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
55 void RenderD3D11::_4A4CC9_AddSomeBillboard(struct stru6_stru1_indoor_sw_billboard *a1, int diffuse) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
56 void RenderD3D11::TransformBillboardsAndSetPalettesODM() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
57 void RenderD3D11::DrawBillboardList_BLV() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
58 void RenderD3D11::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
59 void RenderD3D11::ScreenFade(unsigned int color, float t) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
60 void RenderD3D11::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
61 void RenderD3D11::ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
62 void RenderD3D11::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, struct Texture *pTexture, int zVal) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
63 void RenderD3D11::DrawAura(unsigned int a2, unsigned int a3, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
64 void RenderD3D11::_4A65CC(unsigned int x, unsigned int y, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
65 void RenderD3D11::DrawTransparentRedShade(unsigned int a2, unsigned int a3, struct Texture *a4) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
66 void RenderD3D11::DrawTransparentGreenShade(signed int a2, signed int a3, struct Texture *pTexture) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
67 void RenderD3D11::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
68 void RenderD3D11::DrawMasked(signed int a2, signed int a3, struct Texture *pTexture, unsigned __int16 mask) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
69 void RenderD3D11::GetLeather(unsigned int a2, unsigned int a3, struct Texture *a4, __int16 height) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
70 void RenderD3D11::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
71 void RenderD3D11::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
72 void RenderD3D11::DrawTranslucent(unsigned int a2, unsigned int a3, struct Texture *a4) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
73 void RenderD3D11::DrawBuildingsD3D() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
74 void RenderD3D11::DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
75 void RenderD3D11::DrawOutdoorSkyD3D() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
76 void RenderD3D11::DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
77 void RenderD3D11::DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
78 void RenderD3D11::PrepareDecorationsRenderList_ODM() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
79 void RenderD3D11::DrawSpriteObjects_ODM() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
80 void RenderD3D11::RenderTerrainD3D() {__debugbreak();}
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
81 bool RenderD3D11::AreRenderSurfacesOk() {return true;}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
82 void RenderD3D11::SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
83 void RenderD3D11::SavePCXScreenshot() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
84 int RenderD3D11::_46À6ÀÑ_GetActorsInViewport(int pDepth) {__debugbreak(); return 0;}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
85 void RenderD3D11::BeginLightmaps() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
86 void RenderD3D11::EndLightmaps() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
87 void RenderD3D11::BeginLightmaps2() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
88 void RenderD3D11::EndLightmaps2() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
89 bool RenderD3D11::DrawLightmap(struct Lightmap *pLightmap, struct Vec3_float_ *pColorMult, float z_bias) {__debugbreak(); return 0;}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
90 void RenderD3D11::BeginDecals() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
91 void RenderD3D11::EndDecals() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
92 void RenderD3D11::DrawDecal(struct Decal *pDecal, float z_bias) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
93 void RenderD3D11::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
94 void RenderD3D11::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
95 void RenderD3D11::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
96 void RenderD3D11::am_Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
97 void RenderD3D11::am_Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
98
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
99 void RenderD3D11::Sub01() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
100
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
101
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
102
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
103
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
104 void RenderD3D11::PackScreenshot(unsigned int width, unsigned int height, void *out_data, unsigned int data_size, unsigned int *screenshot_size) {}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
105
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
106 void RenderD3D11::SetUIClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
107 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
108 ui_clip_rect.left = uX;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
109 ui_clip_rect.top = uY;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
110 ui_clip_rect.right = uZ;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
111 ui_clip_rect.bottom = uW;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
112 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
113
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
114 void RenderD3D11::ResetUIClipRect()
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
115 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
116 ui_clip_rect.left = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
117 ui_clip_rect.top = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
118 ui_clip_rect.right = window->GetWidth();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
119 ui_clip_rect.bottom = window->GetHeight();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
120 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
121
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
122 void RenderD3D11::PresentBlackScreen()
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
123 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
124 ClearTarget(0xFF000000);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
125 ErrorD3D(pSwapChain->Present(0, 0));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
126 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
127
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
128 void RenderD3D11::BeginScene() {}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
129 void RenderD3D11::EndScene() {}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
130
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
131 void RenderD3D11::ClearTarget(unsigned int uColor)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
132 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
133 float clear_color[] =
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
134 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
135 ((uColor & 0x00FF0000) >> 16) / 255.0f,
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
136 ((uColor & 0x0000FF00) >> 8) / 255.0f,
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
137 ((uColor & 0x000000FF) >> 0) / 255.0f,
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
138 ((uColor & 0xFF000000) >> 24) / 255.0f
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
139 };
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
140 d3dc->ClearRenderTargetView(primary_srv, clear_color);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
141 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
142
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
143 void RenderD3D11::ClearZBuffer(int, int)
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
144 {
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
145 d3dc->ClearDepthStencilView(default_depth_srv, D3D11_CLEAR_DEPTH, 1.0f, 0);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
146 }
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
147
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
148
2536
400edd7b0407 DrawTextureIndexed() func
Ritor1
parents: 2526
diff changeset
149 void RenderD3D11::DrawTextureIndexed(signed int x, signed int y, struct Texture *tex)
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
150 {
2536
400edd7b0407 DrawTextureIndexed() func
Ritor1
parents: 2526
diff changeset
151 PrepareTextureIndexed(tex);
400edd7b0407 DrawTextureIndexed() func
Ritor1
parents: 2526
diff changeset
152 DrawTexture((float)x / window->GetWidth(), (float)y / window->GetHeight(), tex->uTextureWidth, tex->uTextureHeight, tex->d3d11_srv, ui_blend_solid);
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
153 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
154
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
155
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
156 void RenderD3D11::DrawTextureAlphaNew(float u, float v, Image *img)
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
157 {
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
158 __debugbreak();
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
159 }
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
160
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
161 void RenderD3D11::DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, struct Texture *a4)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
162 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
163 PrepareTextureIndexed(a4);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
164 DrawTexture((float)uX / window->GetWidth(), (float)uY / window->GetHeight(), a4->uTextureWidth, a4->uTextureHeight, a4->d3d11_srv, ui_blend_alpha);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
165 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
166
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
167
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
168 void RenderD3D11::DrawTextureNew(float u, float v, Texture *tex)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
169 {
2521
a.parshin
parents: 2518
diff changeset
170 __debugbreak();
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
171 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
172
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
173
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
174 void RenderD3D11::DrawTextureNew(float u, float v, Image *tex)
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
175 {
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
176 __debugbreak();
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
177 }
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
178
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
179 void RenderD3D11::DrawText(signed int uX, signed int uY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
180 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
181 auto srv = PrepareFontTexture(pFontPixels, uCharWidth, uCharHeight, pFontPalette, uFaceColor, uShadowColor);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
182 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
183 DrawTexture((float)uX / window->GetWidth(), (float)uY / window->GetHeight(), uCharWidth, uCharHeight, srv, ui_blend_alpha);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
184 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
185 srv->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
186 }
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
187
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
188 void RenderD3D11::DrawTextAlpha(int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, bool present_time_transparency)
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
189 {
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
190 auto srv = PrepareFontTexture(font_pixels, a5, uFontHeight, pPalette);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
191 {
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
192 DrawTexture((float)x / window->GetWidth(), (float)y / window->GetHeight(), a5, uFontHeight, srv, ui_blend_alpha);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
193 }
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
194 srv->Release();
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
195 }
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
196
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
197 void RenderD3D11::DrawTexture(float u, float v, int texture_width, int texture_height, ID3D11ShaderResourceView *srv, ID3D11BlendState *blend)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
198 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
199 bool clipping = false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
200 if (ui_clip_rect.left != 0 || ui_clip_rect.top != 0
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
201 || ui_clip_rect.right != window->GetWidth() || ui_clip_rect.bottom != window->GetHeight())
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
202 clipping = true;
2521
a.parshin
parents: 2518
diff changeset
203
a.parshin
parents: 2518
diff changeset
204 float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
205 d3dc->OMSetRenderTargets(1, &primary_srv, default_depth_srv);
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
206 d3dc->OMSetBlendState(blend, blendFactor, 0xFFFFFFFF);
2521
a.parshin
parents: 2518
diff changeset
207 d3dc->OMSetDepthStencilState(ui_depthstencil, 1);
a.parshin
parents: 2518
diff changeset
208
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
209 {
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
210 struct cb_fast
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
211 {
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
212 float pos_x;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
213 float pos_y;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
214 float size_x;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
215 float size_y;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
216 };
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
217
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
218 D3D11_MAPPED_SUBRESOURCE map;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
219 d3dc->Map(ui_cb_fast, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
220 {
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
221 cb_fast data;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
222 {
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
223 data.pos_x = u;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
224 data.pos_y = v;
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
225 data.size_x = (float)texture_width / window->GetWidth();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
226 data.size_y = (float)texture_height / window->GetHeight();
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
227 }
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
228 memcpy(map.pData, &data, sizeof(data));
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
229 }
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
230 d3dc->Unmap(ui_cb_fast, 0);
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
231 }
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
232
2521
a.parshin
parents: 2518
diff changeset
233 d3dc->VSSetShader(ui_vs, nullptr, 0);
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
234 d3dc->VSSetConstantBuffers(0, 1, &ui_cb_fast);
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
235
2521
a.parshin
parents: 2518
diff changeset
236 d3dc->PSSetShader(ui_ps, nullptr, 0);
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
237 d3dc->PSSetConstantBuffers(0, 1, &ui_cb_fast);
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
238 d3dc->PSSetShaderResources(0, 1, &srv);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
239
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
240 if (clipping)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
241 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
242 d3dc->RSSetState(ui_rasterizer);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
243 d3dc->RSSetScissorRects(1, &ui_clip_rect);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
244 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
245 //d3dc->RSSetViewports(1, &ui_viewport);
2521
a.parshin
parents: 2518
diff changeset
246
a.parshin
parents: 2518
diff changeset
247 uint uOffset = 0;
a.parshin
parents: 2518
diff changeset
248 uint uStride = 4 * sizeof(float);
a.parshin
parents: 2518
diff changeset
249 d3dc->IASetVertexBuffers(0, 1, &ui_vb, &uStride, &uOffset);
a.parshin
parents: 2518
diff changeset
250 d3dc->IASetInputLayout(ui_layout);
a.parshin
parents: 2518
diff changeset
251 d3dc->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
a.parshin
parents: 2518
diff changeset
252
a.parshin
parents: 2518
diff changeset
253 d3dc->Draw(6, 0);
a.parshin
parents: 2518
diff changeset
254
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
255 if (clipping)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
256 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
257 d3dc->RSSetState(default_rasterizer);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
258 //d3dc->RSSetScissorRects(0, nullptr);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
259 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
260 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
261
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
262
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
263
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
264 void RenderD3D11::Present()
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
265 {
2521
a.parshin
parents: 2518
diff changeset
266 pSwapChain->Present(0, 0);
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
267 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
268
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
269 bool RenderD3D11::IsGammaSupported()
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
270 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
271 return false;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
272 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
273
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
274 struct
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
275 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
276 unsigned char restore_resolution;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
277 unsigned char _saved_screen_bpp;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
278 unsigned short _saved_screen_width;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
279 unsigned short _saved_screen_height;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
280 } on_exit;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
281
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
282 void ChangeResolution(int new_width, int new_height, int new_bpp)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
283 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
284 if (!on_exit.restore_resolution)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
285 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
286 on_exit.restore_resolution = true;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
287
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
288 auto hdc = GetDC(nullptr);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
289 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
290 on_exit._saved_screen_width = GetDeviceCaps(hdc, HORZRES);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
291 on_exit._saved_screen_height = GetDeviceCaps(hdc, VERTRES);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
292 on_exit._saved_screen_bpp = GetDeviceCaps(hdc, BITSPIXEL);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
293 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
294 ReleaseDC(nullptr, hdc);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
295 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
296
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
297 DEVMODEA dm;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
298 dm.dmSize = sizeof(dm);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
299 dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
300 dm.dmBitsPerPel = new_bpp;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
301 dm.dmPelsWidth = new_width;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
302 dm.dmPelsHeight = new_height;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
303
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
304 if (ChangeDisplaySettingsA(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
305 Error("ChangeDisplaySettingsA");
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
306 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
307
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
308 __declspec(noreturn) void ExitApp()
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
309 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
310 if (on_exit.restore_resolution)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
311 ChangeResolution(on_exit._saved_screen_width, on_exit._saved_screen_height, on_exit._saved_screen_bpp);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
312
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
313 ExitProcess(0);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
314 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
315
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
316
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
317
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
318 bool RenderD3D11::SwitchToWindow()
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
319 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
320 if (on_exit.restore_resolution)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
321 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
322 on_exit.restore_resolution = false;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
323 ChangeResolution(on_exit._saved_screen_width, on_exit._saved_screen_height, on_exit._saved_screen_bpp);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
324 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
325 return true;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
326 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
327
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
328
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
329
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
330
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
331 bool RenderD3D11::Initialize(OSWindow *window)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
332 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
333 this->window = window;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
334
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
335 auto d3d_lib = LoadLibraryW(L"d3d11.dll");
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
336 if (!d3d_lib)
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
337 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
338 Error("d3d11.dll is missing");
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
339 return false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
340 }
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
341
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
342
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
343 DXGI_SWAP_CHAIN_DESC swapChainDesc;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
344 memset(&swapChainDesc, 0, sizeof(swapChainDesc));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
345 swapChainDesc.BufferDesc.Width = window->GetWidth();
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
346 swapChainDesc.BufferDesc.Height = window->GetHeight();
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
347 //swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
348 //swapChainDesc.BufferDesc.RefreshRate.Denominator = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
349 swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
350 //swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
351 //swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
352 swapChainDesc.SampleDesc.Count = 1;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
353 //swapChainDesc.SampleDesc.Quality = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
354 swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
355 swapChainDesc.BufferCount = 2;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
356 swapChainDesc.OutputWindow = window->GetApiHandle();
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
357 swapChainDesc.Windowed = true;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
358 //swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
359 //swapChainDesc.Flags = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
360
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
361
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
362 D3D_FEATURE_LEVEL requested_feature_level = D3D_FEATURE_LEVEL_11_0,
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
363 received_feature_level;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
364
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
365 unsigned int device_flags = 0;//D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
366 #ifndef NODEBUG
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
367 device_flags |= D3D11_CREATE_DEVICE_DEBUG;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
368 #endif
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
369
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
370 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);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
371 dll_D3D11CreateDeviceAndSwapChain = (decltype(dll_D3D11CreateDeviceAndSwapChain))GetProcAddress(d3d_lib, "D3D11CreateDeviceAndSwapChain");
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
372 ErrorD3D(dll_D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, device_flags, nullptr, 0, D3D11_SDK_VERSION, &swapChainDesc, &pSwapChain, &d3dd, &received_feature_level, &d3dc));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
373
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
374 if (received_feature_level < D3D_FEATURE_LEVEL_10_0)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
375 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
376 MessageBoxA(nullptr, "Received Direct3D 9 or lower", "", 0);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
377 __debugbreak();
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
378 }
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
379 /*if (fullscreen)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
380 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
381 extern void ChangeResolution(int new_dith, int new_height, int new_bpp);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
382 ChangeResolution(target_window->GetWidth(), target_window->GetHeight(), 32);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
383
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
384 target_window->SetPosition(0, 0);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
385 target_window->SetTopmost(true);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
386 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
387 ErrorD3D(pSwapChain->SetFullscreenState(fullscreen, nullptr));*/
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
388
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
389
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
390 ID3D11Texture2D *pSwapChainSurface;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
391 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
392 ErrorD3D(pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void **)&pSwapChainSurface));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
393 ErrorD3D(d3dd->CreateRenderTargetView(pSwapChainSurface, nullptr, &primary_srv));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
394 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
395 pSwapChainSurface->Release();
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
396
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
397
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
398 D3D11_TEXTURE2D_DESC z_desc;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
399 memset(&z_desc, 0, sizeof(z_desc));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
400 z_desc.Width = window->GetWidth();
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
401 z_desc.Height = window->GetHeight();
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
402 z_desc.MipLevels = 1;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
403 z_desc.ArraySize = 1;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
404 z_desc.Format = DXGI_FORMAT_D32_FLOAT;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
405 z_desc.SampleDesc.Count = 1;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
406 //z_desc.SampleDesc.Quality = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
407 //z_desc.Usage = D3D11_USAGE_DEFAULT;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
408 z_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
409 //z_desc.CPUAccessFlags = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
410 //z_desc.MiscFlags = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
411
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
412 ID3D11Texture2D *depth_surface;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
413 ErrorD3D(d3dd->CreateTexture2D(&z_desc, nullptr, &depth_surface));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
414
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
415 D3D11_DEPTH_STENCIL_VIEW_DESC depth_srv_desc;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
416 memset(&depth_srv_desc, 0, sizeof(depth_srv_desc));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
417 depth_srv_desc.Format = DXGI_FORMAT_D32_FLOAT;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
418 depth_srv_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
419 //depth_srv_desc.Texture2D.MipSlice = 0;
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
420 ErrorD3D(d3dd->CreateDepthStencilView(depth_surface, &depth_srv_desc, &default_depth_srv));
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
421
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
422 d3dc->OMSetRenderTargets(1, &primary_srv, default_depth_srv);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
423 d3dc->ClearDepthStencilView(default_depth_srv, D3D11_CLEAR_DEPTH, 1.0f, 0);
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
424
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
425
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
426
2521
a.parshin
parents: 2518
diff changeset
427 D3D11_RASTERIZER_DESC default_rasterizer_desc;
a.parshin
parents: 2518
diff changeset
428 memset(&default_rasterizer_desc, 0, sizeof(default_rasterizer_desc));
a.parshin
parents: 2518
diff changeset
429 default_rasterizer_desc.FillMode = D3D11_FILL_SOLID;
a.parshin
parents: 2518
diff changeset
430 default_rasterizer_desc.CullMode = D3D11_CULL_NONE;
a.parshin
parents: 2518
diff changeset
431 //default_rasterizer_desc.FrontCounterClockwise = false;
a.parshin
parents: 2518
diff changeset
432 //default_rasterizer_desc.DepthBias = 0;
a.parshin
parents: 2518
diff changeset
433 //default_rasterizer_desc.DepthBiasClamp = 0.0f;
a.parshin
parents: 2518
diff changeset
434 //default_rasterizer_desc.SlopeScaledDepthBias = 0.0f;
a.parshin
parents: 2518
diff changeset
435 //default_rasterizer_desc.DepthClipEnable = true;
a.parshin
parents: 2518
diff changeset
436 //default_rasterizer_desc.ScissorEnable = false;
a.parshin
parents: 2518
diff changeset
437 //default_rasterizer_desc.MultisampleEnable = false;
a.parshin
parents: 2518
diff changeset
438 //default_rasterizer_desc.AntialiasedLineEnable = false;
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
439
2521
a.parshin
parents: 2518
diff changeset
440 ErrorD3D(d3dd->CreateRasterizerState(&default_rasterizer_desc, &default_rasterizer));
a.parshin
parents: 2518
diff changeset
441 d3dc->RSSetState(default_rasterizer);
a.parshin
parents: 2518
diff changeset
442
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
443
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
444
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
445 D3D11_RASTERIZER_DESC ui_rasterizer_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
446 memset(&ui_rasterizer_desc, 0, sizeof(ui_rasterizer_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
447 ui_rasterizer_desc.FillMode = D3D11_FILL_SOLID;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
448 ui_rasterizer_desc.CullMode = D3D11_CULL_NONE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
449 //ui_rasterizer_desc.FrontCounterClockwise = false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
450 //ui_rasterizer_desc.DepthBias = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
451 //ui_rasterizer_desc.DepthBiasClamp = 0.0f;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
452 //ui_rasterizer_desc.SlopeScaledDepthBias = 0.0f;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
453 //ui_rasterizer_desc.DepthClipEnable = true;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
454 ui_rasterizer_desc.ScissorEnable = true;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
455 //ui_rasterizer_desc.MultisampleEnable = false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
456 //ui_rasterizer_desc.AntialiasedLineEnable = false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
457
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
458 ErrorD3D(d3dd->CreateRasterizerState(&ui_rasterizer_desc, &ui_rasterizer));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
459
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
460
2521
a.parshin
parents: 2518
diff changeset
461 default_depthstencil = nullptr;
a.parshin
parents: 2518
diff changeset
462 default_blend = nullptr;
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
463
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
464
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
465
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
466 D3D11_VIEWPORT viewport;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
467 memset(&viewport, 0, sizeof(viewport));
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
468 viewport.TopLeftX = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
469 viewport.TopLeftY = 0;
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
470 viewport.Width = window->GetWidth();
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
471 viewport.Height = window->GetHeight();
2521
a.parshin
parents: 2518
diff changeset
472 viewport.MinDepth = 0;
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
473 viewport.MaxDepth = 1;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
474 d3dc->RSSetViewports(1, &viewport);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
475
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
476 ResetUIClipRect();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
477
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
478
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
479 D3D11_INPUT_ELEMENT_DESC layout_desc[] =
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
480 {
2521
a.parshin
parents: 2518
diff changeset
481 { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
a.parshin
parents: 2518
diff changeset
482 //{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 },
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
483 };
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
484 CompileShader(d3dd, L"data/shaders/UI.hlsl", layout_desc, 1/*2*/, &ui_vs, &ui_ps, &ui_layout);
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
485
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
486 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
487 uint uVertexSize = 4 * sizeof(float);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
488
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
489 float ui_mesh[] =
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
490 {
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
491 1, 1, 0, 0, // pos
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
492 1, 1, 1, 0, // pos + size.x
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
493 1, 1, 0, 1, // pos + size.y
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
494
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
495 1, 1, 0, 1, // pos + size.y
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
496 1, 1, 1, 0, // pos + size.x
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
497 1, 1, 1, 1 // pos + size.xy
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
498 /*-1, 1, 0.1, 1,
2521
a.parshin
parents: 2518
diff changeset
499 1, 1, 0.1, 1,
a.parshin
parents: 2518
diff changeset
500 -1, -1, 0.1, 1,
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
501
2521
a.parshin
parents: 2518
diff changeset
502 -1, -1, 0.1, 1,
a.parshin
parents: 2518
diff changeset
503 1, 1, 0.1, 1,
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
504 1, -1, 0.1, 1*/
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
505 };
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
506
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
507 D3D11_BUFFER_DESC vbdesc;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
508 vbdesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
509 vbdesc.ByteWidth = 6 * uVertexSize;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
510 vbdesc.CPUAccessFlags = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
511 vbdesc.MiscFlags = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
512 vbdesc.StructureByteStride = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
513 vbdesc.Usage = D3D11_USAGE_DEFAULT;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
514
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
515 D3D11_SUBRESOURCE_DATA vbdata;
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
516 vbdata.pSysMem = ui_mesh;
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
517 vbdata.SysMemPitch = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
518 vbdata.SysMemSlicePitch = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
519
2521
a.parshin
parents: 2518
diff changeset
520 d3dd->CreateBuffer(&vbdesc, &vbdata, &ui_vb);
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
521 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
522
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
523 D3D11_BUFFER_DESC ui_cb_fast_desc;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
524 ZeroMemory(&ui_cb_fast_desc, sizeof(ui_cb_fast_desc));
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
525 // TODO: Fix Bug Prone size
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
526 ui_cb_fast_desc.ByteWidth = 1 * 4 * sizeof(float);
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
527 ui_cb_fast_desc.Usage = D3D11_USAGE_DYNAMIC;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
528 ui_cb_fast_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
529 ui_cb_fast_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
530 ui_cb_fast_desc.MiscFlags = 0;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
531 ui_cb_fast_desc.StructureByteStride = 0;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
532 d3dd->CreateBuffer(&ui_cb_fast_desc, nullptr, &ui_cb_fast);
2521
a.parshin
parents: 2518
diff changeset
533
a.parshin
parents: 2518
diff changeset
534 D3D11_DEPTH_STENCIL_DESC ui_depthstencil_desc;
a.parshin
parents: 2518
diff changeset
535 ui_depthstencil_desc.DepthEnable = true;
a.parshin
parents: 2518
diff changeset
536 ui_depthstencil_desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
a.parshin
parents: 2518
diff changeset
537 ui_depthstencil_desc.DepthFunc = D3D11_COMPARISON_ALWAYS;
a.parshin
parents: 2518
diff changeset
538 ui_depthstencil_desc.StencilEnable = false;
a.parshin
parents: 2518
diff changeset
539 ui_depthstencil_desc.StencilReadMask = 0xFF;
a.parshin
parents: 2518
diff changeset
540 ui_depthstencil_desc.StencilWriteMask = 0xFF;
a.parshin
parents: 2518
diff changeset
541 // Stencil operations if pixel is front-facing
a.parshin
parents: 2518
diff changeset
542 ui_depthstencil_desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
a.parshin
parents: 2518
diff changeset
543 ui_depthstencil_desc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
a.parshin
parents: 2518
diff changeset
544 ui_depthstencil_desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
a.parshin
parents: 2518
diff changeset
545 ui_depthstencil_desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
a.parshin
parents: 2518
diff changeset
546 // Stencil operations if pixel is back-facing
a.parshin
parents: 2518
diff changeset
547 ui_depthstencil_desc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
a.parshin
parents: 2518
diff changeset
548 ui_depthstencil_desc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
a.parshin
parents: 2518
diff changeset
549 ui_depthstencil_desc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
a.parshin
parents: 2518
diff changeset
550 ui_depthstencil_desc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
a.parshin
parents: 2518
diff changeset
551
a.parshin
parents: 2518
diff changeset
552 ErrorD3D(d3dd->CreateDepthStencilState(&ui_depthstencil_desc, &ui_depthstencil));
a.parshin
parents: 2518
diff changeset
553
a.parshin
parents: 2518
diff changeset
554
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
555 D3D11_BLEND_DESC ui_blend_solid_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
556 memset(&ui_blend_solid_desc, 0, sizeof(ui_blend_solid_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
557 ui_blend_solid_desc.RenderTarget[0].BlendEnable = false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
558 ui_blend_solid_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
559 ErrorD3D(d3dd->CreateBlendState(&ui_blend_solid_desc, &ui_blend_solid));
2521
a.parshin
parents: 2518
diff changeset
560
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
561 D3D11_BLEND_DESC ui_blend_alpha_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
562 memset(&ui_blend_alpha_desc, 0, sizeof(ui_blend_alpha_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
563 ui_blend_alpha_desc.RenderTarget[0].BlendEnable = true;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
564 ui_blend_alpha_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
565 ui_blend_alpha_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
566 ui_blend_alpha_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
567 ui_blend_alpha_desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
568 ui_blend_alpha_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
569 ui_blend_alpha_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
570 ui_blend_alpha_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
571 ErrorD3D(d3dd->CreateBlendState(&ui_blend_alpha_desc, &ui_blend_alpha));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
572
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
573
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
574 return pD3DBitmaps.Load(L"data\\d3dbitmap.hwl") && pD3DSprites.Load(L"data\\d3dsprite.hwl");
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
575 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
576
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
577
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
578
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
579
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
580 bool RenderD3D11::MoveSpriteToDevice(Sprite *pSprite)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
581 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
582 HWLTexture *sprite_texture; // eax@1
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
583 unsigned __int16 *v9; // edx@5
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
584 LPVOID v10; // eax@5
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
585 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
586
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
587 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
588 if ( sprite_texture )
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
589 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
590 pSprite->uAreaX = sprite_texture->uAreaX;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
591 pSprite->uAreaY = sprite_texture->uAreaY;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
592 pSprite->uBufferWidth = sprite_texture->uBufferWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
593 pSprite->uBufferHeight = sprite_texture->uBufferHeight;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
594 pSprite->uAreaWidth = sprite_texture->uAreaWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
595 pSprite->uAreaHeight = sprite_texture->uAreaHeigth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
596
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
597 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
598 D3D11_TEXTURE2D_DESC desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
599 desc.Width = sprite_texture->uWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
600 desc.Height = sprite_texture->uHeight;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
601 desc.ArraySize = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
602 desc.MipLevels = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
603 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
604 desc.SampleDesc.Count = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
605 desc.SampleDesc.Quality = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
606 desc.Usage = D3D11_USAGE_DEFAULT;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
607 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
608 desc.CPUAccessFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
609 desc.MiscFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
610
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
611 ID3D11Texture2D *vram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
612 ErrorD3D(d3dd->CreateTexture2D(&desc, nullptr, &vram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
613
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
614 D3D11_TEXTURE2D_DESC ram_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
615 memcpy(&ram_desc, &desc, sizeof(ram_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
616 ram_desc.Usage = D3D11_USAGE_STAGING;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
617 ram_desc.BindFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
618 ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
619
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
620 ID3D11Texture2D *ram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
621 ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
622
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
623 D3D11_MAPPED_SUBRESOURCE map;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
624 ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
625 for (unsigned int y = 0; y < desc.Height; ++y)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
626 for (unsigned int x = 0; x < desc.Width; ++x)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
627 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
628 auto src = sprite_texture->pPixels + y * desc.Width + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
629 auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
630
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
631 extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
632 *dst = 0xFF000000 | Color32_SwapRedBlue(*src);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
633 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
634
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
635
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
636 d3dc->Unmap(ram_texture, 0);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
637 d3dc->CopyResource(vram_texture, ram_texture);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
638 ram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
639
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
640 ID3D11ShaderResourceView *srv = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
641 ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, &srv));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
642 vram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
643
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
644 pSprite->d3d11_srv = srv;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
645 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
646 /*if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim))
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
647 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
648 memset(&Dst, 0, sizeof(DDSURFACEDESC2));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
649 Dst.dwSize = 124;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
650 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) )
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
651 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
652 v9 = sprite_texture->pPixels;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
653 v10 = Dst.lpSurface;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
654 for (uint i=0; i<sprite_texture->uHeight; ++i)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
655 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
656 for (uint j=0; j<sprite_texture->uWidth/2; ++j)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
657 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
658 *(int *)v10 = *(int *)v9;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
659 v9 += 2;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
660 v10 = (char *)v10 + 4;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
661 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
662 v10 = (char *)v10 + Dst.lPitch-sprite_texture->uWidth*2;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
663 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
664 ErrD3D(pSprite->pTextureSurface->Unlock(NULL));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
665 }*/
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
666 delete [] sprite_texture->pPixels;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
667 delete sprite_texture;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
668 return true;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
669 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
670 return false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
671 }
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
672
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
673
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
674 ID3DBlob *DoD3DCompiling(const wchar_t *shader_name, const char *pShaderSource, uint uShaderSourceLen, const char *pEntry, const char *pVersionString, uint uCompileOptions);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
675 void DoCompile(const wchar_t *pFilename, const char *pShaderSource, unsigned int uShaderSourceLen,
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
676 unsigned char **vs, unsigned int *vs_size, unsigned char **ps, unsigned int *ps_size);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
677 bool CompileShader(ID3D11Device *d3dd, const wchar_t *pShaderSourceFile, D3D11_INPUT_ELEMENT_DESC *input_desc, int input_desc_size,
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
678 ID3D11VertexShader **vertex_out, ID3D11PixelShader **pixel_out, ID3D11InputLayout **layout_out)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
679 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
680 unsigned char *vs, *ps;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
681 unsigned int vs_size, ps_size;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
682
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
683 HANDLE hSourceFile = CreateFileW(pShaderSourceFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
684 if (hSourceFile == INVALID_HANDLE_VALUE)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
685 Error("%S:\n\nCannot read shader file", pShaderSourceFile);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
686
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
687 char *pShaderSource = nullptr;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
688 int uShaderSourceLen = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
689 uint uFileSize = GetFileSize(hSourceFile, nullptr);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
690 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
691 DWORD w;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
692 char *p = new char[uFileSize + 1];
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
693 ReadFile(hSourceFile, p, uFileSize, &w, nullptr);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
694 CloseHandle(hSourceFile);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
695 p[uFileSize] = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
696
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
697 pShaderSource = p;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
698 uShaderSourceLen = uFileSize;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
699 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
700
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
701 DoCompile(pShaderSourceFile, pShaderSource, uShaderSourceLen, &vs, &vs_size, &ps, &ps_size);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
702
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
703 ErrorD3D(d3dd->CreateVertexShader(vs, vs_size, nullptr, vertex_out));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
704 ErrorD3D(d3dd->CreatePixelShader(ps, ps_size, nullptr, pixel_out));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
705 ErrorD3D(d3dd->CreateInputLayout(input_desc, input_desc_size, vs, vs_size, layout_out));
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
706
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
707 delete [] vs;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
708 delete [] ps;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
709
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
710 return true;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
711 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
712
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
713
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
714
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
715 static HMODULE compiler_dll = nullptr;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
716 void DoCompile(const wchar_t *pFilename, const char *pSahderSource, unsigned int uShaderSourceLen,
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
717 unsigned char **vs, unsigned int *vs_size, unsigned char **ps, unsigned int *ps_size)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
718 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
719 const char *pVSEntry = "vs",
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
720 *pVSVersionString = "vs_4_0";
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
721 const char *pPSEntry = "main",
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
722 *pPSVersionString = "ps_4_0";
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
723
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
724
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
725 uint uVSCompileOptions =
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
726 #ifndef NDEBUG
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
727 D3D10_SHADER_SKIP_VALIDATION |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
728 D3D10_SHADER_SKIP_OPTIMIZATION |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
729 D3D10_SHADER_PREFER_FLOW_CONTROL;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
730 #else
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
731 D3D10_SHADER_SKIP_VALIDATION |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
732 D3D10_SHADER_OPTIMIZATION_LEVEL3 |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
733 D3D10_SHADER_WARNINGS_ARE_ERRORS |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
734 D3D10_SHADER_AVOID_FLOW_CONTROL |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
735 D3D10_SHADER_ENABLE_STRICTNESS |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
736 D3D10_SHADER_IEEE_STRICTNESS;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
737 #endif
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
738
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
739 *vs_size = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
740 *vs = nullptr;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
741 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
742 auto pVSBlob = DoD3DCompiling(pFilename, pSahderSource, uShaderSourceLen, pVSEntry, pVSVersionString, uVSCompileOptions);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
743 if (pVSBlob)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
744 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
745 *vs = new unsigned char[*vs_size = pVSBlob->GetBufferSize()];
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
746 memcpy(*vs, pVSBlob->GetBufferPointer(), *vs_size);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
747
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
748 pVSBlob->Release();
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
749 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
750 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
751
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
752
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
753 uint uPSCompileOptions =
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
754 #ifndef NDEBUG
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
755 D3D10_SHADER_SKIP_VALIDATION |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
756 D3D10_SHADER_SKIP_OPTIMIZATION |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
757 D3D10_SHADER_PREFER_FLOW_CONTROL;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
758 #else
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
759 D3D10_SHADER_SKIP_VALIDATION |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
760 D3D10_SHADER_OPTIMIZATION_LEVEL3 |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
761 D3D10_SHADER_WARNINGS_ARE_ERRORS |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
762 D3D10_SHADER_AVOID_FLOW_CONTROL |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
763 D3D10_SHADER_ENABLE_STRICTNESS |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
764 D3D10_SHADER_IEEE_STRICTNESS;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
765 #endif
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
766
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
767 *ps_size = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
768 *ps = nullptr;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
769 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
770 auto pPSBlob = DoD3DCompiling(pFilename, pSahderSource, uShaderSourceLen, pPSEntry, pPSVersionString, uPSCompileOptions);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
771 if (pPSBlob)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
772 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
773 *ps = new unsigned char[*ps_size = pPSBlob->GetBufferSize()];
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
774 memcpy(*ps, pPSBlob->GetBufferPointer(), *ps_size);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
775
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
776 pPSBlob->Release();
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
777 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
778 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
779 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
780
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
781 ID3DBlob *DoD3DCompiling(const wchar_t *shader_name, const char *pShaderSource, uint uShaderSourceLen, const char *pEntry, const char *pVersionString, uint uCompileOptions)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
782 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
783 ID3DBlob *pShader,
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
784 *pErrors;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
785
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
786 if (!compiler_dll)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
787 for (int i = 45; i >= 38; --i)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
788 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
789 wchar_t dll_name[64];
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
790 swprintf(dll_name, L"d3dcompiler_%u.dll", i);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
791
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
792 compiler_dll = LoadLibraryW(dll_name);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
793 if (compiler_dll)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
794 break;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
795 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
796
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
797 if (!compiler_dll)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
798 Error("Cannot find any suitable d3dcompiler.dll");
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
799
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
800 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);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
801 auto pD3DCompile = (fnD3DCompile)GetProcAddress(compiler_dll, "D3DCompile");
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
802
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
803 HRESULT hr = pD3DCompile(pShaderSource, uShaderSourceLen, nullptr, nullptr, nullptr, pEntry, pVersionString, uCompileOptions, 0, &pShader, &pErrors);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
804
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
805 if (FAILED(hr))
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
806 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
807 if (pErrors)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
808 Error("%S (%s) build failed:\n\n%s", shader_name, pVersionString, pErrors->GetBufferPointer());
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
809 else
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
810 Error("%S (%s) build failed", shader_name, pVersionString);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
811 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
812 else if (pErrors)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
813 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
814 Log::Warning(L"%s (%S) build warnings:\n\n%S", shader_name, pVersionString, pErrors->GetBufferPointer());
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
815 pErrors->Release();
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
816 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
817
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
818 return pShader;
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
819 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
820
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
821 /*
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
822 void RenderD3D11::PrepareTexture(RGBTexture *p)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
823 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
824 if (!p->d3d11_srv)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
825 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
826 auto desc = p->d3d11_desc = new D3D11_TEXTURE2D_DESC;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
827 desc->Width = p->uWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
828 desc->Height = p->uHeight;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
829 desc->ArraySize = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
830 desc->MipLevels = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
831 desc->Format = DXGI_FORMAT_R8G8B8A8_UNORM;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
832 desc->SampleDesc.Count = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
833 desc->SampleDesc.Quality = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
834 desc->Usage = D3D11_USAGE_DEFAULT;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
835 desc->BindFlags = D3D11_BIND_SHADER_RESOURCE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
836 desc->CPUAccessFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
837 desc->MiscFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
838
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
839 ID3D11Texture2D *vram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
840 ErrorD3D(d3dd->CreateTexture2D(desc, nullptr, &vram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
841
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
842 D3D11_TEXTURE2D_DESC ram_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
843 memcpy(&ram_desc, desc, sizeof(ram_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
844 ram_desc.Usage = D3D11_USAGE_STAGING;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
845 ram_desc.BindFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
846 ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
847
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
848 ID3D11Texture2D *ram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
849 ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
850
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
851 D3D11_MAPPED_SUBRESOURCE map;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
852 ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
853 for (unsigned int y = 0; y < desc->Height; ++y)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
854 for (unsigned int x = 0; x < desc->Width; ++x)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
855 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
856 auto src = p->pPixels + y * p->uWidth + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
857 auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
858
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
859 extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
860 *dst = 0xFF000000 | Color32_SwapRedBlue(*src);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
861 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
862
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
863 d3dc->Unmap(ram_texture, 0);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
864 d3dc->CopyResource(vram_texture, ram_texture);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
865 ram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
866
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
867 ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, (ID3D11ShaderResourceView **)&p->d3d11_srv));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
868 vram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
869 }
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
870 }*/
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
871
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
872
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
873
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
874 void RenderD3D11::PrepareTextureIndexed(Texture *p)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
875 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
876 if (!p->d3d11_srv)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
877 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
878 auto desc = p->d3d11_desc = new D3D11_TEXTURE2D_DESC;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
879 desc->Width = p->uTextureWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
880 desc->Height = p->uTextureHeight;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
881 desc->ArraySize = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
882 desc->MipLevels = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
883 desc->Format = DXGI_FORMAT_R8G8B8A8_UNORM;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
884 desc->SampleDesc.Count = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
885 desc->SampleDesc.Quality = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
886 desc->Usage = D3D11_USAGE_DEFAULT;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
887 desc->BindFlags = D3D11_BIND_SHADER_RESOURCE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
888 desc->CPUAccessFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
889 desc->MiscFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
890
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
891 ID3D11Texture2D *vram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
892 ErrorD3D(d3dd->CreateTexture2D(desc, nullptr, &vram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
893
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
894 D3D11_TEXTURE2D_DESC ram_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
895 memcpy(&ram_desc, desc, sizeof(ram_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
896 ram_desc.Usage = D3D11_USAGE_STAGING;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
897 ram_desc.BindFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
898 ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
899
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
900 ID3D11Texture2D *ram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
901 ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
902
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
903 D3D11_MAPPED_SUBRESOURCE map;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
904 ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
905 for (unsigned int y = 0; y < desc->Height; ++y)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
906 for (unsigned int x = 0; x < desc->Width; ++x)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
907 {
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
908 auto index = p->paletted_pixels[y * p->uTextureWidth + x];
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
909 auto src = p->pPalette16[index];
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
910 auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
911
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
912 if (index)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
913 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
914 extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
915 *dst = 0xFF000000 | Color32_SwapRedBlue(src);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
916 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
917 else
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
918 *dst = 0x00000000;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
919 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
920
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
921 d3dc->Unmap(ram_texture, 0);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
922 d3dc->CopyResource(vram_texture, ram_texture);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
923 ram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
924
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
925 ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, (ID3D11ShaderResourceView **)&p->d3d11_srv));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
926 vram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
927 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
928 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
929
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
930
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
931 ID3D11ShaderResourceView *RenderD3D11::PrepareFontTexture(unsigned char *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned short *pFontPalette, unsigned short uFaceColor, unsigned short uShadowColor)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
932 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
933 D3D11_TEXTURE2D_DESC desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
934 desc.Width = uCharWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
935 desc.Height = uCharHeight;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
936 desc.ArraySize = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
937 desc.MipLevels = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
938 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
939 desc.SampleDesc.Count = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
940 desc.SampleDesc.Quality = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
941 desc.Usage = D3D11_USAGE_DEFAULT;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
942 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
943 desc.CPUAccessFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
944 desc.MiscFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
945
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
946 ID3D11Texture2D *vram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
947 ErrorD3D(d3dd->CreateTexture2D(&desc, nullptr, &vram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
948
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
949 D3D11_TEXTURE2D_DESC ram_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
950 memcpy(&ram_desc, &desc, sizeof(ram_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
951 ram_desc.Usage = D3D11_USAGE_STAGING;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
952 ram_desc.BindFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
953 ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
954
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
955 ID3D11Texture2D *ram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
956 ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
957
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
958 D3D11_MAPPED_SUBRESOURCE map;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
959 ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
960 for (unsigned int y = 0; y < desc.Height; ++y)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
961 for (unsigned int x = 0; x < desc.Width; ++x)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
962 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
963 auto index = pFontPixels[y * desc.Width + x];
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
964 auto src = pFontPalette[index];
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
965 auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
966
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
967 if (index)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
968 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
969 extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
970 *dst = 0xFF000000 | Color32_SwapRedBlue(index == 1 ? uShadowColor : uFaceColor);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
971 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
972 else
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
973 *dst = 0x00000000;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
974 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
975
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
976 d3dc->Unmap(ram_texture, 0);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
977 d3dc->CopyResource(vram_texture, ram_texture);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
978 ram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
979
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
980 ID3D11ShaderResourceView *srv = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
981 ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, &srv));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
982 vram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
983
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
984 return srv;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
985 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
986
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
987
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
988 ID3D11ShaderResourceView *RenderD3D11::PrepareFontTexture(unsigned char *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned short *pFontPalette)
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
989 {
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
990 D3D11_TEXTURE2D_DESC desc;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
991 desc.Width = uCharWidth;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
992 desc.Height = uCharHeight;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
993 desc.ArraySize = 1;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
994 desc.MipLevels = 1;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
995 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
996 desc.SampleDesc.Count = 1;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
997 desc.SampleDesc.Quality = 0;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
998 desc.Usage = D3D11_USAGE_DEFAULT;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
999 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1000 desc.CPUAccessFlags = 0;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1001 desc.MiscFlags = 0;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1002
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1003 ID3D11Texture2D *vram_texture = nullptr;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1004 ErrorD3D(d3dd->CreateTexture2D(&desc, nullptr, &vram_texture));
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1005
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1006 D3D11_TEXTURE2D_DESC ram_desc;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1007 memcpy(&ram_desc, &desc, sizeof(ram_desc));
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1008 ram_desc.Usage = D3D11_USAGE_STAGING;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1009 ram_desc.BindFlags = 0;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1010 ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1011
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1012 ID3D11Texture2D *ram_texture = nullptr;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1013 ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1014
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1015 D3D11_MAPPED_SUBRESOURCE map;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1016 ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1017 for (unsigned int y = 0; y < desc.Height; ++y)
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1018 for (unsigned int x = 0; x < desc.Width; ++x)
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1019 {
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1020 auto index = pFontPixels[y * desc.Width + x];
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1021 auto src = pFontPalette[index];
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1022 auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1023
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1024 if (index)
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1025 {
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1026 extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1027 *dst = 0xFF000000 | Color32_SwapRedBlue(src);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1028 }
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1029 else
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1030 *dst = 0x00000000;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1031 }
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1032
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1033 d3dc->Unmap(ram_texture, 0);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1034 d3dc->CopyResource(vram_texture, ram_texture);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1035 ram_texture->Release();
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1036
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1037 ID3D11ShaderResourceView *srv = nullptr;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1038 ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, &srv));
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1039 vram_texture->Release();
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1040
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1041 return srv;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1042 }
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1043
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1044
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1045 void d3d11_release(ID3D11ShaderResourceView *srv)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1046 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1047 srv->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1048 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1049
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1050
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1051 //----- (004A4DE1) --------------------------------------------------------
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1052 bool RenderD3D11::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1053 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1054 unsigned __int16 *v13; // ecx@19
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1055 unsigned __int16 *v14; // eax@19
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1056 DWORD v15; // edx@20
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1057
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1058 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1059 if (!pHWLTexture)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1060 return false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1061
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1062 int num_min_levels = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1063 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1064 int dim = min(pHWLTexture->uWidth, pHWLTexture->uHeight);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1065 while (dim > 1)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1066 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1067 dim /= 2;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1068 num_min_levels++;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1069 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1070 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1071
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1072
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1073 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1074 D3D11_TEXTURE2D_DESC desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1075 desc.Width = pHWLTexture->uWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1076 desc.Height = pHWLTexture->uHeight;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1077 desc.ArraySize = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1078 desc.MipLevels = num_min_levels;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1079 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1080 desc.SampleDesc.Count = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1081 desc.SampleDesc.Quality = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1082 desc.Usage = D3D11_USAGE_DEFAULT;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1083 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET/* for mipmap generation */;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1084 desc.CPUAccessFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1085 desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1086
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1087 ID3D11Texture2D *vram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1088 ErrorD3D(d3dd->CreateTexture2D(&desc, nullptr, &vram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1089
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1090 D3D11_TEXTURE2D_DESC ram_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1091 memcpy(&ram_desc, &desc, sizeof(ram_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1092 ram_desc.Usage = D3D11_USAGE_STAGING;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1093 ram_desc.BindFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1094 ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1095 ram_desc.MiscFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1096
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1097 ID3D11Texture2D *ram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1098 ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1099
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1100 D3D11_MAPPED_SUBRESOURCE map;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1101 ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1102 for (unsigned int y = 0; y < desc.Height; ++y)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1103 for (unsigned int x = 0; x < desc.Width; ++x)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1104 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1105 auto src = pHWLTexture->pPixels + y * desc.Width + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1106 auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1107
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1108 extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1109 *dst = 0xFF000000 | Color32_SwapRedBlue(*src);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1110 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1111
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1112 d3dc->Unmap(ram_texture, 0);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1113 d3dc->CopyResource(vram_texture, ram_texture);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1114 ram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1115
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1116 ID3D11ShaderResourceView *srv = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1117 ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, &srv));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1118 vram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1119
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1120 d3dc->GenerateMips(srv);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1121 *pOutTexture = (IDirect3DTexture2 *)srv;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1122 *pOutSurface = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1123 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1124
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1125 delete [] pHWLTexture->pPixels;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1126 delete pHWLTexture;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1127 return true;
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1128 }
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1129