17 D3D11_TEXTURE2D_DESC desc;
22 desc.Format =
static_cast<DXGI_FORMAT
>(texture->
GetFormat());
23 desc.SampleDesc.Count = 1;
24 desc.SampleDesc.Quality = 0;
25 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
26 desc.MiscFlags = (texture->
IsShared() ?
31 desc.Usage = D3D11_USAGE_IMMUTABLE;
36 desc.Usage = D3D11_USAGE_DYNAMIC;
37 desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
41 desc.Usage = D3D11_USAGE_DEFAULT;
42 desc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
48 desc.Usage = D3D11_USAGE_DEFAULT;
49 desc.BindFlags |= D3D11_BIND_RENDER_TARGET;
51 desc.MiscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS;
55 ID3D11Texture2D* dxTexture =
nullptr;
60 std::vector<D3D11_SUBRESOURCE_DATA>
data(numSubresources);
65 data[
index].SysMemPitch = sr.rowPitch;
66 data[
index].SysMemSlicePitch = 0;
68 hr = device->CreateTexture2D(&desc, &data[0], &dxTexture);
72 hr = device->CreateTexture2D(&desc,
nullptr, &dxTexture);
79 if (texture->
GetUsage() == Resource::SHADER_OUTPUT)
93 ID3D11DeviceContext* context;
94 device->GetImmediateContext(&context);
108 auto gtTexture = dxSharedTexture->
GetTexture();
109 D3D11_TEXTURE2D_DESC desc;
110 dxShared->GetDesc(&desc);
112 if (gtTexture->GetUsage() == Resource::SHADER_OUTPUT)
126 ID3D11ShaderResourceView* dxSRView)
138 return std::make_shared<DX11Texture2>(
139 reinterpret_cast<ID3D11Device*
>(device),
140 static_cast<Texture2 const*>(
object));
155 IDXGIResource* resource =
nullptr;
156 HRESULT hr =
mDXObject->QueryInterface(__uuidof(IDXGIResource), (
void**)&resource);
160 hr = resource->GetSharedHandle(&handle);
164 ID3D11Texture2D* dxShared =
nullptr;
165 hr = device->OpenSharedResource(handle, __uuidof(ID3D11Texture2D), (
void**)&dxShared);
172 D3D11_TEXTURE2D_DESC desc;
173 desc.Width = tx.Width;
174 desc.Height = tx.Height;
175 desc.MipLevels = tx.MipLevels;
176 desc.ArraySize = tx.ArraySize;
177 desc.Format = tx.Format;
178 desc.SampleDesc.Count = tx.SampleDesc.Count;
179 desc.SampleDesc.Quality = tx.SampleDesc.Quality;
180 desc.Usage = D3D11_USAGE_STAGING;
185 HRESULT hr = device->CreateTexture2D(&desc,
nullptr, reinterpret_cast<ID3D11Texture2D**>(&
mStaging));
191 D3D11_SHADER_RESOURCE_VIEW_DESC desc;
192 desc.Format = tx.Format;
193 desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
194 desc.Texture2D.MostDetailedMip = 0;
195 desc.Texture2D.MipLevels = tx.MipLevels;
203 D3D11_UNORDERED_ACCESS_VIEW_DESC desc;
204 desc.Format = tx.Format;
205 desc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D;
206 desc.Texture2D.MipSlice = 0;
unsigned int GetWidth() const
#define D3D11_RESOURCE_MISC_NONE
static std::shared_ptr< GEObject > Create(void *device, GraphicsObject const *object)
#define CHECK_HR_RETURN_NONE(msg)
void CreateSRView(ID3D11Device *device, D3D11_TEXTURE2D_DESC const &tx)
typedef HANDLE(WINAPI *PFNWGLCREATEBUFFERREGIONARBPROC)(HDC hDC
Texture2 * GetTexture() const
GraphicsObjectType GetType() const
ID3D11UnorderedAccessView * mUAView
ID3D11Resource * mStaging
void CreateUAView(ID3D11Device *device, D3D11_TEXTURE2D_DESC const &tx)
ID3D11Texture2D * GetDXTexture() const
#define LogError(message)
unsigned int GetHeight() const
ID3D11DeviceChild * mDXObject
char const * GetData() const
void CreateStaging(ID3D11Device *device, D3D11_TEXTURE2D_DESC const &tx)
unsigned int GetNumLevels() const
GLsizeiptr const void GLenum usage
Subresource GetSubresource(unsigned int index) const
#define D3D11_CPU_ACCESS_NONE
#define CHECK_HR_RETURN_VOID(msg)
static UINT const msStagingAccess[]
CopyType GetCopyType() const
ID3D11Texture2D * CreateSharedDXObject(ID3D11Device *device) const
#define CHECK_HR_RETURN(msg, value)
DX11Texture2(ID3D11Device *device, Texture2 const *texture)
bool WantAutogenerateMipmaps() const
ID3D11ShaderResourceView * mSRView
unsigned int GetNumSubresources() const