23 D3D11_TEXTURE2D_DESC desc;
29 desc.SampleDesc.Count = 1;
30 desc.SampleDesc.Quality = 0;
31 desc.Usage = D3D11_USAGE_DEFAULT;
32 desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
34 desc.MiscFlags = (texture->
IsShared() ?
38 desc.BindFlags |= D3D11_BIND_SHADER_RESOURCE;
43 ID3D11Texture2D* dxTexture =
nullptr;
44 HRESULT hr = device->CreateTexture2D(&desc,
nullptr, &dxTexture);
79 return std::make_shared<DX11TextureDS>(
80 reinterpret_cast<ID3D11Device*
>(device),
81 static_cast<TextureDS const*>(
object));
97 D3D11_DEPTH_STENCIL_VIEW_DESC desc;
99 desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
101 desc.Texture2D.MipSlice = 0;
108 D3D11_SHADER_RESOURCE_VIEW_DESC desc;
110 desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
111 desc.Texture2D.MostDetailedMip = 0;
112 desc.Texture2D.MipLevels = 1;
119 if (depthFormat == DXGI_FORMAT_D16_UNORM)
121 return DXGI_FORMAT_R16_TYPELESS;
124 if (depthFormat == DXGI_FORMAT_D24_UNORM_S8_UINT)
126 return DXGI_FORMAT_R24G8_TYPELESS;
129 if (depthFormat == DXGI_FORMAT_D32_FLOAT)
131 return DXGI_FORMAT_R32_TYPELESS;
134 if (depthFormat == DXGI_FORMAT_D32_FLOAT_S8X24_UINT)
136 return DXGI_FORMAT_R32G8X24_TYPELESS;
140 return DXGI_FORMAT_UNKNOWN;
145 if (depthFormat == DXGI_FORMAT_D16_UNORM)
147 return DXGI_FORMAT_R16_UNORM;
150 if (depthFormat == DXGI_FORMAT_D24_UNORM_S8_UINT)
152 return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
155 if (depthFormat == DXGI_FORMAT_D32_FLOAT)
157 return DXGI_FORMAT_R32_FLOAT;
160 if (depthFormat == DXGI_FORMAT_D32_FLOAT_S8X24_UINT)
162 return DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS;
166 return DXGI_FORMAT_UNKNOWN;
virtual void SetName(std::string const &name) override
unsigned int GetWidth() const
static std::shared_ptr< GEObject > Create(void *device, GraphicsObject const *object)
#define D3D11_RESOURCE_MISC_NONE
#define CHECK_HR_RETURN_NONE(msg)
HRESULT SetPrivateName(ID3D11DeviceChild *object, std::string const &name)
DXGI_FORMAT GetDepthSRVFormat(DXGI_FORMAT depthFormat)
Texture2 * GetTexture() const
DXGI_FORMAT GetDepthResourceFormat(DXGI_FORMAT depthFormat)
GraphicsObjectType GetType() const
GLuint const GLchar * name
ULONG FinalRelease(T *&object)
DX11TextureDS(ID3D11Device *device, TextureDS const *texture)
virtual void SetName(std::string const &name)
ID3D11Texture2D * GetDXTexture() const
GLsizei const GLchar *const * string
#define LogError(message)
unsigned int GetHeight() const
ID3D11DeviceChild * mDXObject
void CreateDSSRView(ID3D11Device *device)
void CreateStaging(ID3D11Device *device, D3D11_TEXTURE2D_DESC const &tx)
void CreateDSView(ID3D11Device *device)
#define D3D11_CPU_ACCESS_NONE
#define CHECK_HR_RETURN_VOID(msg)
bool IsShaderInput() const
CopyType GetCopyType() const
ID3D11Texture2D * CreateSharedDXObject(ID3D11Device *device) const
ID3D11DepthStencilView * mDSView
ID3D11ShaderResourceView * mSRView