MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / DX11TextureRT

Method DX11TextureRT

GTE/Graphics/DX11/DX11TextureRT.cpp:17–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16
17DX11TextureRT::DX11TextureRT(ID3D11Device* device, TextureRT const* texture)
18 :
19 DX11Texture2(texture),
20 mRTView(nullptr)
21{
22 // Specify the texture description.
23 D3D11_TEXTURE2D_DESC desc;
24 desc.Width = texture->GetWidth();
25 desc.Height = texture->GetHeight();
26 desc.MipLevels = texture->GetNumLevels();
27 desc.ArraySize = 1;
28 desc.Format = static_cast<DXGI_FORMAT>(texture->GetFormat());
29 desc.SampleDesc.Count = 1;
30 desc.SampleDesc.Quality = 0;
31 desc.Usage = D3D11_USAGE_DEFAULT;
32 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
33 desc.CPUAccessFlags = D3D11_CPU_ACCESS_NONE;
34 desc.MiscFlags = (texture->IsShared() ?
35 D3D11_RESOURCE_MISC_SHARED : D3D11_RESOURCE_MISC_NONE);
36
37 if (texture->GetUsage() == Resource::Usage::SHADER_OUTPUT)
38 {
39 desc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
40 }
41
42 if (texture->WantAutogenerateMipmaps() && !texture->IsShared())
43 {
44 desc.MiscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS;
45 }
46
47 // Create the texture.
48 ID3D11Texture2D* dxTexture = nullptr;
49 if (texture->GetData())
50 {
51 uint32_t const numSubresources = texture->GetNumSubresources();
52 std::vector<D3D11_SUBRESOURCE_DATA> data(numSubresources);
53 for (uint32_t index = 0; index < numSubresources; ++index)
54 {
55 auto sr = texture->GetSubresource(index);
56 data[index].pSysMem = sr.data;
57 data[index].SysMemPitch = sr.rowPitch;
58 data[index].SysMemSlicePitch = 0;
59 }
60 DX11Log(device->CreateTexture2D(&desc, &data[0], &dxTexture));
61 }
62 else
63 {
64 DX11Log(device->CreateTexture2D(&desc, nullptr, &dxTexture));
65 }
66 mDXObject = dxTexture;
67
68 // Create views of the texture.
69 CreateSRView(device, desc);
70 CreateRTView(device, desc);
71 if (texture->GetUsage() == Resource::Usage::SHADER_OUTPUT)
72 {
73 CreateUAView(device, desc);
74 }

Callers

nothing calls this directly

Calls 13

GetNumLevelsMethod · 0.80
IsSharedMethod · 0.80
GetNumSubresourcesMethod · 0.80
GetSubresourceMethod · 0.80
CreateSharedDXObjectMethod · 0.80
GetWidthMethod · 0.45
GetHeightMethod · 0.45
GetFormatMethod · 0.45
GetUsageMethod · 0.45
GetDataMethod · 0.45
GetCopyMethod · 0.45

Tested by

no test coverage detected