MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / createResourceForPass

Function createResourceForPass

Source/Falcor/RenderGraph/ResourceCache.cpp:122–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122inline ref<Resource> createResourceForPass(
123 ref<Device> pDevice,
124 const ResourceCache::DefaultProperties& params,
125 const RenderPassReflection::Field& field,
126 bool resolveBindFlags,
127 const std::string& resourceName
128)
129{
130 uint32_t width = field.getWidth() ? field.getWidth() : params.dims.x;
131 uint32_t height = field.getHeight() ? field.getHeight() : params.dims.y;
132 uint32_t depth = field.getDepth() ? field.getDepth() : 1;
133 uint32_t sampleCount = field.getSampleCount() ? field.getSampleCount() : 1;
134 auto bindFlags = field.getBindFlags();
135 auto arraySize = field.getArraySize();
136 auto mipLevels = field.getMipCount();
137
138 ResourceFormat format = ResourceFormat::Unknown;
139
140 if (field.getType() != RenderPassReflection::Field::Type::RawBuffer)
141 {
142 format = field.getFormat() == ResourceFormat::Unknown ? params.format : field.getFormat();
143 if (resolveBindFlags)
144 {
145 ResourceBindFlags mask = ResourceBindFlags::UnorderedAccess | ResourceBindFlags::ShaderResource;
146 bool isOutput = is_set(field.getVisibility(), RenderPassReflection::Field::Visibility::Output);
147 bool isInternal = is_set(field.getVisibility(), RenderPassReflection::Field::Visibility::Internal);
148 if (isOutput || isInternal)
149 mask |= ResourceBindFlags::DepthStencil | ResourceBindFlags::RenderTarget;
150 auto supported = pDevice->getFormatBindFlags(format);
151 mask &= supported;
152 bindFlags |= mask;
153 }
154 }
155 else // RawBuffer
156 {
157 if (resolveBindFlags)
158 bindFlags = ResourceBindFlags::UnorderedAccess | ResourceBindFlags::ShaderResource;
159 }
160 ref<Resource> pResource;
161
162 switch (field.getType())
163 {
164 case RenderPassReflection::Field::Type::RawBuffer:
165 pResource = pDevice->createBuffer(width, bindFlags, MemoryType::DeviceLocal);
166 break;
167 case RenderPassReflection::Field::Type::Texture1D:
168 pResource = pDevice->createTexture1D(width, format, arraySize, mipLevels, nullptr, bindFlags);
169 break;
170 case RenderPassReflection::Field::Type::Texture2D:
171 if (sampleCount > 1)
172 {
173 pResource = pDevice->createTexture2DMS(width, height, format, sampleCount, arraySize, bindFlags);
174 }
175 else
176 {
177 pResource = pDevice->createTexture2D(width, height, format, arraySize, mipLevels, nullptr, bindFlags);
178 }
179 break;

Callers 1

allocateResourcesMethod · 0.85

Calls 13

getWidthMethod · 0.80
getHeightMethod · 0.80
getFormatMethod · 0.80
getVisibilityMethod · 0.80
getFormatBindFlagsMethod · 0.80
createBufferMethod · 0.80
createTexture1DMethod · 0.80
createTexture2DMSMethod · 0.80
createTexture2DMethod · 0.80
createTexture3DMethod · 0.80
createTextureCubeMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected