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

Method Texture

Source/Falcor/Core/API/Texture.cpp:74–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72} // namespace
73
74Texture::Texture(
75 ref<Device> pDevice,
76 Type type,
77 ResourceFormat format,
78 uint32_t width,
79 uint32_t height,
80 uint32_t depth,
81 uint32_t arraySize,
82 uint32_t mipLevels,
83 uint32_t sampleCount,
84 ResourceBindFlags bindFlags,
85 const void* pInitData
86)
87 : Resource(std::move(pDevice), type, bindFlags, 0)
88 , mFormat(format)
89 , mWidth(width)
90 , mHeight(height)
91 , mDepth(depth)
92 , mMipLevels(mipLevels)
93 , mArraySize(arraySize)
94 , mSampleCount(sampleCount)
95{
96 FALCOR_ASSERT(mType != Type::Buffer);
97 FALCOR_ASSERT(mFormat != ResourceFormat::Unknown);
98 FALCOR_ASSERT(mWidth > 0 && mHeight > 0 && mDepth > 0);
99 switch (mType)
100 {
101 case Resource::Type::Texture1D:
102 FALCOR_ASSERT(mHeight == 1 && mDepth == 1 && mSampleCount == 1);
103 break;
104 case Resource::Type::Texture2D:
105 FALCOR_ASSERT(mDepth == 1 && mSampleCount == 1);
106 break;
107 case Resource::Type::Texture2DMultisample:
108 FALCOR_ASSERT(mDepth == 1);
109 break;
110 case Resource::Type::Texture3D:
111 FALCOR_ASSERT(mSampleCount == 1);
112 break;
113 case Resource::Type::TextureCube:
114 FALCOR_ASSERT(mDepth == 1 && mSampleCount == 1);
115 break;
116 default:
117 FALCOR_UNREACHABLE();
118 break;
119 }
120
121 FALCOR_ASSERT(mArraySize > 0 && mMipLevels > 0 && mSampleCount > 0);
122
123 bool autoGenerateMips = pInitData && (mMipLevels == Texture::kMaxPossible);
124
125 if (autoGenerateMips)
126 mBindFlags |= ResourceBindFlags::RenderTarget;
127
128 if (mMipLevels == kMaxPossible)
129 {
130 uint32_t dims = width | height | depth;
131 mMipLevels = bitScanReverse(dims) + 1;

Callers

nothing calls this directly

Calls 11

getGfxResourceTypeFunction · 0.85
getGFXResourceStateFunction · 0.85
align_toFunction · 0.85
getGFXFormatFunction · 0.85
getFormatBindFlagsMethod · 0.80
writeRefMethod · 0.80
to_stringFunction · 0.70
bitScanReverseFunction · 0.50
resizeMethod · 0.45

Tested by

no test coverage detected