mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-01 01:45:38 +00:00
This will be used by Blink to create error textures with correct reflection information exposed to JavaScript. Bug: chromium:1345736 Change-Id: I0bc3a72d602c1bb57dc76e90f4883951f86ef428 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96681 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Shrek Shao <shrekshao@google.com> Commit-Queue: Shrek Shao <shrekshao@google.com> Reviewed-by: Austin Eng <enga@chromium.org> Auto-Submit: Corentin Wallez <cwallez@chromium.org>
98 lines
2.8 KiB
C++
98 lines
2.8 KiB
C++
// Copyright 2022 The Dawn Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "dawn/wire/client/Texture.h"
|
|
|
|
#include "dawn/wire/client/Client.h"
|
|
#include "dawn/wire/client/Device.h"
|
|
|
|
namespace dawn::wire::client {
|
|
|
|
// static
|
|
WGPUTexture Texture::Create(Device* device, const WGPUTextureDescriptor* descriptor) {
|
|
Client* wireClient = device->GetClient();
|
|
Texture* texture = wireClient->Make<Texture>(descriptor);
|
|
|
|
// Send the Device::CreateTexture command without modifications.
|
|
DeviceCreateTextureCmd cmd;
|
|
cmd.self = ToAPI(device);
|
|
cmd.selfId = device->GetWireId();
|
|
cmd.descriptor = descriptor;
|
|
cmd.result = texture->GetWireHandle();
|
|
wireClient->SerializeCommand(cmd);
|
|
|
|
return ToAPI(texture);
|
|
}
|
|
|
|
// static
|
|
WGPUTexture Texture::CreateError(Device* device, const WGPUTextureDescriptor* descriptor) {
|
|
Client* wireClient = device->GetClient();
|
|
Texture* texture = wireClient->Make<Texture>(descriptor);
|
|
|
|
// Send the Device::CreateErrorTexture command without modifications.
|
|
DeviceCreateErrorTextureCmd cmd;
|
|
cmd.self = ToAPI(device);
|
|
cmd.selfId = device->GetWireId();
|
|
cmd.descriptor = descriptor;
|
|
cmd.result = texture->GetWireHandle();
|
|
wireClient->SerializeCommand(cmd);
|
|
|
|
return ToAPI(texture);
|
|
}
|
|
|
|
Texture::Texture(const ObjectBaseParams& params, const WGPUTextureDescriptor* descriptor)
|
|
: ObjectBase(params),
|
|
mSize(descriptor->size),
|
|
mMipLevelCount(descriptor->mipLevelCount),
|
|
mSampleCount(descriptor->sampleCount),
|
|
mDimension(descriptor->dimension),
|
|
mFormat(descriptor->format),
|
|
mUsage(static_cast<WGPUTextureUsage>(descriptor->usage)) {}
|
|
|
|
Texture::~Texture() = default;
|
|
|
|
uint32_t Texture::GetWidth() const {
|
|
return mSize.width;
|
|
}
|
|
|
|
uint32_t Texture::GetHeight() const {
|
|
return mSize.height;
|
|
}
|
|
|
|
uint32_t Texture::GetDepthOrArrayLayers() const {
|
|
return mSize.depthOrArrayLayers;
|
|
}
|
|
|
|
uint32_t Texture::GetMipLevelCount() const {
|
|
return mMipLevelCount;
|
|
}
|
|
|
|
uint32_t Texture::GetSampleCount() const {
|
|
return mSampleCount;
|
|
}
|
|
|
|
WGPUTextureDimension Texture::GetDimension() const {
|
|
return mDimension;
|
|
}
|
|
|
|
WGPUTextureFormat Texture::GetFormat() const {
|
|
return mFormat;
|
|
}
|
|
|
|
WGPUTextureUsage Texture::GetUsage() const {
|
|
return mUsage;
|
|
}
|
|
|
|
} // namespace dawn::wire::client
|