tint->dawn: Move src/dawn_platform -> src/dawn/platform

Bug: dawn:1275
Change-Id: I043c5e6d84e199fe2e753ac43181b125882439bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79082
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Ben Clayton 2022-02-04 12:51:25 +00:00
parent 20cbe6d9e8
commit b2c4d7a244
39 changed files with 338 additions and 318 deletions

View File

@ -214,7 +214,7 @@ add_subdirectory(third_party)
add_subdirectory(generator)
add_subdirectory(src/dawn)
add_subdirectory(src/dawn/common)
add_subdirectory(src/dawn_platform)
add_subdirectory(src/dawn/platform)
add_subdirectory(src/dawn_native)
add_subdirectory(src/dawn/wire)
# TODO(dawn:269): Remove once the implementation-based swapchains are removed.

View File

@ -17,9 +17,9 @@ This repository contains the implementation of Dawn, which is itself composed of
- [`common`](../src/dawn/common): helper code that is allowed to be used by Dawn's core libraries, `dawn_native` and `dawn_wire`. Also allowed for use in all other Dawn targets.
- [`wire`](../src/dawn/wire): code for an implementation of WebGPU as a client-server architecture.
- [`utils`](../src/dawn/utils): helper code to use Dawn used by tests and samples but disallowed for `dawn_native` and `dawn_wire`.
- [`platform`](../src/dawn/platform): definition of interfaces for dependency injection in `dawn_native` or `dawn_wire`.
- [`dawn_native`](../src/dawn_native): code for the implementation of WebGPU on top of graphics APIs. Files in this folder are the "frontend" while subdirectories are "backends".
- `<backend>`: code for the implementation of the backend on a specific graphics API, for example `d3d12`, `metal` or `vulkan`.
- [`dawn_platform`](../src/dawn_platform): definition of interfaces for dependency injection in `dawn_native` or `dawn_wire`.
- [`fuzzers`](../src/dawn/fuzzers): various fuzzers for Dawn that are running in [Clusterfuzz](https://google.github.io/clusterfuzz/).
- [`include`](../src/include): public headers with subdirectories for each library. Note that some headers are auto-generated and not present directly in the directory.
- [`tests`](../src/tests):

View File

@ -0,0 +1,41 @@
# Copyright 2020 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.
import("../../../scripts/dawn_overrides_with_defaults.gni")
import("${dawn_root}/scripts/dawn_component.gni")
dawn_component("platform") {
DEFINE_PREFIX = "DAWN_PLATFORM"
configs = [ "${dawn_root}/src/dawn/common:internal_config" ]
sources = [
"${dawn_root}/src/include/dawn/platform/DawnPlatform.h",
"${dawn_root}/src/include/dawn/platform/dawn_platform_export.h",
"DawnPlatform.cpp",
"WorkerThread.cpp",
"WorkerThread.h",
"tracing/EventTracer.cpp",
"tracing/EventTracer.h",
"tracing/TraceEvent.h",
]
deps = [ "${dawn_root}/src/dawn/common" ]
public_deps = [
# DawnPlatform.h has #include <dawn/webgpu.h>
"${dawn_root}/src/dawn:dawn_headers",
]
}

View File

@ -20,8 +20,8 @@ if(BUILD_SHARED_LIBS)
endif()
target_sources(dawn_platform PRIVATE
"${DAWN_INCLUDE_DIR}/dawn_platform/DawnPlatform.h"
"${DAWN_INCLUDE_DIR}/dawn_platform/dawn_platform_export.h"
"${DAWN_INCLUDE_DIR}/dawn/platform/DawnPlatform.h"
"${DAWN_INCLUDE_DIR}/dawn/platform/dawn_platform_export.h"
"DawnPlatform.cpp"
"WorkerThread.cpp"
"WorkerThread.h"

View File

@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/WorkerThread.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/WorkerThread.h"
#include "dawn/common/Assert.h"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "dawn_platform/WorkerThread.h"
#include "dawn/platform/WorkerThread.h"
#include <condition_variable>
#include <functional>

View File

@ -16,7 +16,7 @@
#define COMMON_WORKERTHREAD_H_
#include "dawn/common/NonCopyable.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn/platform/DawnPlatform.h"
namespace dawn::platform {

View File

@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "dawn_platform/tracing/EventTracer.h"
#include "dawn/platform/tracing/EventTracer.h"
#include "dawn/common/Assert.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn/platform/DawnPlatform.h"
namespace dawn::platform::tracing {

View File

@ -15,7 +15,7 @@
#ifndef DAWNPLATFORM_TRACING_EVENTTRACER_H_
#define DAWNPLATFORM_TRACING_EVENTTRACER_H_
#include "dawn_platform/dawn_platform_export.h"
#include "dawn/platform/dawn_platform_export.h"
#include <cstdint>

View File

@ -154,7 +154,7 @@
#include <string>
#include "dawn_platform/tracing/EventTracer.h"
#include "dawn/platform/tracing/EventTracer.h"
// Records a pair of begin and end events called "name" for the current
// scope, with 0, 1 or 2 associated arguments. If the category is not
@ -856,137 +856,135 @@ namespace dawn::platform::TraceEvent {
*value = static_cast<unsigned long long>(arg); \
}
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long long, TRACE_VALUE_TYPE_UINT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned int, TRACE_VALUE_TYPE_UINT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned short, TRACE_VALUE_TYPE_UINT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned char, TRACE_VALUE_TYPE_UINT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long long, TRACE_VALUE_TYPE_INT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT)
INTERNAL_DECLARE_SET_TRACE_VALUE(bool, m_bool, TRACE_VALUE_TYPE_BOOL)
INTERNAL_DECLARE_SET_TRACE_VALUE(double, m_double, TRACE_VALUE_TYPE_DOUBLE)
INTERNAL_DECLARE_SET_TRACE_VALUE(const void*, m_pointer, TRACE_VALUE_TYPE_POINTER)
INTERNAL_DECLARE_SET_TRACE_VALUE(const char*, m_string, TRACE_VALUE_TYPE_STRING)
INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&,
m_string,
TRACE_VALUE_TYPE_COPY_STRING)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long long, TRACE_VALUE_TYPE_UINT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned int, TRACE_VALUE_TYPE_UINT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned short, TRACE_VALUE_TYPE_UINT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned char, TRACE_VALUE_TYPE_UINT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long long, TRACE_VALUE_TYPE_INT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT)
INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT)
INTERNAL_DECLARE_SET_TRACE_VALUE(bool, m_bool, TRACE_VALUE_TYPE_BOOL)
INTERNAL_DECLARE_SET_TRACE_VALUE(double, m_double, TRACE_VALUE_TYPE_DOUBLE)
INTERNAL_DECLARE_SET_TRACE_VALUE(const void*, m_pointer, TRACE_VALUE_TYPE_POINTER)
INTERNAL_DECLARE_SET_TRACE_VALUE(const char*, m_string, TRACE_VALUE_TYPE_STRING)
INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&,
m_string,
TRACE_VALUE_TYPE_COPY_STRING)
#undef INTERNAL_DECLARE_SET_TRACE_VALUE
#undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT
static inline void setTraceValue(const std::string& arg,
unsigned char* type,
uint64_t* value) {
TraceValueUnion typeValue;
typeValue.m_string = arg.data();
*type = TRACE_VALUE_TYPE_COPY_STRING;
*value = typeValue.m_uint;
static inline void setTraceValue(const std::string& arg, unsigned char* type, uint64_t* value) {
TraceValueUnion typeValue;
typeValue.m_string = arg.data();
*type = TRACE_VALUE_TYPE_COPY_STRING;
*value = typeValue.m_uint;
}
// These addTraceEvent template functions are defined here instead of in the
// macro, because the arg values could be temporary string objects. In order to
// store pointers to the internal c_str and pass through to the tracing API, the
// arg values must live throughout these procedures.
static inline dawn::platform::tracing::TraceEventHandle addTraceEvent(
dawn::platform::Platform* platform,
char phase,
const unsigned char* categoryEnabled,
const char* name,
unsigned long long id,
unsigned char flags,
int /*unused, helps avoid empty __VA_ARGS__*/) {
return TRACE_EVENT_API_ADD_TRACE_EVENT(platform, phase, categoryEnabled, name, id,
zeroNumArgs, 0, 0, 0, flags);
}
template <class ARG1_TYPE>
static inline dawn::platform::tracing::TraceEventHandle addTraceEvent(
dawn::platform::Platform* platform,
char phase,
const unsigned char* categoryEnabled,
const char* name,
unsigned long long id,
unsigned char flags,
int /*unused, helps avoid empty __VA_ARGS__*/,
const char* arg1Name,
const ARG1_TYPE& arg1Val) {
const int numArgs = 1;
unsigned char argTypes[1];
uint64_t argValues[1];
setTraceValue(arg1Val, &argTypes[0], &argValues[0]);
return TRACE_EVENT_API_ADD_TRACE_EVENT(platform, phase, categoryEnabled, name, id, numArgs,
&arg1Name, argTypes, argValues, flags);
}
template <class ARG1_TYPE, class ARG2_TYPE>
static inline dawn::platform::tracing::TraceEventHandle addTraceEvent(
dawn::platform::Platform* platform,
char phase,
const unsigned char* categoryEnabled,
const char* name,
unsigned long long id,
unsigned char flags,
int /*unused, helps avoid empty __VA_ARGS__*/,
const char* arg1Name,
const ARG1_TYPE& arg1Val,
const char* arg2Name,
const ARG2_TYPE& arg2Val) {
const int numArgs = 2;
const char* argNames[2] = {arg1Name, arg2Name};
unsigned char argTypes[2];
uint64_t argValues[2];
setTraceValue(arg1Val, &argTypes[0], &argValues[0]);
setTraceValue(arg2Val, &argTypes[1], &argValues[1]);
return TRACE_EVENT_API_ADD_TRACE_EVENT(platform, phase, categoryEnabled, name, id, numArgs,
argNames, argTypes, argValues, flags);
}
// Used by TRACE_EVENTx macro. Do not use directly.
class TraceEndOnScopeClose {
public:
// Note: members of m_data intentionally left uninitialized. See initialize.
TraceEndOnScopeClose() : m_pdata(0) {
}
~TraceEndOnScopeClose() {
if (m_pdata)
addEventIfEnabled();
}
// These addTraceEvent template functions are defined here instead of in the
// macro, because the arg values could be temporary string objects. In order to
// store pointers to the internal c_str and pass through to the tracing API, the
// arg values must live throughout these procedures.
static inline dawn::platform::tracing::TraceEventHandle addTraceEvent(
dawn::platform::Platform* platform,
char phase,
const unsigned char* categoryEnabled,
const char* name,
unsigned long long id,
unsigned char flags,
int /*unused, helps avoid empty __VA_ARGS__*/) {
return TRACE_EVENT_API_ADD_TRACE_EVENT(platform, phase, categoryEnabled, name, id,
zeroNumArgs, 0, 0, 0, flags);
void initialize(dawn::platform::Platform* platform,
const unsigned char* categoryEnabled,
const char* name) {
m_data.platform = platform;
m_data.categoryEnabled = categoryEnabled;
m_data.name = name;
m_pdata = &m_data;
}
template <class ARG1_TYPE>
static inline dawn::platform::tracing::TraceEventHandle addTraceEvent(
dawn::platform::Platform* platform,
char phase,
const unsigned char* categoryEnabled,
const char* name,
unsigned long long id,
unsigned char flags,
int /*unused, helps avoid empty __VA_ARGS__*/,
const char* arg1Name,
const ARG1_TYPE& arg1Val) {
const int numArgs = 1;
unsigned char argTypes[1];
uint64_t argValues[1];
setTraceValue(arg1Val, &argTypes[0], &argValues[0]);
return TRACE_EVENT_API_ADD_TRACE_EVENT(platform, phase, categoryEnabled, name, id,
numArgs, &arg1Name, argTypes, argValues, flags);
private:
// Add the end event if the category is still enabled.
void addEventIfEnabled() {
// Only called when m_pdata is non-null.
if (*m_pdata->categoryEnabled) {
TRACE_EVENT_API_ADD_TRACE_EVENT(m_pdata->platform, TRACE_EVENT_PHASE_END,
m_pdata->categoryEnabled, m_pdata->name, noEventId,
zeroNumArgs, 0, 0, 0, TRACE_EVENT_FLAG_NONE);
}
}
template <class ARG1_TYPE, class ARG2_TYPE>
static inline dawn::platform::tracing::TraceEventHandle addTraceEvent(
dawn::platform::Platform* platform,
char phase,
const unsigned char* categoryEnabled,
const char* name,
unsigned long long id,
unsigned char flags,
int /*unused, helps avoid empty __VA_ARGS__*/,
const char* arg1Name,
const ARG1_TYPE& arg1Val,
const char* arg2Name,
const ARG2_TYPE& arg2Val) {
const int numArgs = 2;
const char* argNames[2] = {arg1Name, arg2Name};
unsigned char argTypes[2];
uint64_t argValues[2];
setTraceValue(arg1Val, &argTypes[0], &argValues[0]);
setTraceValue(arg2Val, &argTypes[1], &argValues[1]);
return TRACE_EVENT_API_ADD_TRACE_EVENT(platform, phase, categoryEnabled, name, id,
numArgs, argNames, argTypes, argValues, flags);
}
// Used by TRACE_EVENTx macro. Do not use directly.
class TraceEndOnScopeClose {
public:
// Note: members of m_data intentionally left uninitialized. See initialize.
TraceEndOnScopeClose() : m_pdata(0) {
}
~TraceEndOnScopeClose() {
if (m_pdata)
addEventIfEnabled();
}
void initialize(dawn::platform::Platform* platform,
const unsigned char* categoryEnabled,
const char* name) {
m_data.platform = platform;
m_data.categoryEnabled = categoryEnabled;
m_data.name = name;
m_pdata = &m_data;
}
private:
// Add the end event if the category is still enabled.
void addEventIfEnabled() {
// Only called when m_pdata is non-null.
if (*m_pdata->categoryEnabled) {
TRACE_EVENT_API_ADD_TRACE_EVENT(
m_pdata->platform, TRACE_EVENT_PHASE_END, m_pdata->categoryEnabled,
m_pdata->name, noEventId, zeroNumArgs, 0, 0, 0, TRACE_EVENT_FLAG_NONE);
}
}
// This Data struct workaround is to avoid initializing all the members
// in Data during construction of this object, since this object is always
// constructed, even when tracing is disabled. If the members of Data were
// members of this class instead, compiler warnings occur about potential
// uninitialized accesses.
struct Data {
dawn::platform::Platform* platform;
const unsigned char* categoryEnabled;
const char* name;
};
Data* m_pdata;
Data m_data;
// This Data struct workaround is to avoid initializing all the members
// in Data during construction of this object, since this object is always
// constructed, even when tracing is disabled. If the members of Data were
// members of this class instead, compiler warnings occur about potential
// uninitialized accesses.
struct Data {
dawn::platform::Platform* platform;
const unsigned char* categoryEnabled;
const char* name;
};
Data* m_pdata;
Data m_data;
};
} // namespace dawn::platform::TraceEvent

View File

@ -1,6 +1,6 @@
#include "dawn_native/AsyncTask.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn/platform/DawnPlatform.h"
namespace dawn::native {

View File

@ -179,7 +179,7 @@ source_set("dawn_native_sources") {
# dawn_native target
public_deps = [
":dawn_abseil",
"${dawn_root}/src/dawn_platform",
"${dawn_root}/src/dawn/platform",
]
sources = get_target_outputs(":dawn_native_utils_gen")

View File

@ -16,6 +16,8 @@
#include "dawn/common/BitSetIterator.h"
#include "dawn/common/Math.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/BindGroup.h"
#include "dawn_native/Buffer.h"
#include "dawn_native/ChainUtils_autogen.h"
@ -33,8 +35,6 @@
#include "dawn_native/RenderPassEncoder.h"
#include "dawn_native/RenderPipeline.h"
#include "dawn_native/ValidationUtils_autogen.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include <cmath>
#include <map>

View File

@ -14,13 +14,13 @@
#include "dawn_native/CreatePipelineAsyncTask.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/AsyncTask.h"
#include "dawn_native/ComputePipeline.h"
#include "dawn_native/Device.h"
#include "dawn_native/RenderPipeline.h"
#include "dawn_native/utils/WGPUHelpers.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
namespace dawn::native {

View File

@ -15,12 +15,12 @@
#include "dawn_native/DawnNative.h"
#include "dawn/common/Log.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn_native/BindGroupLayout.h"
#include "dawn_native/Buffer.h"
#include "dawn_native/Device.h"
#include "dawn_native/Instance.h"
#include "dawn_native/Texture.h"
#include "dawn_platform/DawnPlatform.h"
// Contains the entry-points into dawn_native

View File

@ -15,6 +15,8 @@
#include "dawn_native/Device.h"
#include "dawn/common/Log.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/Adapter.h"
#include "dawn_native/AsyncTask.h"
#include "dawn_native/AttachmentState.h"
@ -45,8 +47,6 @@
#include "dawn_native/Texture.h"
#include "dawn_native/ValidationUtils_autogen.h"
#include "dawn_native/utils/WGPUHelpers.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include <array>
#include <mutex>

View File

@ -18,11 +18,11 @@
#include "dawn/common/GPUInfo.h"
#include "dawn/common/Log.h"
#include "dawn/common/SystemUtils.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn_native/ChainUtils_autogen.h"
#include "dawn_native/ErrorData.h"
#include "dawn_native/Surface.h"
#include "dawn_native/ValidationUtils_autogen.h"
#include "dawn_platform/DawnPlatform.h"
// For SwiftShader fallback
#if defined(DAWN_ENABLE_BACKEND_VULKAN)

View File

@ -15,8 +15,8 @@
#include "dawn_native/PersistentCache.h"
#include "dawn/common/Assert.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn_native/Device.h"
#include "dawn_platform/DawnPlatform.h"
namespace dawn::native {

View File

@ -15,6 +15,8 @@
#include "dawn_native/Queue.h"
#include "dawn/common/Constants.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/Buffer.h"
#include "dawn_native/CommandBuffer.h"
#include "dawn_native/CommandEncoder.h"
@ -29,8 +31,6 @@
#include "dawn_native/RenderPassEncoder.h"
#include "dawn_native/RenderPipeline.h"
#include "dawn_native/Texture.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include <cstring>

View File

@ -14,6 +14,8 @@
#include "dawn_native/RenderBundleEncoder.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/CommandValidation.h"
#include "dawn_native/Commands.h"
#include "dawn_native/Device.h"
@ -21,8 +23,6 @@
#include "dawn_native/ObjectType_autogen.h"
#include "dawn_native/RenderPipeline.h"
#include "dawn_native/ValidationUtils_autogen.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
namespace dawn::native {

View File

@ -13,13 +13,13 @@
// limitations under the License.
#include "dawn_native/d3d12/CommandRecordingContext.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/d3d12/CommandAllocatorManager.h"
#include "dawn_native/d3d12/D3D12Error.h"
#include "dawn_native/d3d12/DeviceD3D12.h"
#include "dawn_native/d3d12/HeapD3D12.h"
#include "dawn_native/d3d12/ResidencyManagerD3D12.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include <profileapi.h>
#include <sysinfoapi.h>

View File

@ -15,14 +15,14 @@
#include "dawn_native/d3d12/QueueD3D12.h"
#include "dawn/common/Math.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/CommandValidation.h"
#include "dawn_native/Commands.h"
#include "dawn_native/DynamicUploader.h"
#include "dawn_native/d3d12/CommandBufferD3D12.h"
#include "dawn_native/d3d12/D3D12Error.h"
#include "dawn_native/d3d12/DeviceD3D12.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
namespace dawn::native::d3d12 {

View File

@ -18,6 +18,8 @@
#include "dawn/common/BitSetIterator.h"
#include "dawn/common/Log.h"
#include "dawn/common/WindowsUtils.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/Pipeline.h"
#include "dawn_native/TintUtils.h"
#include "dawn_native/d3d12/BindGroupLayoutD3D12.h"
@ -26,8 +28,6 @@
#include "dawn_native/d3d12/PipelineLayoutD3D12.h"
#include "dawn_native/d3d12/PlatformFunctions.h"
#include "dawn_native/d3d12/UtilsD3D12.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include <d3dcompiler.h>

View File

@ -16,6 +16,8 @@
#include "dawn/common/GPUInfo.h"
#include "dawn/common/Platform.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/BackendConnection.h"
#include "dawn_native/BindGroupLayout.h"
#include "dawn_native/Commands.h"
@ -35,8 +37,6 @@
#include "dawn_native/metal/SwapChainMTL.h"
#include "dawn_native/metal/TextureMTL.h"
#include "dawn_native/metal/UtilsMetal.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include <type_traits>

View File

@ -15,14 +15,14 @@
#include "dawn_native/metal/QueueMTL.h"
#include "dawn/common/Math.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/Buffer.h"
#include "dawn_native/CommandValidation.h"
#include "dawn_native/Commands.h"
#include "dawn_native/DynamicUploader.h"
#include "dawn_native/metal/CommandBufferMTL.h"
#include "dawn_native/metal/DeviceMTL.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
namespace dawn::native::metal {

View File

@ -14,13 +14,13 @@
#include "dawn_native/metal/ShaderModuleMTL.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/BindGroupLayout.h"
#include "dawn_native/TintUtils.h"
#include "dawn_native/metal/DeviceMTL.h"
#include "dawn_native/metal/PipelineLayoutMTL.h"
#include "dawn_native/metal/RenderPipelineMTL.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include <tint/tint.h>

View File

@ -14,12 +14,12 @@
#include "dawn_native/opengl/QueueGL.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/opengl/BufferGL.h"
#include "dawn_native/opengl/CommandBufferGL.h"
#include "dawn_native/opengl/DeviceGL.h"
#include "dawn_native/opengl/TextureGL.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
namespace dawn::native::opengl {

View File

@ -16,14 +16,14 @@
#include "dawn/common/Assert.h"
#include "dawn/common/Platform.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/BindGroupLayout.h"
#include "dawn_native/SpirvValidation.h"
#include "dawn_native/TintUtils.h"
#include "dawn_native/opengl/DeviceGL.h"
#include "dawn_native/opengl/PipelineLayoutGL.h"
#include "dawn_native/opengl/SpirvUtils.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include <spirv_glsl.hpp>

View File

@ -14,11 +14,11 @@
#include "dawn_native/vulkan/QuerySetVk.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn_native/vulkan/DeviceVk.h"
#include "dawn_native/vulkan/FencedDeleter.h"
#include "dawn_native/vulkan/UtilsVulkan.h"
#include "dawn_native/vulkan/VulkanError.h"
#include "dawn_platform/DawnPlatform.h"
namespace dawn::native::vulkan {

View File

@ -15,6 +15,8 @@
#include "dawn_native/vulkan/QueueVk.h"
#include "dawn/common/Math.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/Buffer.h"
#include "dawn_native/CommandValidation.h"
#include "dawn_native/Commands.h"
@ -22,8 +24,6 @@
#include "dawn_native/vulkan/CommandBufferVk.h"
#include "dawn_native/vulkan/CommandRecordingContext.h"
#include "dawn_native/vulkan/DeviceVk.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
namespace dawn::native::vulkan {

View File

@ -14,6 +14,8 @@
#include "dawn_native/vulkan/ShaderModuleVk.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn_native/SpirvValidation.h"
#include "dawn_native/TintUtils.h"
#include "dawn_native/vulkan/BindGroupLayoutVk.h"
@ -22,8 +24,6 @@
#include "dawn_native/vulkan/PipelineLayoutVk.h"
#include "dawn_native/vulkan/UtilsVulkan.h"
#include "dawn_native/vulkan/VulkanError.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include <tint/tint.h>
#include <spirv-tools/libspirv.hpp>

View File

@ -1,4 +1,4 @@
# Copyright 2020 The Dawn Authors
# 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.
@ -12,30 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("../../scripts/dawn_overrides_with_defaults.gni")
import("${dawn_root}/scripts/dawn_component.gni")
dawn_component("dawn_platform") {
DEFINE_PREFIX = "DAWN_PLATFORM"
configs = [ "${dawn_root}/src/dawn/common:internal_config" ]
sources = [
"${dawn_root}/src/include/dawn_platform/DawnPlatform.h",
"${dawn_root}/src/include/dawn_platform/dawn_platform_export.h",
"DawnPlatform.cpp",
"WorkerThread.cpp",
"WorkerThread.h",
"tracing/EventTracer.cpp",
"tracing/EventTracer.h",
"tracing/TraceEvent.h",
]
deps = [ "${dawn_root}/src/dawn/common" ]
public_deps = [
# DawnPlatform.h has #include <dawn/webgpu.h>
"${dawn_root}/src/dawn:dawn_headers",
]
################################################################################
# Build target aliases
# TODO(crbug.com/dawn/1275) - remove these
################################################################################
group("dawn_platform") {
public_deps = [ "../dawn/platform" ]
}

View File

@ -0,0 +1,119 @@
// Copyright 2019 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.
#ifndef DAWNPLATFORM_DAWNPLATFORM_H_
#define DAWNPLATFORM_DAWNPLATFORM_H_
#include "dawn/platform/dawn_platform_export.h"
#include <cstddef>
#include <cstdint>
#include <memory>
#include <dawn/webgpu.h>
namespace dawn::platform {
enum class TraceCategory {
General, // General trace events
Validation, // Dawn validation
Recording, // Native command recording
GPUWork, // Actual GPU work
};
class DAWN_PLATFORM_EXPORT CachingInterface {
public:
CachingInterface();
virtual ~CachingInterface();
// LoadData has two modes. The first mode is used to get a value which
// corresponds to the |key|. The |valueOut| is a caller provided buffer
// allocated to the size |valueSize| which is loaded with data of the
// size returned. The second mode is used to query for the existence of
// the |key| where |valueOut| is nullptr and |valueSize| must be 0.
// The return size is non-zero if the |key| exists.
virtual size_t LoadData(const WGPUDevice device,
const void* key,
size_t keySize,
void* valueOut,
size_t valueSize) = 0;
// StoreData puts a |value| in the cache which corresponds to the |key|.
virtual void StoreData(const WGPUDevice device,
const void* key,
size_t keySize,
const void* value,
size_t valueSize) = 0;
private:
CachingInterface(const CachingInterface&) = delete;
CachingInterface& operator=(const CachingInterface&) = delete;
};
class DAWN_PLATFORM_EXPORT WaitableEvent {
public:
WaitableEvent() = default;
virtual ~WaitableEvent() = default;
virtual void Wait() = 0; // Wait for completion
virtual bool IsComplete() = 0; // Non-blocking check if the event is complete
};
using PostWorkerTaskCallback = void (*)(void* userdata);
class DAWN_PLATFORM_EXPORT WorkerTaskPool {
public:
WorkerTaskPool() = default;
virtual ~WorkerTaskPool() = default;
virtual std::unique_ptr<WaitableEvent> PostWorkerTask(PostWorkerTaskCallback,
void* userdata) = 0;
};
class DAWN_PLATFORM_EXPORT Platform {
public:
Platform();
virtual ~Platform();
virtual const unsigned char* GetTraceCategoryEnabledFlag(TraceCategory category);
virtual double MonotonicallyIncreasingTime();
virtual uint64_t AddTraceEvent(char phase,
const unsigned char* categoryGroupEnabled,
const char* name,
uint64_t id,
double timestamp,
int numArgs,
const char** argNames,
const unsigned char* argTypes,
const uint64_t* argValues,
unsigned char flags);
// The |fingerprint| is provided by Dawn to inform the client to discard the Dawn caches
// when the fingerprint changes. The returned CachingInterface is expected to outlive the
// device which uses it to persistently cache objects.
virtual CachingInterface* GetCachingInterface(const void* fingerprint,
size_t fingerprintSize);
virtual std::unique_ptr<WorkerTaskPool> CreateWorkerTaskPool();
private:
Platform(const Platform&) = delete;
Platform& operator=(const Platform&) = delete;
};
} // namespace dawn::platform
// TODO(dawn:824): Remove once the deprecation period is passed.
namespace dawn_platform = dawn::platform;
#endif // DAWNPLATFORM_DAWNPLATFORM_H_

View File

@ -1,119 +1 @@
// Copyright 2019 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.
#ifndef DAWNPLATFORM_DAWNPLATFORM_H_
#define DAWNPLATFORM_DAWNPLATFORM_H_
#include "dawn_platform/dawn_platform_export.h"
#include <cstddef>
#include <cstdint>
#include <memory>
#include <dawn/webgpu.h>
namespace dawn::platform {
enum class TraceCategory {
General, // General trace events
Validation, // Dawn validation
Recording, // Native command recording
GPUWork, // Actual GPU work
};
class DAWN_PLATFORM_EXPORT CachingInterface {
public:
CachingInterface();
virtual ~CachingInterface();
// LoadData has two modes. The first mode is used to get a value which
// corresponds to the |key|. The |valueOut| is a caller provided buffer
// allocated to the size |valueSize| which is loaded with data of the
// size returned. The second mode is used to query for the existence of
// the |key| where |valueOut| is nullptr and |valueSize| must be 0.
// The return size is non-zero if the |key| exists.
virtual size_t LoadData(const WGPUDevice device,
const void* key,
size_t keySize,
void* valueOut,
size_t valueSize) = 0;
// StoreData puts a |value| in the cache which corresponds to the |key|.
virtual void StoreData(const WGPUDevice device,
const void* key,
size_t keySize,
const void* value,
size_t valueSize) = 0;
private:
CachingInterface(const CachingInterface&) = delete;
CachingInterface& operator=(const CachingInterface&) = delete;
};
class DAWN_PLATFORM_EXPORT WaitableEvent {
public:
WaitableEvent() = default;
virtual ~WaitableEvent() = default;
virtual void Wait() = 0; // Wait for completion
virtual bool IsComplete() = 0; // Non-blocking check if the event is complete
};
using PostWorkerTaskCallback = void (*)(void* userdata);
class DAWN_PLATFORM_EXPORT WorkerTaskPool {
public:
WorkerTaskPool() = default;
virtual ~WorkerTaskPool() = default;
virtual std::unique_ptr<WaitableEvent> PostWorkerTask(PostWorkerTaskCallback,
void* userdata) = 0;
};
class DAWN_PLATFORM_EXPORT Platform {
public:
Platform();
virtual ~Platform();
virtual const unsigned char* GetTraceCategoryEnabledFlag(TraceCategory category);
virtual double MonotonicallyIncreasingTime();
virtual uint64_t AddTraceEvent(char phase,
const unsigned char* categoryGroupEnabled,
const char* name,
uint64_t id,
double timestamp,
int numArgs,
const char** argNames,
const unsigned char* argTypes,
const uint64_t* argValues,
unsigned char flags);
// The |fingerprint| is provided by Dawn to inform the client to discard the Dawn caches
// when the fingerprint changes. The returned CachingInterface is expected to outlive the
// device which uses it to persistently cache objects.
virtual CachingInterface* GetCachingInterface(const void* fingerprint,
size_t fingerprintSize);
virtual std::unique_ptr<WorkerTaskPool> CreateWorkerTaskPool();
private:
Platform(const Platform&) = delete;
Platform& operator=(const Platform&) = delete;
};
} // namespace dawn::platform
// TODO(dawn:824): Remove once the deprecation period is passed.
namespace dawn_platform = dawn::platform;
#endif // DAWNPLATFORM_DAWNPLATFORM_H_
#include <dawn/platform/DawnPlatform.h>

View File

@ -20,8 +20,8 @@
#include "dawn/common/Assert.h"
#include "dawn/common/Log.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn/utils/Timer.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include "tests/perf_tests/DawnPerfTestPlatform.h"
namespace {

View File

@ -18,8 +18,8 @@
#include "dawn/common/Assert.h"
#include "dawn/common/HashUtils.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "dawn/utils/Timer.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include "tests/perf_tests/DawnPerfTest.h"
namespace {

View File

@ -21,8 +21,8 @@
#include <mutex>
#include "dawn/common/NonCopyable.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn_native/AsyncTask.h"
#include "dawn_platform/DawnPlatform.h"
namespace {

View File

@ -15,9 +15,9 @@
#include <gtest/gtest.h>
#include "dawn/common/ConcurrentCache.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/utils/SystemUtils.h"
#include "dawn_native/AsyncTask.h"
#include "dawn_platform/DawnPlatform.h"
namespace {
class SimpleCachedObject {