MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / Initialize

Method Initialize

SampleFramework11/v1.02/Graphics/GraphicsTypes.cpp:36–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36void RenderTarget2D::Initialize(ID3D11Device* device,
37 uint32 width,
38 uint32 height,
39 DXGI_FORMAT format,
40 uint32 numMipLevels,
41 uint32 multiSamples,
42 uint32 msQuality,
43 bool32 autoGenMipMaps,
44 bool32 createUAV,
45 uint32 arraySize,
46 bool32 cubeMap)
47{
48 D3D11_TEXTURE2D_DESC desc;
49 desc.Width = width;
50 desc.Height = height;
51 desc.ArraySize = arraySize;
52 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE|D3D11_BIND_RENDER_TARGET;
53 if(createUAV)
54 desc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
55
56 desc.CPUAccessFlags = 0;
57 desc.Format = format;
58 desc.MipLevels = numMipLevels;
59 desc.MiscFlags = (autoGenMipMaps && numMipLevels != 1) ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0;
60 desc.SampleDesc.Count = multiSamples;
61 desc.SampleDesc.Quality = msQuality;
62 desc.Usage = D3D11_USAGE_DEFAULT;
63
64 if(cubeMap)
65 {
66 Assert_(arraySize == 6);
67 desc.MiscFlags |= D3D11_RESOURCE_MISC_TEXTURECUBE;
68 }
69
70 DXCall(device->CreateTexture2D(&desc, nullptr, &Texture));
71
72 RTVArraySlices.clear();
73 RTVArraySlices.reserve(arraySize);
74 for(uint32 i = 0; i < arraySize; ++i)
75 {
76 ID3D11RenderTargetViewPtr rtView;
77 D3D11_RENDER_TARGET_VIEW_DESC rtDesc;
78 rtDesc.Format = format;
79
80 if(arraySize == 1)
81 {
82 if(multiSamples > 1)
83 {
84 rtDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS;
85 }
86 else
87 {
88 rtDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
89 rtDesc.Texture2D.MipSlice = 0;
90 }
91 }
92 else
93 {

Callers 1

WriteToFileMethod · 0.45

Calls 4

DXCallFunction · 0.85
clearMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected