mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-06 22:53:35 +00:00
This CL adds some missing constructors and destructors. Others are moved from the header file to implementation files. Bug: dawn:1405 Change-Id: I17e98f6da48518112bafb0876679cc3989ba2548 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89160 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
67 lines
2.2 KiB
C++
67 lines
2.2 KiB
C++
// Copyright 2021 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/ShaderModule.h"
|
|
|
|
#include "dawn/wire/client/Client.h"
|
|
|
|
namespace dawn::wire::client {
|
|
|
|
ShaderModule::ShaderModule(Client* c, uint32_t r, uint32_t i) : ObjectBase(c, r, i) {}
|
|
|
|
ShaderModule::~ShaderModule() {
|
|
ClearAllCallbacks(WGPUCompilationInfoRequestStatus_Unknown);
|
|
}
|
|
|
|
void ShaderModule::GetCompilationInfo(WGPUCompilationInfoCallback callback, void* userdata) {
|
|
if (client->IsDisconnected()) {
|
|
callback(WGPUCompilationInfoRequestStatus_DeviceLost, nullptr, userdata);
|
|
return;
|
|
}
|
|
|
|
uint64_t serial = mCompilationInfoRequests.Add({callback, userdata});
|
|
|
|
ShaderModuleGetCompilationInfoCmd cmd;
|
|
cmd.shaderModuleId = this->id;
|
|
cmd.requestSerial = serial;
|
|
|
|
client->SerializeCommand(cmd);
|
|
}
|
|
|
|
bool ShaderModule::GetCompilationInfoCallback(uint64_t requestSerial,
|
|
WGPUCompilationInfoRequestStatus status,
|
|
const WGPUCompilationInfo* info) {
|
|
CompilationInfoRequest request;
|
|
if (!mCompilationInfoRequests.Acquire(requestSerial, &request)) {
|
|
return false;
|
|
}
|
|
|
|
request.callback(status, info, request.userdata);
|
|
return true;
|
|
}
|
|
|
|
void ShaderModule::CancelCallbacksForDisconnect() {
|
|
ClearAllCallbacks(WGPUCompilationInfoRequestStatus_DeviceLost);
|
|
}
|
|
|
|
void ShaderModule::ClearAllCallbacks(WGPUCompilationInfoRequestStatus status) {
|
|
mCompilationInfoRequests.CloseAll([status](CompilationInfoRequest* request) {
|
|
if (request->callback != nullptr) {
|
|
request->callback(status, nullptr, request->userdata);
|
|
}
|
|
});
|
|
}
|
|
|
|
} // namespace dawn::wire::client
|