Rise
The Vieneo Province
Loading...
Searching...
No Matches
ClientResources11.cpp
Go to the documentation of this file.
1#include "ClientRenderer11.h"
2#include "TextureMips11.h"
3#include <algorithm>
4#include <fstream>
5#include <filesystem>
6#include <iterator>
7#include <new>
8using Microsoft::WRL::ComPtr;
9namespace Rendering
10{
11 DXGI_FORMAT NativeFormat(ImageFormat format)
12 {
13 switch(format)
14 {
15 case ImageFormat::BGRA8:return DXGI_FORMAT_B8G8R8A8_UNORM;
16 case ImageFormat::RGB8:return DXGI_FORMAT_B8G8R8X8_UNORM;
17 case ImageFormat::RGBA8:return DXGI_FORMAT_R8G8B8A8_UNORM;
18 case ImageFormat::R8:return DXGI_FORMAT_R8_UNORM;
19 case ImageFormat::RG8:return DXGI_FORMAT_R8G8_UNORM;
20 case ImageFormat::R16Float:return DXGI_FORMAT_R16_FLOAT;
21 case ImageFormat::R32Float:return DXGI_FORMAT_R32_FLOAT;
22 case ImageFormat::RGBA16Float:return DXGI_FORMAT_R16G16B16A16_FLOAT;
23 case ImageFormat::RGBA32Float:return DXGI_FORMAT_R32G32B32A32_FLOAT;
24 case ImageFormat::BC1:return DXGI_FORMAT_BC1_UNORM;
25 case ImageFormat::BC2:return DXGI_FORMAT_BC2_UNORM;
26 case ImageFormat::BC3:return DXGI_FORMAT_BC3_UNORM;
27 case ImageFormat::Depth24Stencil8:return DXGI_FORMAT_D24_UNORM_S8_UINT;
28 default:return DXGI_FORMAT_UNKNOWN;
29 }
30 }
39 namespace
40 {
41 std::wstring Wide(const char* value)
42 {
43 if(!value)return {};
44 const int count=MultiByteToWideChar(CP_ACP,0,value,-1,nullptr,0);if(!count)return {};
45 std::wstring result(size_t(count),L'\0');MultiByteToWideChar(CP_ACP,0,value,-1,result.data(),count);
46 result.pop_back();return result;
47 }
48 UINT PixelBytes(DXGI_FORMAT format)
49 {
50 switch(format)
51 {
52 case DXGI_FORMAT_B8G8R8A8_UNORM:case DXGI_FORMAT_B8G8R8X8_UNORM:case DXGI_FORMAT_R8G8B8A8_UNORM:case DXGI_FORMAT_R32_FLOAT:return 4;
53 case DXGI_FORMAT_R8_UNORM:return 1;
54 case DXGI_FORMAT_R8G8_UNORM:case DXGI_FORMAT_R16_FLOAT:return 2;
55 case DXGI_FORMAT_R16G16B16A16_FLOAT:return 8;
56 case DXGI_FORMAT_R32G32B32A32_FLOAT:return 16;
57 default:return 0;
58 }
59 }
60 }
61 HRESULT RenderTexture::Adopt(RenderDevice& device,Texture11& texture,UINT requestedLevels)
62 {
63 D3D11_SHADER_RESOURCE_VIEW_DESC description{};texture.View()->GetDesc(&description);
64 UINT* count=nullptr;
65 switch(description.ViewDimension)
66 {
67 case D3D11_SRV_DIMENSION_TEXTURE2D:count=&description.Texture2D.MipLevels;break;
68 case D3D11_SRV_DIMENSION_TEXTURE3D:count=&description.Texture3D.MipLevels;break;
69 case D3D11_SRV_DIMENSION_TEXTURECUBE:count=&description.TextureCube.MipLevels;break;
70 default:return E_INVALIDARG;
71 }
72 if(requestedLevels && requestedLevels!=DefaultSize)*count=(std::min)(*count,requestedLevels);
73 ComPtr<ID3D11ShaderResourceView> next;
74 const HRESULT hr=device.Native()->CreateShaderResourceView(texture.Resource(),&description,&next);if(FAILED(hr))return hr;
75 resource=texture.Resource();view=next;owner=&device;levels=*count;return S_OK;
76 }
77 HRESULT RenderTexture::Load(RenderDevice& device,const wchar_t* path,UINT requestedLevels,UINT width,UINT height)
78 {
79 if(!path)return E_INVALIDARG;
80 std::ifstream file(std::filesystem::path(path),std::ios::binary|std::ios::ate);if(!file)return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
81 const auto length=file.tellg();if(length<=0 || uint64_t(length)>UINT_MAX)return E_INVALIDARG;
82 // Allocate once at the file size instead of growing a byte-at-a-time
83 // vector while old allocations still occupy the Win32 address space.
84 std::vector<uint8_t> bytes(static_cast<size_t>(length));file.seekg(0);
85 if(!file.read(reinterpret_cast<char*>(bytes.data()),static_cast<std::streamsize>(bytes.size())))return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
86 return Load(device,bytes.data(),bytes.size(),requestedLevels,width,height);
87 }
88 HRESULT RenderTexture::Load(RenderDevice& device,const void* data,size_t bytes,UINT requestedLevels,UINT width,UINT height)
89 {
90 std::vector<uint8_t> generated;
91 HRESULT hr=PrepareTextureDDS(static_cast<const uint8_t*>(data),bytes,requestedLevels,width,height,generated);
92 if(FAILED(hr))return hr;
93 if(!generated.empty()){data=generated.data();bytes=generated.size();}
94 Texture11 loaded;hr=loaded.Load(device.Native(),device.Context(),static_cast<const uint8_t*>(data),bytes);
95 return FAILED(hr) ? hr : Adopt(device,loaded,requestedLevels);
96 }
97 HRESULT RenderTexture::Create(RenderDevice& device,UINT width,UINT height,UINT requestedLevels,DWORD usage,ImageFormat format)
98 {
99 if(locked || !width || !height || width>D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION || height>D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION)return E_INVALIDARG;
100 D3D11_TEXTURE2D_DESC desc{};desc.Width=width;desc.Height=height;desc.MipLevels=requestedLevels==DefaultSize ? 0 : requestedLevels;
101 desc.ArraySize=1;desc.Format=NativeFormat(format);desc.SampleDesc.Count=1;desc.Usage=D3D11_USAGE_DEFAULT;
102 desc.BindFlags=D3D11_BIND_SHADER_RESOURCE|((usage&BufferUsage::RENDERTARGET) ? D3D11_BIND_RENDER_TARGET : 0);
103 ComPtr<ID3D11Texture2D> next;HRESULT hr=device.Native()->CreateTexture2D(&desc,nullptr,&next);if(FAILED(hr))return hr;
104 ComPtr<ID3D11ShaderResourceView> nextView;if(FAILED(hr=device.Native()->CreateShaderResourceView(next.Get(),nullptr,&nextView)))return hr;
105 next->GetDesc(&desc);resource=next;view=nextView;owner=&device;levels=desc.MipLevels;return S_OK;
106 }
108 {
109 if(!result)return E_POINTER;if(!resource || level>=levels)return E_INVALIDARG;
110 ComPtr<ID3D11Texture2D> image;HRESULT hr=resource.As(&image);if(FAILED(hr))return hr;
111 D3D11_TEXTURE2D_DESC desc{};image->GetDesc(&desc);
112 *result={ClientFormat(desc.Format),(std::max)(1u,desc.Width>>level),(std::max)(1u,desc.Height>>level),desc.SampleDesc.Count,desc.SampleDesc.Quality};return S_OK;
113 }
115 {
116 if(!result)return E_POINTER;*result=nullptr;if(!owner || level>=levels)return E_INVALIDARG;
117 ComPtr<ID3D11Texture2D> image;HRESULT hr=resource.As(&image);if(FAILED(hr))return hr;
118 auto surface=std::make_unique<RenderSurface>();if(FAILED(hr=surface->Initialize(*owner,image.Get(),level)))return hr;
119 *result=surface.release();return S_OK;
120 }
122 {
123 // An interrupted update may leave staging mapped. Unmap through its
124 // retained context before releasing it, without borrowing the owner.
125 if(locked && staging && mappedContext)mappedContext->Unmap(staging.Get(),0);
126 }
127 HRESULT RenderTexture::LockRect(UINT level,LockedRectangle* result,const RECT* region,DWORD flags)
128 {
129 if(!result)return E_POINTER;*result={};if(!owner || locked || level>=levels)return E_INVALIDARG;
130 ComPtr<ID3D11Texture2D> image;HRESULT hr=resource.As(&image);if(FAILED(hr))return hr;
131 D3D11_TEXTURE2D_DESC desc{};image->GetDesc(&desc);const UINT bytes=PixelBytes(desc.Format);
132 if(!bytes || desc.SampleDesc.Count!=1)return E_INVALIDARG;
133 desc.Width=(std::max)(1u,desc.Width>>level);desc.Height=(std::max)(1u,desc.Height>>level);
134 const RECT rectangle=region ? *region : RECT{0,0,LONG(desc.Width),LONG(desc.Height)};
135 if(rectangle.left<0 || rectangle.top<0 || rectangle.right>LONG(desc.Width) || rectangle.bottom>LONG(desc.Height)
136 || rectangle.right<=rectangle.left || rectangle.bottom<=rectangle.top)return E_INVALIDARG;
137 desc.MipLevels=1;desc.ArraySize=1;desc.Usage=D3D11_USAGE_STAGING;desc.BindFlags=desc.MiscFlags=0;
138 desc.CPUAccessFlags=D3D11_CPU_ACCESS_READ|D3D11_CPU_ACCESS_WRITE;
139 staging.Reset();if(FAILED(hr=owner->Native()->CreateTexture2D(&desc,nullptr,&staging)))return hr;
140 // Preserve pixels outside a subrectangle, and preserve old contents
141 // whenever the caller has not explicitly discarded the whole image.
142 if(region || !(flags&LockFlags::DISCARD))owner->Context()->CopySubresourceRegion(staging.Get(),0,0,0,0,resource.Get(),level,nullptr);
143 D3D11_MAPPED_SUBRESOURCE mapped{};readOnly=(flags&LockFlags::READONLY)!=0;
144 if(FAILED(hr=owner->Context()->Map(staging.Get(),0,readOnly ? D3D11_MAP_READ : D3D11_MAP_READ_WRITE,0,&mapped))){staging.Reset();return hr;}
145 mappedContext=owner->Context();locked=true;lockedLevel=level;result->Pitch=INT(mapped.RowPitch);
146 result->pBits=static_cast<uint8_t*>(mapped.pData)+size_t(rectangle.top)*mapped.RowPitch+size_t(rectangle.left)*bytes;return S_OK;
147 }
149 {
150 if(!locked || level!=lockedLevel || !owner)return E_INVALIDARG;
151 mappedContext->Unmap(staging.Get(),0);
152 if(!readOnly){owner->Owner().UnbindShaderResources();mappedContext->CopySubresourceRegion(resource.Get(),level,0,0,0,staging.Get(),0,nullptr);}
153 locked=false;staging.Reset();mappedContext.Reset();return S_OK;
154 }
155 HRESULT RenderSurface::Initialize(RenderDevice& owner,ID3D11Texture2D* image,UINT mip)
156 {
157 if(!image)return E_INVALIDARG;D3D11_TEXTURE2D_DESC desc{};image->GetDesc(&desc);if(mip>=desc.MipLevels)return E_INVALIDARG;
158 ComPtr<ID3D11RenderTargetView> next;
159 if(desc.BindFlags&D3D11_BIND_RENDER_TARGET)
160 {
161 D3D11_RENDER_TARGET_VIEW_DESC rt{};rt.Format=desc.Format;
162 rt.ViewDimension=desc.SampleDesc.Count>1 ? D3D11_RTV_DIMENSION_TEXTURE2DMS : D3D11_RTV_DIMENSION_TEXTURE2D;rt.Texture2D.MipSlice=mip;
163 const HRESULT hr=owner.Native()->CreateRenderTargetView(image,&rt,&next);if(FAILED(hr))return hr;
164 }
165 texture=image;target=next;level=mip;return S_OK;
166 }
168 {
169 if(!result)return E_POINTER;if(!texture)return E_UNEXPECTED;D3D11_TEXTURE2D_DESC desc{};texture->GetDesc(&desc);
170 *result={ClientFormat(desc.Format),(std::max)(1u,desc.Width>>level),(std::max)(1u,desc.Height>>level),desc.SampleDesc.Count,desc.SampleDesc.Quality};return S_OK;
171 }
172 HRESULT RenderBuffer::Create(RenderDevice& owner,UINT bytes,DWORD usage,bool index,bool indices32)
173 {return geometry.Create(owner.Native(),bytes,(usage&BufferUsage::DYNAMIC)!=0,index,indices32);}
175 {
176 D3D11_QUERY_DESC desc{D3D11_QUERY_OCCLUSION,0};owner=&device;return device.Native()->CreateQuery(&desc,&query);
177 }
179 {
180 if(!owner || !query)return E_UNEXPECTED;
181 if(flags==2)owner->Context()->Begin(query.Get());else if(flags==1)owner->Context()->End(query.Get());else return E_INVALIDARG;return S_OK;
182 }
183 HRESULT RenderQuery::GetData(void* result,DWORD bytes,DWORD flags)
184 {
185 if(!owner || !query)return E_UNEXPECTED;if(!result || bytes!=sizeof(DWORD))return E_INVALIDARG;
186 UINT64 samples=0;const HRESULT hr=owner->Context()->GetData(query.Get(),&samples,sizeof(samples),flags ? 0 : D3D11_ASYNC_GETDATA_DONOTFLUSH);
187 if(hr==S_OK)*static_cast<DWORD*>(result)=DWORD((std::min)(samples,UINT64(MAXDWORD)));return hr;
188 }
189 HRESULT RenderMaterial::SetValue(const char* name,const void* value,UINT bytes)
190 {if(!name || !value || !bytes)return E_INVALIDARG;owner.Draws().Materials().Values().Set(name,value,bytes);return S_OK;}
192 {
193 if(!name)return E_INVALIDARG;auto& parameters=owner.Draws().Materials().Values();auto* view=value ? value->View() : nullptr;
194 // ColorMap3 still supports the animated 3D explosion textures.
195 // SM5 exposes the volume binding separately from the 2D binding.
196 if(!strcmp(name,"ColorMap3"))
197 {
198 D3D11_SHADER_RESOURCE_VIEW_DESC description{};if(view)view->GetDesc(&description);
199 const bool volume=description.ViewDimension==D3D11_SRV_DIMENSION_TEXTURE3D;
200 parameters.Texture(name,volume ? nullptr : view);parameters.Texture(std::string(name)+"Volume",volume ? view : nullptr);
201 }
202 else parameters.Texture(name,view);return S_OK;
203 }
205 {
206 if(active)return E_UNEXPECTED;if(count)*count=15;
207 active=true;previousPass=owner.Draws().Material();return S_OK;
208 }
210 {
211 if(!active)return E_UNEXPECTED;owner.Draws().Material(previousPass);active=false;return S_OK;
212 }
214 {
215 if(active)return E_UNEXPECTED;
216 HRESULT hr=owner.Draws().ApplyPipeline();if(FAILED(hr))return hr;
217 SpriteOptions11 options;options.alphaBlend=(flags&SpriteFlags::AlphaBlend)!=0;options.inheritBlend=!options.alphaBlend;
218 options.sortTextures=(flags&SpriteFlags::SortTexture)!=0;
220 hr=sprite.Begin(owner.Context(),options);
222 return hr;
223 }
225 {
226 RECT rectangle{};owner.GetScissorRect(&rectangle);
227 HRESULT hr=sprite.SetScissor(owner.Draws().Pipeline().raster.ScissorEnable!=FALSE,rectangle);
228 return FAILED(hr) ? hr : sprite.Flush();
229 }
231 {
232 if(!active)return E_UNEXPECTED;
233 const HRESULT flush=Flush(),end=sprite.End();owner.activeSprite=previousSprite;previousSprite=nullptr;active=false;
234 return FAILED(flush) ? flush : end;
235 }
236 INT RenderFont::DrawTextW(RenderSprite* sprite,const wchar_t* text,INT count,RECT* rectangle,DWORD flags,PackedColor color)
237 {
238 if(sprite || (flags&DT_CALCRECT))return font.Draw(sprite ? &sprite->Native() : nullptr,text,count,rectangle,flags,color);
239 if(!automatic){automatic=std::make_unique<RenderSprite>(owner);if(FAILED(automatic->Initialize())){automatic.reset();return 0;}}
240 if(FAILED(automatic->Begin(SpriteFlags::AlphaBlend)))return 0;
241 const int result=font.Draw(&automatic->Native(),text,count,rectangle,flags,color);return FAILED(automatic->End()) ? 0 : result;
242 }
243 INT RenderFont::DrawFixedTextW(RenderSprite* sprite,const wchar_t* text,INT count,RECT* rectangle,DWORD flags,PackedColor color)
244 {
245 return sprite ? font.DrawFixed(&sprite->Native(),text,count,rectangle,flags,color)
246 : DrawTextW(sprite,text,count,rectangle,flags,color);
247 }
248 INT RenderFont::DrawTextA(RenderSprite* sprite,const char* text,INT count,RECT* rectangle,DWORD flags,PackedColor color)
249 {
250 if(!text || count==0)return 0;
251 const int length=count<0 ? int(strlen(text)) : count;
252 const int size=MultiByteToWideChar(CP_ACP,0,text,length,nullptr,0);if(!size)return 0;
253 std::wstring converted(size,L'\0');MultiByteToWideChar(CP_ACP,0,text,length,converted.data(),size);
254 return DrawTextW(sprite,converted.data(),size,rectangle,flags,color);
255 }
256 HRESULT RenderToTexture::Initialize(UINT requestedWidth,UINT requestedHeight,bool hasDepth)
257 {
258 width=requestedWidth;height=requestedHeight;return hasDepth ? depth.Create(owner.Native(),width,height,{1,0}) : S_OK;
259 }
261 {
262 if(saved || !surface || !surface->Target())return E_INVALIDARG;SurfaceDescription desc{};HRESULT hr=surface->GetDesc(&desc);if(FAILED(hr))return hr;
263 if(desc.Width!=width || desc.Height!=height)return E_INVALIDARG;
264 saved=std::make_unique<DrawContext11::Saved>(owner.Draws().Capture());
265 const D3D11_VIEWPORT viewport=requested ? D3D11_VIEWPORT{float(requested->X),float(requested->Y),float(requested->Width),float(requested->Height),requested->MinZ,requested->MaxZ}
266 : D3D11_VIEWPORT{0,0,float(width),float(height),0,1};
267 hr=owner.Draws().Target(surface->Target(),depth.WriteView(),viewport);
268 if(SUCCEEDED(hr))hr=owner.BeginScene();if(FAILED(hr)){owner.Draws().Restore(*saved);saved.reset();}return hr;
269 }
271 {
272 if(!saved)return E_UNEXPECTED;const HRESULT end=owner.EndScene();
273 const HRESULT restore=owner.Draws().Target(saved->color.Get(),saved->depth.Get(),saved->viewport);
274 saved.reset();return FAILED(end) ? end : restore;
275 }
277 {
278 if(!owner || !result)return E_INVALIDARG;*result=nullptr;auto value=std::make_unique<RenderSprite>(*owner);
279 const HRESULT hr=value->Initialize();if(SUCCEEDED(hr))*result=value.release();return hr;
280 }
281 HRESULT CreateFontW(RenderDevice* owner,INT height,UINT width,UINT weight,UINT,BOOL italic,DWORD charset,
282 DWORD precision,DWORD quality,DWORD pitch,const wchar_t* face,RenderFont** result)
283 {
284 if(!owner || !result || !face)return E_INVALIDARG;*result=nullptr;
285 LOGFONTW description{};description.lfHeight=height;description.lfWidth=LONG(width);description.lfWeight=LONG(weight);
286 description.lfItalic=BYTE(italic!=FALSE);description.lfCharSet=BYTE(charset);description.lfOutPrecision=BYTE(precision);
287 description.lfQuality=BYTE(quality);description.lfPitchAndFamily=BYTE(pitch);wcsncpy_s(description.lfFaceName,face,_TRUNCATE);
288 auto value=std::make_unique<RenderFont>(*owner);const HRESULT hr=value->Initialize(description);if(SUCCEEDED(hr))*result=value.release();return hr;
289 }
290 HRESULT CreateFontA(RenderDevice* owner,INT height,UINT width,UINT weight,UINT mip,BOOL italic,DWORD charset,
291 DWORD precision,DWORD quality,DWORD pitch,const char* face,RenderFont** result)
292 {return CreateFontW(owner,height,width,weight,mip,italic,charset,precision,quality,pitch,Wide(face).c_str(),result);}
293 HRESULT CreateTexture(RenderDevice* owner,UINT width,UINT height,UINT levels,DWORD usage,ImageFormat format,ResourcePool,RenderTexture** result)
294 {
295 if(!owner || !result)return E_INVALIDARG;*result=nullptr;auto value=std::make_unique<RenderTexture>();
296 const HRESULT hr=value->Create(*owner,width,height,levels,usage,format);if(SUCCEEDED(hr))*result=value.release();return hr;
297 }
299 {
300 if(!owner || !result)return E_INVALIDARG;*result=nullptr;auto value=std::make_unique<RenderToTexture>(*owner);
301 const HRESULT hr=value->Initialize(width,height,depth!=FALSE);if(SUCCEEDED(hr))*result=value.release();return hr;
302 }
303 HRESULT LoadTexture(RenderDevice* owner,const wchar_t* path,RenderTexture** result,UINT levels,UINT width,UINT height)
304 try
305 {
306 if(!owner || !result)return E_INVALIDARG;*result=nullptr;auto value=std::make_unique<RenderTexture>();
307 const HRESULT hr=value->Load(*owner,path,levels,width,height);if(SUCCEEDED(hr))*result=value.release();return hr;
308 }
309 catch(const std::bad_alloc&){return E_OUTOFMEMORY;}
310 HRESULT LoadTexture(RenderDevice* owner,const char* path,RenderTexture** result,UINT levels)
311 try {if(result)*result=nullptr;return LoadTexture(owner,Wide(path).c_str(),result,levels);}
312 catch(const std::bad_alloc&){return E_OUTOFMEMORY;}
313 HRESULT LoadTextureMemory(RenderDevice* owner,const void* data,UINT bytes,RenderTexture** result,UINT levels)
314 try
315 {
316 if(!owner || !result)return E_INVALIDARG;*result=nullptr;auto value=std::make_unique<RenderTexture>();
317 const HRESULT hr=value->Load(*owner,data,bytes,levels);if(SUCCEEDED(hr))*result=value.release();return hr;
318 }
319 catch(const std::bad_alloc&){return E_OUTOFMEMORY;}
320}
SCRIPT_CONTROL SCRIPT_STATE const void int
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
SCRIPT_CONTROL SCRIPT_STATE const void SCRIPT_CONTROL SCRIPT_STATE const int SCRIPT_TABDEF const BYTE SCRIPT_STRING_ANALYSIS BOOL
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
void UnbindShaderResources()
Definition Device11.cpp:163
HRESULT ApplyPipeline(bool fixedPoints=false)
Materials11 & Materials()
HRESULT Restore(const Saved &saved)
HRESULT Target(ID3D11RenderTargetView *color, ID3D11DepthStencilView *depth, const D3D11_VIEWPORT &viewport)
int DrawFixed(Sprite11 *sprite, const wchar_t *text, int count, RECT *rectangle, UINT format, uint32_t color)
Definition Font11.cpp:346
int Draw(Sprite11 *sprite, const wchar_t *text, int count, RECT *rectangle, UINT format, uint32_t color)
Definition Font11.cpp:215
HRESULT Create(ID3D11Device *device, UINT bytes, bool dynamic, bool index=false, bool indices32=false)
Parameters11 & Values()
Definition Materials11.h:14
void Set(const std::string &name, const void *data, size_t bytes)
Definition Program11.cpp:45
HRESULT Create(RenderDevice &owner, UINT bytes, DWORD usage, bool index=false, bool indices32=false)
DrawContext11 & Draws()
ID3D11DeviceContext * Context()
HRESULT GetScissorRect(RECT *value) const
std::unique_ptr< RenderSprite > automatic
INT DrawTextW(RenderSprite *sprite, const wchar_t *text, INT count, RECT *rectangle, DWORD flags, PackedColor color)
INT DrawTextA(RenderSprite *sprite, const char *text, INT count, RECT *rectangle, DWORD flags, PackedColor color)
INT DrawFixedTextW(RenderSprite *sprite, const wchar_t *text, INT count, RECT *rectangle, DWORD flags, PackedColor color)
HRESULT SetValue(const char *name, const void *value, UINT bytes)
HRESULT Begin(UINT *count, DWORD flags)
HRESULT SetTexture(const char *name, RenderTexture *value)
HRESULT Initialize(RenderDevice &owner)
Microsoft::WRL::ComPtr< ID3D11Query > query
HRESULT Issue(DWORD flags)
HRESULT GetData(void *destination, DWORD bytes, DWORD flags)
std::array< DWORD, 3 > filters
HRESULT Begin(DWORD flags)
Microsoft::WRL::ComPtr< ID3D11Texture2D > texture
ID3D11RenderTargetView * Target() const
HRESULT GetDesc(SurfaceDescription *result) const
HRESULT Initialize(RenderDevice &owner, ID3D11Texture2D *texture, UINT level)
Microsoft::WRL::ComPtr< ID3D11RenderTargetView > target
HRESULT Load(RenderDevice &owner, const wchar_t *path, UINT levels=0, UINT width=0, UINT height=0)
HRESULT GetSurfaceLevel(UINT level, RenderSurface **result)
Microsoft::WRL::ComPtr< ID3D11DeviceContext > mappedContext
Microsoft::WRL::ComPtr< ID3D11ShaderResourceView > view
Microsoft::WRL::ComPtr< ID3D11Texture2D > staging
Microsoft::WRL::ComPtr< ID3D11Resource > resource
HRESULT GetLevelDesc(UINT level, SurfaceDescription *result) const
ID3D11ShaderResourceView * View() const
HRESULT Adopt(RenderDevice &owner, Texture11 &texture, UINT requestedLevels)
HRESULT Create(RenderDevice &owner, UINT width, UINT height, UINT levels, DWORD usage, ImageFormat format)
HRESULT LockRect(UINT level, LockedRectangle *result, const RECT *region, DWORD flags)
HRESULT UnlockRect(UINT level)
HRESULT EndScene(DWORD filter)
std::unique_ptr< DrawContext11::Saved > saved
HRESULT BeginScene(RenderSurface *surface, const Viewport *viewport)
HRESULT Initialize(UINT width, UINT height, bool hasDepth)
HRESULT Create(ID3D11Device *device, UINT width, UINT height, DXGI_SAMPLE_DESC samples)
Definition Device11.cpp:20
ID3D11DepthStencilView * WriteView() const
Definition Device11.h:18
HRESULT SetScissor(bool enabled, const RECT &rectangle)
Definition Sprite11.cpp:135
HRESULT Begin(ID3D11DeviceContext *context, const SpriteOptions11 &options={})
Definition Sprite11.cpp:47
ID3D11ShaderResourceView * View() const
Definition Texture11.h:20
ID3D11Resource * Resource() const
Definition Texture11.h:19
HRESULT Load(ID3D11Device *device, ID3D11DeviceContext *context, const wchar_t *path)
Definition Texture11.cpp:70
constexpr uint32_t DYNAMIC
constexpr uint32_t RENDERTARGET
constexpr uint32_t LINEAR
constexpr uint32_t ANISOTROPIC
constexpr uint32_t READONLY
constexpr uint32_t DISCARD
constexpr DWORD AlphaBlend
constexpr DWORD SortTexture
constexpr DWORD SortBackToFront
HRESULT LoadTextureMemory(RenderDevice *owner, const void *data, UINT bytes, RenderTexture **result, UINT levels=0)
ImageFormat ClientFormat(DXGI_FORMAT format)
HRESULT CreateRenderToSurface(RenderDevice *owner, UINT width, UINT height, ImageFormat format, BOOL depth, ImageFormat depthFormat, RenderToTexture **result)
HRESULT CreateFontW(RenderDevice *owner, INT height, UINT width, UINT weight, UINT mipLevels, BOOL italic, DWORD charset, DWORD precision, DWORD quality, DWORD pitch, const wchar_t *face, RenderFont **result)
HRESULT PrepareTextureDDS(const uint8_t *data, size_t size, UINT requested, UINT requestedWidth, UINT requestedHeight, std::vector< uint8_t > &output)
DXGI_FORMAT NativeFormat(ImageFormat format)
HRESULT CreateSprite(RenderDevice *owner, RenderSprite **result)
constexpr unsigned DefaultSize
HRESULT LoadTexture(RenderDevice *owner, const wchar_t *path, RenderTexture **result, UINT levels=0, UINT width=0, UINT height=0)
HRESULT CreateFontA(RenderDevice *owner, INT height, UINT width, UINT weight, UINT mipLevels, BOOL italic, DWORD charset, DWORD precision, DWORD quality, DWORD pitch, const char *face, RenderFont **result)
uint32_t PackedColor
HRESULT CreateTexture(RenderDevice *owner, UINT width, UINT height, UINT levels, DWORD usage, ImageFormat format, ResourcePool pool, RenderTexture **result)
D3D11_RASTERIZER_DESC raster