28 SKGPU_LOG_E(
"Texture creation failure: dimensions %d x %d too large.",
39 if (dawnSpec.
fUsage & wgpu::TextureUsage::RenderAttachment &&
53 wgpu::TextureDescriptor
desc;
55 desc.dimension = wgpu::TextureDimension::e2D;
58 desc.size.depthOrArrayLayers = 1;
60 desc.mipLevelCount = numMipLevels;
61 desc.sampleCount =
info.numSamples();
62 desc.viewFormatCount = 0;
63 desc.viewFormats =
nullptr;
77 wgpu::TextureView sampleTextureView,
78 wgpu::TextureView renderTextureView,
88 , fSampleTextureView(
std::move(sampleTextureView))
89 , fRenderTextureView(
std::move(renderTextureView)) {}
92std::pair<wgpu::TextureView, wgpu::TextureView> DawnTexture::CreateTextureViews(
93 const wgpu::Texture&
texture,
const TextureInfo&
info) {
94 const auto aspect =
info.dawnTextureSpec().fAspect;
95 if (aspect == wgpu::TextureAspect::All) {
96 wgpu::TextureViewDescriptor viewDesc = {};
97 viewDesc.dimension = wgpu::TextureViewDimension::e2D;
98 viewDesc.baseArrayLayer =
info.dawnTextureSpec().fSlice;
99 viewDesc.arrayLayerCount = 1;
103 viewDesc.baseMipLevel = 0;
104 viewDesc.mipLevelCount = 1;
112#if defined(__EMSCRIPTEN__)
116 SkASSERT(aspect == wgpu::TextureAspect::Plane0Only ||
117 aspect == wgpu::TextureAspect::Plane1Only ||
118 aspect == wgpu::TextureAspect::Plane2Only);
119 wgpu::TextureView planeTextureView;
120 wgpu::TextureViewDescriptor planeViewDesc = {};
121 planeViewDesc.format =
info.dawnTextureSpec().fViewFormat;
122 planeViewDesc.dimension = wgpu::TextureViewDimension::e2D;
123 planeViewDesc.aspect = aspect;
124 planeViewDesc.baseArrayLayer =
info.dawnTextureSpec().fSlice;
125 planeViewDesc.arrayLayerCount = 1;
126 planeTextureView =
texture.CreateView(&planeViewDesc);
127 return {planeTextureView, planeTextureView};
155 SKGPU_LOG_E(
"No valid texture passed into MakeWrapped\n");
173 const wgpu::TextureView& textureView) {
175 SKGPU_LOG_E(
"No valid texture view passed into MakeWrapped\n");
188void DawnTexture::freeGpuData() {
196 fSampleTextureView =
nullptr;
197 fRenderTextureView =
nullptr;
200void DawnTexture::setBackendLabel(
char const* label) {
207 fTexture.SetLabel(label);
212 if (fSampleTextureView.Get() == fRenderTextureView.Get()) {
213 fSampleTextureView.SetLabel(
SkStringPrintf(
"%s_%s", label,
"_TextureView").c_str());
215 fSampleTextureView.SetLabel(
SkStringPrintf(
"%s_%s", label,
"_SampleTextureView").c_str());
216 fRenderTextureView.SetLabel(
SkStringPrintf(
"%s_%s", label,
"_RenderTextureView").c_str());
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
#define SKGPU_LOG_E(fmt,...)
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
static int ComputeLevelCount(int baseWidth, int baseHeight)
bool isTexturable(const TextureInfo &) const
virtual bool isStorage(const TextureInfo &) const =0
virtual bool isRenderable(const TextureInfo &) const =0
int maxTextureSize() const
static sk_sp< Texture > MakeWrapped(const DawnSharedContext *, SkISize dimensions, const TextureInfo &, wgpu::Texture)
static wgpu::Texture MakeDawnTexture(const DawnSharedContext *, SkISize dimensions, const TextureInfo &)
const wgpu::TextureView & renderTextureView() const
const wgpu::TextureView & sampleTextureView() const
static sk_sp< Texture > Make(const DawnSharedContext *, SkISize dimensions, const TextureInfo &, skgpu::Budgeted)
skgpu::Budgeted budgeted() const
const SharedContext * sharedContext() const
Ownership ownership() const
const Caps * caps() const
SkISize dimensions() const
bool DawnFormatIsDepthOrStencil(wgpu::TextureFormat format)
constexpr int32_t width() const
constexpr int32_t height() const
wgpu::TextureUsage fUsage
wgpu::TextureFormat fFormat