Capitalize C types dawn -> Dawn
This is to match Chromium style. Change-Id: Ic97cc03e2291c653ade9662ba3d5e629872b10ad Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5482 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
97ffc1a8aa
commit
45f9730855
|
@ -17,24 +17,24 @@
|
|||
#include "utils/DawnHelpers.h"
|
||||
#include "utils/SystemUtils.h"
|
||||
|
||||
dawnDevice device;
|
||||
dawnQueue queue;
|
||||
dawnSwapChain swapchain;
|
||||
dawnRenderPipeline pipeline;
|
||||
DawnDevice device;
|
||||
DawnQueue queue;
|
||||
DawnSwapChain swapchain;
|
||||
DawnRenderPipeline pipeline;
|
||||
|
||||
dawnTextureFormat swapChainFormat;
|
||||
DawnTextureFormat swapChainFormat;
|
||||
|
||||
void init() {
|
||||
device = CreateCppDawnDevice().Release();
|
||||
queue = dawnDeviceCreateQueue(device);
|
||||
|
||||
{
|
||||
dawnSwapChainDescriptor descriptor;
|
||||
DawnSwapChainDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.implementation = GetSwapChainImplementation();
|
||||
swapchain = dawnDeviceCreateSwapChain(device, &descriptor);
|
||||
}
|
||||
swapChainFormat = static_cast<dawnTextureFormat>(GetPreferredSwapChainTextureFormat());
|
||||
swapChainFormat = static_cast<DawnTextureFormat>(GetPreferredSwapChainTextureFormat());
|
||||
dawnSwapChainConfigure(swapchain, swapChainFormat, DAWN_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT, 640,
|
||||
480);
|
||||
|
||||
|
@ -44,7 +44,7 @@ void init() {
|
|||
"void main() {\n"
|
||||
" gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n"
|
||||
"}\n";
|
||||
dawnShaderModule vsModule = utils::CreateShaderModule(dawn::Device(device), dawn::ShaderStage::Vertex, vs).Release();
|
||||
DawnShaderModule vsModule = utils::CreateShaderModule(dawn::Device(device), dawn::ShaderStage::Vertex, vs).Release();
|
||||
|
||||
const char* fs =
|
||||
"#version 450\n"
|
||||
|
@ -52,19 +52,19 @@ void init() {
|
|||
"void main() {\n"
|
||||
" fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
|
||||
"}\n";
|
||||
dawnShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fs).Release();
|
||||
DawnShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fs).Release();
|
||||
|
||||
{
|
||||
dawnRenderPipelineDescriptor descriptor;
|
||||
DawnRenderPipelineDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
|
||||
dawnPipelineStageDescriptor vertexStage;
|
||||
DawnPipelineStageDescriptor vertexStage;
|
||||
vertexStage.nextInChain = nullptr;
|
||||
vertexStage.module = vsModule;
|
||||
vertexStage.entryPoint = "main";
|
||||
descriptor.vertexStage = &vertexStage;
|
||||
|
||||
dawnPipelineStageDescriptor fragmentStage;
|
||||
DawnPipelineStageDescriptor fragmentStage;
|
||||
fragmentStage.nextInChain = nullptr;
|
||||
fragmentStage.module = fsModule;
|
||||
fragmentStage.entryPoint = "main";
|
||||
|
@ -72,11 +72,11 @@ void init() {
|
|||
|
||||
descriptor.sampleCount = 1;
|
||||
|
||||
dawnBlendDescriptor blendDescriptor;
|
||||
DawnBlendDescriptor blendDescriptor;
|
||||
blendDescriptor.operation = DAWN_BLEND_OPERATION_ADD;
|
||||
blendDescriptor.srcFactor = DAWN_BLEND_FACTOR_ONE;
|
||||
blendDescriptor.dstFactor = DAWN_BLEND_FACTOR_ONE;
|
||||
dawnColorStateDescriptor colorStateDescriptor;
|
||||
DawnColorStateDescriptor colorStateDescriptor;
|
||||
colorStateDescriptor.nextInChain = nullptr;
|
||||
colorStateDescriptor.format = swapChainFormat;
|
||||
colorStateDescriptor.alphaBlend = blendDescriptor;
|
||||
|
@ -84,16 +84,16 @@ void init() {
|
|||
colorStateDescriptor.colorWriteMask = DAWN_COLOR_WRITE_MASK_ALL;
|
||||
|
||||
descriptor.colorStateCount = 1;
|
||||
dawnColorStateDescriptor* colorStatesPtr[] = {&colorStateDescriptor};
|
||||
DawnColorStateDescriptor* colorStatesPtr[] = {&colorStateDescriptor};
|
||||
descriptor.colorStates = colorStatesPtr;
|
||||
|
||||
dawnPipelineLayoutDescriptor pl;
|
||||
DawnPipelineLayoutDescriptor pl;
|
||||
pl.nextInChain = nullptr;
|
||||
pl.bindGroupLayoutCount = 0;
|
||||
pl.bindGroupLayouts = nullptr;
|
||||
descriptor.layout = dawnDeviceCreatePipelineLayout(device, &pl);
|
||||
|
||||
dawnInputStateBuilder inputStateBuilder = dawnDeviceCreateInputStateBuilder(device);
|
||||
DawnInputStateBuilder inputStateBuilder = dawnDeviceCreateInputStateBuilder(device);
|
||||
descriptor.inputState = dawnInputStateBuilderGetResult(inputStateBuilder);
|
||||
dawnInputStateBuilderRelease(inputStateBuilder);
|
||||
|
||||
|
@ -112,14 +112,14 @@ void init() {
|
|||
}
|
||||
|
||||
void frame() {
|
||||
dawnTexture backbuffer = dawnSwapChainGetNextTexture(swapchain);
|
||||
dawnTextureView backbufferView;
|
||||
DawnTexture backbuffer = dawnSwapChainGetNextTexture(swapchain);
|
||||
DawnTextureView backbufferView;
|
||||
{
|
||||
backbufferView = dawnTextureCreateDefaultTextureView(backbuffer);
|
||||
}
|
||||
dawnRenderPassDescriptor renderpassInfo;
|
||||
dawnRenderPassColorAttachmentDescriptor colorAttachment;
|
||||
dawnRenderPassColorAttachmentDescriptor* colorAttachments = {&colorAttachment};
|
||||
DawnRenderPassDescriptor renderpassInfo;
|
||||
DawnRenderPassColorAttachmentDescriptor colorAttachment;
|
||||
DawnRenderPassColorAttachmentDescriptor* colorAttachments = {&colorAttachment};
|
||||
{
|
||||
colorAttachment.attachment = backbufferView;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
|
@ -130,11 +130,11 @@ void frame() {
|
|||
renderpassInfo.colorAttachments = &colorAttachments;
|
||||
renderpassInfo.depthStencilAttachment = nullptr;
|
||||
}
|
||||
dawnCommandBuffer commands;
|
||||
DawnCommandBuffer commands;
|
||||
{
|
||||
dawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
|
||||
dawnRenderPassEncoder pass = dawnCommandEncoderBeginRenderPass(encoder, &renderpassInfo);
|
||||
DawnRenderPassEncoder pass = dawnCommandEncoderBeginRenderPass(encoder, &renderpassInfo);
|
||||
dawnRenderPassEncoderSetPipeline(pass, pipeline);
|
||||
dawnRenderPassEncoderDraw(pass, 3, 1, 0, 0);
|
||||
dawnRenderPassEncoderEndPass(pass);
|
||||
|
|
|
@ -98,8 +98,8 @@ dawn::Device CreateCppDawnDevice() {
|
|||
backendAdapter = *adapterIt;
|
||||
}
|
||||
|
||||
dawnDevice backendDevice = backendAdapter.CreateDevice();
|
||||
dawnProcTable backendProcs = dawn_native::GetProcs();
|
||||
DawnDevice backendDevice = backendAdapter.CreateDevice();
|
||||
DawnProcTable backendProcs = dawn_native::GetProcs();
|
||||
|
||||
binding = utils::CreateBinding(backendType, window, backendDevice);
|
||||
if (binding == nullptr) {
|
||||
|
@ -107,8 +107,8 @@ dawn::Device CreateCppDawnDevice() {
|
|||
}
|
||||
|
||||
// Choose whether to use the backend procs and devices directly, or set up the wire.
|
||||
dawnDevice cDevice = nullptr;
|
||||
dawnProcTable procs;
|
||||
DawnDevice cDevice = nullptr;
|
||||
DawnProcTable procs;
|
||||
|
||||
switch (cmdBufType) {
|
||||
case CmdBufType::None:
|
||||
|
@ -125,8 +125,8 @@ dawn::Device CreateCppDawnDevice() {
|
|||
c2sBuf->SetHandler(wireServer);
|
||||
|
||||
wireClient = new dawn_wire::WireClient(c2sBuf);
|
||||
dawnDevice clientDevice = wireClient->GetDevice();
|
||||
dawnProcTable clientProcs = wireClient->GetProcs();
|
||||
DawnDevice clientDevice = wireClient->GetDevice();
|
||||
DawnProcTable clientProcs = wireClient->GetProcs();
|
||||
s2cBuf->SetHandler(wireClient);
|
||||
|
||||
procs = clientProcs;
|
||||
|
|
|
@ -230,7 +230,7 @@ def as_cType(name):
|
|||
if name.native:
|
||||
return name.concatcase()
|
||||
else:
|
||||
return 'dawn' + name.CamelCase()
|
||||
return 'Dawn' + name.CamelCase()
|
||||
|
||||
def as_cppType(name):
|
||||
if name.native:
|
||||
|
@ -272,7 +272,7 @@ def as_MethodSuffix(type_name, method_name):
|
|||
|
||||
def as_cProc(type_name, method_name):
|
||||
assert(not type_name.native and not method_name.native)
|
||||
return 'dawn' + 'Proc' + type_name.CamelCase() + method_name.CamelCase()
|
||||
return 'Dawn' + 'Proc' + type_name.CamelCase() + method_name.CamelCase()
|
||||
|
||||
def as_frontendType(typ):
|
||||
if typ.category == 'object':
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
#include "dawn/dawn.h"
|
||||
|
||||
static dawnProcTable procs;
|
||||
static DawnProcTable procs;
|
||||
|
||||
static dawnProcTable nullProcs;
|
||||
static DawnProcTable nullProcs;
|
||||
|
||||
void dawnSetProcs(const dawnProcTable* procs_) {
|
||||
void dawnSetProcs(const DawnProcTable* procs_) {
|
||||
if (procs_) {
|
||||
procs = *procs_;
|
||||
} else {
|
||||
|
|
|
@ -48,13 +48,13 @@
|
|||
{% endfor %}
|
||||
|
||||
// Custom types depending on the target language
|
||||
typedef uint64_t dawnCallbackUserdata;
|
||||
typedef void (*dawnDeviceErrorCallback)(const char* message, dawnCallbackUserdata userdata);
|
||||
typedef void (*dawnBuilderErrorCallback)(dawnBuilderErrorStatus status, const char* message, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2);
|
||||
typedef void (*dawnBufferMapReadCallback)(dawnBufferMapAsyncStatus status, const void* data, uint32_t dataLength, dawnCallbackUserdata userdata);
|
||||
typedef void (*dawnBufferMapWriteCallback)(dawnBufferMapAsyncStatus status, void* data, uint32_t dataLength, dawnCallbackUserdata userdata);
|
||||
typedef void (*dawnFenceOnCompletionCallback)(dawnFenceCompletionStatus status,
|
||||
dawnCallbackUserdata userdata);
|
||||
typedef uint64_t DawnCallbackUserdata;
|
||||
typedef void (*DawnDeviceErrorCallback)(const char* message, DawnCallbackUserdata userdata);
|
||||
typedef void (*DawnBuilderErrorCallback)(DawnBuilderErrorStatus status, const char* message, DawnCallbackUserdata userdata1, DawnCallbackUserdata userdata2);
|
||||
typedef void (*DawnBufferMapReadCallback)(DawnBufferMapAsyncStatus status, const void* data, uint32_t dataLength, DawnCallbackUserdata userdata);
|
||||
typedef void (*DawnBufferMapWriteCallback)(DawnBufferMapAsyncStatus status, void* data, uint32_t dataLength, DawnCallbackUserdata userdata);
|
||||
typedef void (*DawnFenceOnCompletionCallback)(DawnFenceCompletionStatus status,
|
||||
DawnCallbackUserdata userdata);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -73,7 +73,7 @@ extern "C" {
|
|||
|
||||
{% endfor %}
|
||||
|
||||
struct dawnProcTable_s {
|
||||
struct DawnProcTable_s {
|
||||
{% for type in by_category["object"] %}
|
||||
{% for method in native_methods(type) %}
|
||||
{{as_cProc(type.name, method.name)}} {{as_varName(type.name, method.name)}};
|
||||
|
@ -81,12 +81,12 @@ struct dawnProcTable_s {
|
|||
|
||||
{% endfor %}
|
||||
};
|
||||
typedef struct dawnProcTable_s dawnProcTable;
|
||||
typedef struct DawnProcTable_s DawnProcTable;
|
||||
|
||||
// Stuff below is for convenience and will forward calls to a static dawnProcTable.
|
||||
// Stuff below is for convenience and will forward calls to a static DawnProcTable.
|
||||
|
||||
// Set which dawnProcTable will be used
|
||||
DAWN_EXPORT void dawnSetProcs(const dawnProcTable* procs);
|
||||
// Set which DawnProcTable will be used
|
||||
DAWN_EXPORT void dawnSetProcs(const DawnProcTable* procs);
|
||||
|
||||
{% for type in by_category["object"] %}
|
||||
// Methods of {{type.name.CamelCase()}}
|
||||
|
|
|
@ -170,8 +170,8 @@ namespace dawn_native {
|
|||
{% endfor %}
|
||||
}
|
||||
|
||||
dawnProcTable GetProcsAutogen() {
|
||||
dawnProcTable table;
|
||||
DawnProcTable GetProcsAutogen() {
|
||||
DawnProcTable table;
|
||||
{% for type in by_category["object"] %}
|
||||
{% for method in native_methods(type) %}
|
||||
table.{{as_varName(type.name, method.name)}} = Validating{{as_MethodSuffix(type.name, method.name)}};
|
||||
|
|
|
@ -72,9 +72,9 @@ namespace dawn_wire { namespace client {
|
|||
|
||||
{% if type.is_builder %}
|
||||
void Client{{as_MethodSuffix(type.name, Name("set error callback"))}}({{cType}} cSelf,
|
||||
dawnBuilderErrorCallback callback,
|
||||
dawnCallbackUserdata userdata1,
|
||||
dawnCallbackUserdata userdata2) {
|
||||
DawnBuilderErrorCallback callback,
|
||||
DawnCallbackUserdata userdata1,
|
||||
DawnCallbackUserdata userdata2) {
|
||||
{{Type}}* self = reinterpret_cast<{{Type}}*>(cSelf);
|
||||
self->builderCallback.callback = callback;
|
||||
self->builderCallback.userdata1 = userdata1;
|
||||
|
@ -117,8 +117,8 @@ namespace dawn_wire { namespace client {
|
|||
//* - An autogenerated Client{{suffix}} method that sends the command on the wire
|
||||
//* - A manual ProxyClient{{suffix}} method that will be inserted in the proctable instead of
|
||||
//* the autogenerated one, and that will have to call Client{{suffix}}
|
||||
dawnProcTable GetProcs() {
|
||||
dawnProcTable table;
|
||||
DawnProcTable GetProcs() {
|
||||
DawnProcTable table;
|
||||
{% for type in by_category["object"] %}
|
||||
{% for method in native_methods(type) %}
|
||||
{% set suffix = as_MethodSuffix(type.name, method.name) %}
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace dawn_wire {
|
|||
if (object == nullptr) {
|
||||
return true;
|
||||
}
|
||||
bool called = object->builderCallback.Call(static_cast<dawnBuilderErrorStatus>(status), message);
|
||||
bool called = object->builderCallback.Call(static_cast<DawnBuilderErrorStatus>(status), message);
|
||||
|
||||
//* Unhandled builder errors are forwarded to the device
|
||||
if (!called && status != DAWN_BUILDER_ERROR_STATUS_SUCCESS && status != DAWN_BUILDER_ERROR_STATUS_UNKNOWN) {
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_wire { namespace server {
|
|||
virtual ~ServerBase() = default;
|
||||
|
||||
protected:
|
||||
void DestroyAllObjects(const dawnProcTable& procs) {
|
||||
void DestroyAllObjects(const DawnProcTable& procs) {
|
||||
//* Free all objects when the server is destroyed
|
||||
{% for type in by_category["object"] if type.name.canonical_case() != "device" %}
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
namespace dawn_wire { namespace server {
|
||||
{% for type in by_category["object"] if type.is_builder%}
|
||||
void Server::Forward{{type.name.CamelCase()}}(dawnBuilderErrorStatus status, const char* message, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2) {
|
||||
void Server::Forward{{type.name.CamelCase()}}(DawnBuilderErrorStatus status, const char* message, DawnCallbackUserdata userdata1, DawnCallbackUserdata userdata2) {
|
||||
auto server = reinterpret_cast<Server*>(static_cast<uintptr_t>(userdata1));
|
||||
uint32_t id = userdata2 & 0xFFFFFFFFu;
|
||||
uint32_t serial = userdata2 >> uint64_t(32);
|
||||
|
@ -27,7 +27,7 @@ namespace dawn_wire { namespace server {
|
|||
|
||||
{% for type in by_category["object"] if type.is_builder%}
|
||||
{% set Type = type.name.CamelCase() %}
|
||||
void Server::On{{Type}}Error(dawnBuilderErrorStatus status, const char* message, uint32_t id, uint32_t serial) {
|
||||
void Server::On{{Type}}Error(DawnBuilderErrorStatus status, const char* message, uint32_t id, uint32_t serial) {
|
||||
auto* builder = {{Type}}Objects().Get(id);
|
||||
|
||||
if (builder == nullptr || builder->serial != serial) {
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
|
||||
// Forwarding callbacks
|
||||
{% for type in by_category["object"] if type.is_builder%}
|
||||
static void Forward{{type.name.CamelCase()}}(dawnBuilderErrorStatus status, const char* message, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2);
|
||||
static void Forward{{type.name.CamelCase()}}(DawnBuilderErrorStatus status, const char* message, DawnCallbackUserdata userdata1, DawnCallbackUserdata userdata2);
|
||||
{% endfor %}
|
||||
|
||||
// Error callbacks
|
||||
{% for type in by_category["object"] if type.is_builder%}
|
||||
{% set Type = type.name.CamelCase() %}
|
||||
void On{{Type}}Error(dawnBuilderErrorStatus status, const char* message, uint32_t id, uint32_t serial);
|
||||
void On{{Type}}Error(DawnBuilderErrorStatus status, const char* message, uint32_t id, uint32_t serial);
|
||||
{% endfor %}
|
||||
|
||||
// Command handlers & doers
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace {
|
|||
ProcTableAsClass::~ProcTableAsClass() {
|
||||
}
|
||||
|
||||
void ProcTableAsClass::GetProcTableAndDevice(dawnProcTable* table, dawnDevice* device) {
|
||||
void ProcTableAsClass::GetProcTableAndDevice(DawnProcTable* table, DawnDevice* device) {
|
||||
*device = GetNewDevice();
|
||||
|
||||
{% for type in by_category["object"] %}
|
||||
|
@ -48,7 +48,7 @@ void ProcTableAsClass::GetProcTableAndDevice(dawnProcTable* table, dawnDevice* d
|
|||
{% endfor %}
|
||||
}
|
||||
|
||||
void ProcTableAsClass::DeviceSetErrorCallback(dawnDevice self, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata) {
|
||||
void ProcTableAsClass::DeviceSetErrorCallback(DawnDevice self, DawnDeviceErrorCallback callback, DawnCallbackUserdata userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->deviceErrorCallback = callback;
|
||||
object->userdata1 = userdata;
|
||||
|
@ -56,7 +56,7 @@ void ProcTableAsClass::DeviceSetErrorCallback(dawnDevice self, dawnDeviceErrorCa
|
|||
OnDeviceSetErrorCallback(self, callback, userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::BufferMapReadAsync(dawnBuffer self, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata) {
|
||||
void ProcTableAsClass::BufferMapReadAsync(DawnBuffer self, DawnBufferMapReadCallback callback, DawnCallbackUserdata userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->mapReadCallback = callback;
|
||||
object->userdata1 = userdata;
|
||||
|
@ -64,7 +64,7 @@ void ProcTableAsClass::BufferMapReadAsync(dawnBuffer self, dawnBufferMapReadCall
|
|||
OnBufferMapReadAsyncCallback(self, callback, userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::BufferMapWriteAsync(dawnBuffer self, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata) {
|
||||
void ProcTableAsClass::BufferMapWriteAsync(DawnBuffer self, DawnBufferMapWriteCallback callback, DawnCallbackUserdata userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->mapWriteCallback = callback;
|
||||
object->userdata1 = userdata;
|
||||
|
@ -72,10 +72,10 @@ void ProcTableAsClass::BufferMapWriteAsync(dawnBuffer self, dawnBufferMapWriteCa
|
|||
OnBufferMapWriteAsyncCallback(self, callback, userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::FenceOnCompletion(dawnFence self,
|
||||
void ProcTableAsClass::FenceOnCompletion(DawnFence self,
|
||||
uint64_t value,
|
||||
dawnFenceOnCompletionCallback callback,
|
||||
dawnCallbackUserdata userdata) {
|
||||
DawnFenceOnCompletionCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->fenceOnCompletionCallback = callback;
|
||||
object->userdata1 = userdata;
|
||||
|
@ -83,38 +83,38 @@ void ProcTableAsClass::FenceOnCompletion(dawnFence self,
|
|||
OnFenceOnCompletionCallback(self, value, callback, userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::CallDeviceErrorCallback(dawnDevice device, const char* message) {
|
||||
void ProcTableAsClass::CallDeviceErrorCallback(DawnDevice device, const char* message) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(device);
|
||||
object->deviceErrorCallback(message, object->userdata1);
|
||||
}
|
||||
void ProcTableAsClass::CallBuilderErrorCallback(void* builder , dawnBuilderErrorStatus status, const char* message) {
|
||||
void ProcTableAsClass::CallBuilderErrorCallback(void* builder , DawnBuilderErrorStatus status, const char* message) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(builder);
|
||||
object->builderErrorCallback(status, message, object->userdata1, object->userdata2);
|
||||
}
|
||||
void ProcTableAsClass::CallMapReadCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, const void* data, uint32_t dataLength) {
|
||||
void ProcTableAsClass::CallMapReadCallback(DawnBuffer buffer, DawnBufferMapAsyncStatus status, const void* data, uint32_t dataLength) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
||||
object->mapReadCallback(status, data, dataLength, object->userdata1);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::CallMapWriteCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, void* data, uint32_t dataLength) {
|
||||
void ProcTableAsClass::CallMapWriteCallback(DawnBuffer buffer, DawnBufferMapAsyncStatus status, void* data, uint32_t dataLength) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
||||
object->mapWriteCallback(status, data, dataLength, object->userdata1);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::CallFenceOnCompletionCallback(dawnFence fence,
|
||||
dawnFenceCompletionStatus status) {
|
||||
void ProcTableAsClass::CallFenceOnCompletionCallback(DawnFence fence,
|
||||
DawnFenceCompletionStatus status) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(fence);
|
||||
object->fenceOnCompletionCallback(status, object->userdata1);
|
||||
}
|
||||
|
||||
{% for type in by_category["object"] if type.is_builder %}
|
||||
void ProcTableAsClass::{{as_MethodSuffix(type.name, Name("set error callback"))}}({{as_cType(type.name)}} self, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2) {
|
||||
void ProcTableAsClass::{{as_MethodSuffix(type.name, Name("set error callback"))}}({{as_cType(type.name)}} self, DawnBuilderErrorCallback callback, DawnCallbackUserdata userdata1, DawnCallbackUserdata userdata2) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->builderErrorCallback = callback;
|
||||
object->userdata1 = userdata1;
|
||||
object->userdata2 = userdata2;
|
||||
|
||||
OnBuilderSetErrorCallback(reinterpret_cast<dawnBufferBuilder>(self), callback, userdata1, userdata2);
|
||||
OnBuilderSetErrorCallback(reinterpret_cast<DawnBufferBuilder>(self), callback, userdata1, userdata2);
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class ProcTableAsClass {
|
|||
public:
|
||||
virtual ~ProcTableAsClass();
|
||||
|
||||
void GetProcTableAndDevice(dawnProcTable* table, dawnDevice* device);
|
||||
void GetProcTableAndDevice(DawnProcTable* table, DawnDevice* device);
|
||||
|
||||
// Creates an object that can be returned by a mocked call as in WillOnce(Return(foo)).
|
||||
// It returns an object of the write type that isn't equal to any previously returned object.
|
||||
|
@ -51,45 +51,45 @@ class ProcTableAsClass {
|
|||
|
||||
// Stores callback and userdata and calls OnBuilderSetErrorCallback
|
||||
{% if type.is_builder %}
|
||||
void {{as_MethodSuffix(type.name, Name("set error callback"))}}({{as_cType(type.name)}} self, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2);
|
||||
void {{as_MethodSuffix(type.name, Name("set error callback"))}}({{as_cType(type.name)}} self, DawnBuilderErrorCallback callback, DawnCallbackUserdata userdata1, DawnCallbackUserdata userdata2);
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
// Stores callback and userdata and calls the On* methods
|
||||
void DeviceSetErrorCallback(dawnDevice self, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata);
|
||||
void BufferMapReadAsync(dawnBuffer self, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata);
|
||||
void BufferMapWriteAsync(dawnBuffer self, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata);
|
||||
void FenceOnCompletion(dawnFence self,
|
||||
void DeviceSetErrorCallback(DawnDevice self, DawnDeviceErrorCallback callback, DawnCallbackUserdata userdata);
|
||||
void BufferMapReadAsync(DawnBuffer self, DawnBufferMapReadCallback callback, DawnCallbackUserdata userdata);
|
||||
void BufferMapWriteAsync(DawnBuffer self, DawnBufferMapWriteCallback callback, DawnCallbackUserdata userdata);
|
||||
void FenceOnCompletion(DawnFence self,
|
||||
uint64_t value,
|
||||
dawnFenceOnCompletionCallback callback,
|
||||
dawnCallbackUserdata userdata);
|
||||
DawnFenceOnCompletionCallback callback,
|
||||
DawnCallbackUserdata userdata);
|
||||
|
||||
// Special cased mockable methods
|
||||
virtual void OnDeviceSetErrorCallback(dawnDevice device, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata) = 0;
|
||||
virtual void OnBuilderSetErrorCallback(dawnBufferBuilder builder, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2) = 0;
|
||||
virtual void OnBufferMapReadAsyncCallback(dawnBuffer buffer, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata) = 0;
|
||||
virtual void OnBufferMapWriteAsyncCallback(dawnBuffer buffer, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata) = 0;
|
||||
virtual void OnFenceOnCompletionCallback(dawnFence fence,
|
||||
virtual void OnDeviceSetErrorCallback(DawnDevice device, DawnDeviceErrorCallback callback, DawnCallbackUserdata userdata) = 0;
|
||||
virtual void OnBuilderSetErrorCallback(DawnBufferBuilder builder, DawnBuilderErrorCallback callback, DawnCallbackUserdata userdata1, DawnCallbackUserdata userdata2) = 0;
|
||||
virtual void OnBufferMapReadAsyncCallback(DawnBuffer buffer, DawnBufferMapReadCallback callback, DawnCallbackUserdata userdata) = 0;
|
||||
virtual void OnBufferMapWriteAsyncCallback(DawnBuffer buffer, DawnBufferMapWriteCallback callback, DawnCallbackUserdata userdata) = 0;
|
||||
virtual void OnFenceOnCompletionCallback(DawnFence fence,
|
||||
uint64_t value,
|
||||
dawnFenceOnCompletionCallback callback,
|
||||
dawnCallbackUserdata userdata) = 0;
|
||||
DawnFenceOnCompletionCallback callback,
|
||||
DawnCallbackUserdata userdata) = 0;
|
||||
|
||||
// Calls the stored callbacks
|
||||
void CallDeviceErrorCallback(dawnDevice device, const char* message);
|
||||
void CallBuilderErrorCallback(void* builder , dawnBuilderErrorStatus status, const char* message);
|
||||
void CallMapReadCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, const void* data, uint32_t dataLength);
|
||||
void CallMapWriteCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, void* data, uint32_t dataLength);
|
||||
void CallFenceOnCompletionCallback(dawnFence fence, dawnFenceCompletionStatus status);
|
||||
void CallDeviceErrorCallback(DawnDevice device, const char* message);
|
||||
void CallBuilderErrorCallback(void* builder , DawnBuilderErrorStatus status, const char* message);
|
||||
void CallMapReadCallback(DawnBuffer buffer, DawnBufferMapAsyncStatus status, const void* data, uint32_t dataLength);
|
||||
void CallMapWriteCallback(DawnBuffer buffer, DawnBufferMapAsyncStatus status, void* data, uint32_t dataLength);
|
||||
void CallFenceOnCompletionCallback(DawnFence fence, DawnFenceCompletionStatus status);
|
||||
|
||||
struct Object {
|
||||
ProcTableAsClass* procs = nullptr;
|
||||
dawnDeviceErrorCallback deviceErrorCallback = nullptr;
|
||||
dawnBuilderErrorCallback builderErrorCallback = nullptr;
|
||||
dawnBufferMapReadCallback mapReadCallback = nullptr;
|
||||
dawnBufferMapWriteCallback mapWriteCallback = nullptr;
|
||||
dawnFenceOnCompletionCallback fenceOnCompletionCallback = nullptr;
|
||||
dawnCallbackUserdata userdata1 = 0;
|
||||
dawnCallbackUserdata userdata2 = 0;
|
||||
DawnDeviceErrorCallback deviceErrorCallback = nullptr;
|
||||
DawnBuilderErrorCallback builderErrorCallback = nullptr;
|
||||
DawnBufferMapReadCallback mapReadCallback = nullptr;
|
||||
DawnBufferMapWriteCallback mapWriteCallback = nullptr;
|
||||
DawnFenceOnCompletionCallback fenceOnCompletionCallback = nullptr;
|
||||
DawnCallbackUserdata userdata1 = 0;
|
||||
DawnCallbackUserdata userdata2 = 0;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -117,15 +117,15 @@ class MockProcTable : public ProcTableAsClass {
|
|||
MOCK_METHOD1({{as_MethodSuffix(type.name, Name("release"))}}, void({{as_cType(type.name)}} self));
|
||||
{% endfor %}
|
||||
|
||||
MOCK_METHOD3(OnDeviceSetErrorCallback, void(dawnDevice device, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata));
|
||||
MOCK_METHOD4(OnBuilderSetErrorCallback, void(dawnBufferBuilder builder, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2));
|
||||
MOCK_METHOD3(OnBufferMapReadAsyncCallback, void(dawnBuffer buffer, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata));
|
||||
MOCK_METHOD3(OnBufferMapWriteAsyncCallback, void(dawnBuffer buffer, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata));
|
||||
MOCK_METHOD3(OnDeviceSetErrorCallback, void(DawnDevice device, DawnDeviceErrorCallback callback, DawnCallbackUserdata userdata));
|
||||
MOCK_METHOD4(OnBuilderSetErrorCallback, void(DawnBufferBuilder builder, DawnBuilderErrorCallback callback, DawnCallbackUserdata userdata1, DawnCallbackUserdata userdata2));
|
||||
MOCK_METHOD3(OnBufferMapReadAsyncCallback, void(DawnBuffer buffer, DawnBufferMapReadCallback callback, DawnCallbackUserdata userdata));
|
||||
MOCK_METHOD3(OnBufferMapWriteAsyncCallback, void(DawnBuffer buffer, DawnBufferMapWriteCallback callback, DawnCallbackUserdata userdata));
|
||||
MOCK_METHOD4(OnFenceOnCompletionCallback,
|
||||
void(dawnFence fence,
|
||||
void(DawnFence fence,
|
||||
uint64_t value,
|
||||
dawnFenceOnCompletionCallback callback,
|
||||
dawnCallbackUserdata userdata));
|
||||
DawnFenceOnCompletionCallback callback,
|
||||
DawnCallbackUserdata userdata));
|
||||
};
|
||||
|
||||
#endif // MOCK_DAWN_H
|
||||
|
|
|
@ -18,19 +18,19 @@
|
|||
#include "dawn/dawn_wsi.h"
|
||||
|
||||
template <typename T>
|
||||
dawnSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
|
||||
dawnSwapChainImplementation impl = {};
|
||||
DawnSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
|
||||
DawnSwapChainImplementation impl = {};
|
||||
impl.userData = swapChain;
|
||||
impl.Init = [](void* userData, void* wsiContext) {
|
||||
auto* ctx = reinterpret_cast<typename T::WSIContext*>(wsiContext);
|
||||
reinterpret_cast<T*>(userData)->Init(ctx);
|
||||
};
|
||||
impl.Destroy = [](void* userData) { delete reinterpret_cast<T*>(userData); };
|
||||
impl.Configure = [](void* userData, dawnTextureFormat format, dawnTextureUsageBit allowedUsage,
|
||||
impl.Configure = [](void* userData, DawnTextureFormat format, DawnTextureUsageBit allowedUsage,
|
||||
uint32_t width, uint32_t height) {
|
||||
return reinterpret_cast<T*>(userData)->Configure(format, allowedUsage, width, height);
|
||||
};
|
||||
impl.GetNextTexture = [](void* userData, dawnSwapChainNextTexture* nextTexture) {
|
||||
impl.GetNextTexture = [](void* userData, DawnSwapChainNextTexture* nextTexture) {
|
||||
return reinterpret_cast<T*>(userData)->GetNextTexture(nextTexture);
|
||||
};
|
||||
impl.Present = [](void* userData) { return reinterpret_cast<T*>(userData)->Present(); };
|
||||
|
|
|
@ -125,7 +125,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
void BufferBase::CallMapReadCallback(uint32_t serial,
|
||||
dawnBufferMapAsyncStatus status,
|
||||
DawnBufferMapAsyncStatus status,
|
||||
const void* pointer,
|
||||
uint32_t dataLength) {
|
||||
ASSERT(!IsError());
|
||||
|
@ -133,14 +133,14 @@ namespace dawn_native {
|
|||
ASSERT(mMapWriteCallback == nullptr);
|
||||
// Tag the callback as fired before firing it, otherwise it could fire a second time if
|
||||
// for example buffer.Unmap() is called inside the application-provided callback.
|
||||
dawnBufferMapReadCallback callback = mMapReadCallback;
|
||||
DawnBufferMapReadCallback callback = mMapReadCallback;
|
||||
mMapReadCallback = nullptr;
|
||||
callback(status, pointer, dataLength, mMapUserdata);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferBase::CallMapWriteCallback(uint32_t serial,
|
||||
dawnBufferMapAsyncStatus status,
|
||||
DawnBufferMapAsyncStatus status,
|
||||
void* pointer,
|
||||
uint32_t dataLength) {
|
||||
ASSERT(!IsError());
|
||||
|
@ -148,7 +148,7 @@ namespace dawn_native {
|
|||
ASSERT(mMapReadCallback == nullptr);
|
||||
// Tag the callback as fired before firing it, otherwise it could fire a second time if
|
||||
// for example buffer.Unmap() is called inside the application-provided callback.
|
||||
dawnBufferMapWriteCallback callback = mMapWriteCallback;
|
||||
DawnBufferMapWriteCallback callback = mMapWriteCallback;
|
||||
mMapWriteCallback = nullptr;
|
||||
callback(status, pointer, dataLength, mMapUserdata);
|
||||
}
|
||||
|
@ -165,8 +165,8 @@ namespace dawn_native {
|
|||
}
|
||||
}
|
||||
|
||||
void BufferBase::MapReadAsync(dawnBufferMapReadCallback callback,
|
||||
dawnCallbackUserdata userdata) {
|
||||
void BufferBase::MapReadAsync(DawnBufferMapReadCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsageBit::MapRead))) {
|
||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||
return;
|
||||
|
@ -204,8 +204,8 @@ namespace dawn_native {
|
|||
return {};
|
||||
}
|
||||
|
||||
void BufferBase::MapWriteAsync(dawnBufferMapWriteCallback callback,
|
||||
dawnCallbackUserdata userdata) {
|
||||
void BufferBase::MapWriteAsync(DawnBufferMapWriteCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsageBit::MapWrite))) {
|
||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||
return;
|
||||
|
|
|
@ -54,8 +54,8 @@ namespace dawn_native {
|
|||
|
||||
// Dawn API
|
||||
void SetSubData(uint32_t start, uint32_t count, const uint8_t* data);
|
||||
void MapReadAsync(dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata);
|
||||
void MapWriteAsync(dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata);
|
||||
void MapReadAsync(DawnBufferMapReadCallback callback, DawnCallbackUserdata userdata);
|
||||
void MapWriteAsync(DawnBufferMapWriteCallback callback, DawnCallbackUserdata userdata);
|
||||
void Unmap();
|
||||
void Destroy();
|
||||
|
||||
|
@ -63,11 +63,11 @@ namespace dawn_native {
|
|||
BufferBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||
|
||||
void CallMapReadCallback(uint32_t serial,
|
||||
dawnBufferMapAsyncStatus status,
|
||||
DawnBufferMapAsyncStatus status,
|
||||
const void* pointer,
|
||||
uint32_t dataLength);
|
||||
void CallMapWriteCallback(uint32_t serial,
|
||||
dawnBufferMapAsyncStatus status,
|
||||
DawnBufferMapAsyncStatus status,
|
||||
void* pointer,
|
||||
uint32_t dataLength);
|
||||
|
||||
|
@ -85,9 +85,9 @@ namespace dawn_native {
|
|||
uint32_t mSize = 0;
|
||||
dawn::BufferUsageBit mUsage = dawn::BufferUsageBit::None;
|
||||
|
||||
dawnBufferMapReadCallback mMapReadCallback = nullptr;
|
||||
dawnBufferMapWriteCallback mMapWriteCallback = nullptr;
|
||||
dawnCallbackUserdata mMapUserdata = 0;
|
||||
DawnBufferMapReadCallback mMapReadCallback = nullptr;
|
||||
DawnBufferMapWriteCallback mMapWriteCallback = nullptr;
|
||||
DawnCallbackUserdata mMapUserdata = 0;
|
||||
uint32_t mMapSerial = 0;
|
||||
|
||||
BufferState mState;
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
if (mCallback != nullptr) {
|
||||
mCallback(static_cast<dawnBuilderErrorStatus>(mStoredStatus), mStoredMessage.c_str(),
|
||||
mCallback(static_cast<DawnBuilderErrorStatus>(mStoredStatus), mStoredMessage.c_str(),
|
||||
mUserdata1, mUserdata2);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
namespace dawn_native {
|
||||
|
||||
dawnProcTable GetProcsAutogen();
|
||||
DawnProcTable GetProcsAutogen();
|
||||
|
||||
dawnProcTable GetProcs() {
|
||||
DawnProcTable GetProcs() {
|
||||
return GetProcsAutogen();
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ namespace dawn_native {
|
|||
return mImpl != nullptr;
|
||||
}
|
||||
|
||||
dawnDevice Adapter::CreateDevice() {
|
||||
return reinterpret_cast<dawnDevice>(mImpl->CreateDevice());
|
||||
DawnDevice Adapter::CreateDevice() {
|
||||
return reinterpret_cast<DawnDevice>(mImpl->CreateDevice());
|
||||
}
|
||||
|
||||
// AdapterDiscoverOptionsBase
|
||||
|
|
|
@ -45,8 +45,8 @@ namespace dawn_native {
|
|||
return DAWN_VALIDATION_ERROR("Null implementation for the swapchain");
|
||||
}
|
||||
|
||||
dawnSwapChainImplementation* impl =
|
||||
reinterpret_cast<dawnSwapChainImplementation*>(descriptor->implementation);
|
||||
DawnSwapChainImplementation* impl =
|
||||
reinterpret_cast<DawnSwapChainImplementation*>(descriptor->implementation);
|
||||
|
||||
if (!impl->Init || !impl->Destroy || !impl->Configure || !impl->GetNextTexture ||
|
||||
!impl->Present) {
|
||||
|
@ -61,7 +61,7 @@ namespace dawn_native {
|
|||
SwapChainBase::SwapChainBase(DeviceBase* device, const SwapChainDescriptor* descriptor)
|
||||
: ObjectBase(device),
|
||||
mImplementation(
|
||||
*reinterpret_cast<dawnSwapChainImplementation*>(descriptor->implementation)) {
|
||||
*reinterpret_cast<DawnSwapChainImplementation*>(descriptor->implementation)) {
|
||||
}
|
||||
|
||||
SwapChainBase::SwapChainBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
|
@ -95,8 +95,8 @@ namespace dawn_native {
|
|||
mAllowedUsage = allowedUsage;
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mImplementation.Configure(mImplementation.userData, static_cast<dawnTextureFormat>(format),
|
||||
static_cast<dawnTextureUsageBit>(allowedUsage), width, height);
|
||||
mImplementation.Configure(mImplementation.userData, static_cast<DawnTextureFormat>(format),
|
||||
static_cast<DawnTextureUsageBit>(allowedUsage), width, height);
|
||||
}
|
||||
|
||||
TextureBase* SwapChainBase::GetNextTexture() {
|
||||
|
@ -132,7 +132,7 @@ namespace dawn_native {
|
|||
mImplementation.Present(mImplementation.userData);
|
||||
}
|
||||
|
||||
const dawnSwapChainImplementation& SwapChainBase::GetImplementation() {
|
||||
const DawnSwapChainImplementation& SwapChainBase::GetImplementation() {
|
||||
ASSERT(!IsError());
|
||||
return mImplementation;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace dawn_native {
|
|||
protected:
|
||||
SwapChainBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||
|
||||
const dawnSwapChainImplementation& GetImplementation();
|
||||
const DawnSwapChainImplementation& GetImplementation();
|
||||
virtual TextureBase* GetNextTextureImpl(const TextureDescriptor*) = 0;
|
||||
virtual void OnBeforePresent(TextureBase* texture) = 0;
|
||||
|
||||
|
@ -58,7 +58,7 @@ namespace dawn_native {
|
|||
MaybeError ValidateGetNextTexture() const;
|
||||
MaybeError ValidatePresent(TextureBase* texture) const;
|
||||
|
||||
dawnSwapChainImplementation mImplementation = {};
|
||||
DawnSwapChainImplementation mImplementation = {};
|
||||
dawn::TextureFormat mFormat = {};
|
||||
dawn::TextureUsageBit mAllowedUsage;
|
||||
uint32_t mWidth = 0;
|
||||
|
|
|
@ -23,20 +23,20 @@
|
|||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device, HWND window) {
|
||||
DawnSwapChainImplementation CreateNativeSwapChainImpl(DawnDevice device, HWND window) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
|
||||
dawnSwapChainImplementation impl;
|
||||
DawnSwapChainImplementation impl;
|
||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, window));
|
||||
impl.textureUsage = DAWN_TEXTURE_USAGE_BIT_PRESENT;
|
||||
|
||||
return impl;
|
||||
}
|
||||
|
||||
dawnTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
const dawnSwapChainImplementation* swapChain) {
|
||||
DawnTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
const DawnSwapChainImplementation* swapChain) {
|
||||
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
||||
return static_cast<dawnTextureFormat>(impl->GetPreferredFormat());
|
||||
return static_cast<DawnTextureFormat>(impl->GetPreferredFormat());
|
||||
}
|
||||
|
||||
}} // namespace dawn_native::d3d12
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
namespace {
|
||||
DXGI_USAGE D3D12SwapChainBufferUsage(dawnTextureUsageBit allowedUsages) {
|
||||
DXGI_USAGE D3D12SwapChainBufferUsage(DawnTextureUsageBit allowedUsages) {
|
||||
DXGI_USAGE usage = DXGI_CPU_ACCESS_NONE;
|
||||
if (allowedUsages & DAWN_TEXTURE_USAGE_BIT_SAMPLED) {
|
||||
usage |= DXGI_USAGE_SHADER_INPUT;
|
||||
|
@ -45,16 +45,16 @@ namespace dawn_native { namespace d3d12 {
|
|||
NativeSwapChainImpl::~NativeSwapChainImpl() {
|
||||
}
|
||||
|
||||
void NativeSwapChainImpl::Init(dawnWSIContextD3D12* /*context*/) {
|
||||
void NativeSwapChainImpl::Init(DawnWSIContextD3D12* /*context*/) {
|
||||
}
|
||||
|
||||
dawnSwapChainError NativeSwapChainImpl::Configure(dawnTextureFormat format,
|
||||
dawnTextureUsageBit usage,
|
||||
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
||||
DawnTextureUsageBit usage,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
ASSERT(width > 0);
|
||||
ASSERT(height > 0);
|
||||
ASSERT(format == static_cast<dawnTextureFormat>(GetPreferredFormat()));
|
||||
ASSERT(format == static_cast<DawnTextureFormat>(GetPreferredFormat()));
|
||||
|
||||
ComPtr<IDXGIFactory4> factory = mDevice->GetFactory();
|
||||
ComPtr<ID3D12CommandQueue> queue = mDevice->GetCommandQueue();
|
||||
|
@ -89,7 +89,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawnSwapChainError NativeSwapChainImpl::GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
|
||||
DawnSwapChainError NativeSwapChainImpl::GetNextTexture(DawnSwapChainNextTexture* nextTexture) {
|
||||
mCurrentBuffer = mSwapChain->GetCurrentBackBufferIndex();
|
||||
nextTexture->texture.ptr = mBuffers[mCurrentBuffer].Get();
|
||||
|
||||
|
@ -100,7 +100,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawnSwapChainError NativeSwapChainImpl::Present() {
|
||||
DawnSwapChainError NativeSwapChainImpl::Present() {
|
||||
// This assumes the texture has already been transition to the PRESENT state.
|
||||
|
||||
ASSERT_SUCCESS(mSwapChain->Present(1, 0));
|
||||
|
|
|
@ -28,18 +28,18 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
class NativeSwapChainImpl {
|
||||
public:
|
||||
using WSIContext = dawnWSIContextD3D12;
|
||||
using WSIContext = DawnWSIContextD3D12;
|
||||
|
||||
NativeSwapChainImpl(Device* device, HWND window);
|
||||
~NativeSwapChainImpl();
|
||||
|
||||
void Init(dawnWSIContextD3D12* context);
|
||||
dawnSwapChainError Configure(dawnTextureFormat format,
|
||||
dawnTextureUsageBit,
|
||||
void Init(DawnWSIContextD3D12* context);
|
||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||
DawnTextureUsageBit,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
|
||||
dawnSwapChainError Present();
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||
DawnSwapChainError Present();
|
||||
|
||||
dawn::TextureFormat GetPreferredFormat() const;
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ namespace dawn_native { namespace d3d12 {
|
|||
SwapChain::SwapChain(Device* device, const SwapChainDescriptor* descriptor)
|
||||
: SwapChainBase(device, descriptor) {
|
||||
const auto& im = GetImplementation();
|
||||
dawnWSIContextD3D12 wsiContext = {};
|
||||
wsiContext.device = reinterpret_cast<dawnDevice>(GetDevice());
|
||||
DawnWSIContextD3D12 wsiContext = {};
|
||||
wsiContext.device = reinterpret_cast<DawnDevice>(GetDevice());
|
||||
im.Init(im.userData, &wsiContext);
|
||||
|
||||
ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_BIT_NONE);
|
||||
|
@ -37,8 +37,8 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
TextureBase* SwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
|
||||
const auto& im = GetImplementation();
|
||||
dawnSwapChainNextTexture next = {};
|
||||
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
DawnSwapChainNextTexture next = {};
|
||||
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
if (error) {
|
||||
GetDevice()->HandleError(error);
|
||||
return nullptr;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#ifndef DAWNNATIVE_DAWNPLATFORM_H_
|
||||
#define DAWNNATIVE_DAWNPLATFORM_H_
|
||||
|
||||
// Use dawncpp to have the enum and bitfield definitions
|
||||
// Use cawncpp to have the enum and bitfield definitions
|
||||
#include <dawn/dawncpp.h>
|
||||
|
||||
// Use our autogenerated version of the dawn structures that point to dawn_native object types
|
||||
|
|
|
@ -22,20 +22,20 @@
|
|||
|
||||
namespace dawn_native { namespace metal {
|
||||
|
||||
id<MTLDevice> GetMetalDevice(dawnDevice cDevice) {
|
||||
id<MTLDevice> GetMetalDevice(DawnDevice cDevice) {
|
||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||
return device->GetMTLDevice();
|
||||
}
|
||||
|
||||
dawnTexture WrapIOSurface(dawnDevice cDevice,
|
||||
const dawnTextureDescriptor* cDescriptor,
|
||||
DawnTexture WrapIOSurface(DawnDevice cDevice,
|
||||
const DawnTextureDescriptor* cDescriptor,
|
||||
IOSurfaceRef ioSurface,
|
||||
uint32_t plane) {
|
||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||
const TextureDescriptor* descriptor =
|
||||
reinterpret_cast<const TextureDescriptor*>(cDescriptor);
|
||||
TextureBase* texture = device->CreateTextureWrappingIOSurface(descriptor, ioSurface, plane);
|
||||
return reinterpret_cast<dawnTexture>(texture);
|
||||
return reinterpret_cast<DawnTexture>(texture);
|
||||
}
|
||||
|
||||
}} // namespace dawn_native::metal
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace dawn_native { namespace metal {
|
|||
SwapChain::SwapChain(Device* device, const SwapChainDescriptor* descriptor)
|
||||
: SwapChainBase(device, descriptor) {
|
||||
const auto& im = GetImplementation();
|
||||
dawnWSIContextMetal wsiContext = {};
|
||||
DawnWSIContextMetal wsiContext = {};
|
||||
wsiContext.device = ToBackend(GetDevice())->GetMTLDevice();
|
||||
im.Init(im.userData, &wsiContext);
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ namespace dawn_native { namespace metal {
|
|||
|
||||
TextureBase* SwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
|
||||
const auto& im = GetImplementation();
|
||||
dawnSwapChainNextTexture next = {};
|
||||
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
DawnSwapChainNextTexture next = {};
|
||||
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
if (error) {
|
||||
GetDevice()->HandleError(error);
|
||||
return nullptr;
|
||||
|
|
|
@ -271,18 +271,18 @@ namespace dawn_native { namespace null {
|
|||
void NativeSwapChainImpl::Init(WSIContext* context) {
|
||||
}
|
||||
|
||||
dawnSwapChainError NativeSwapChainImpl::Configure(dawnTextureFormat format,
|
||||
dawnTextureUsageBit,
|
||||
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
||||
DawnTextureUsageBit,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawnSwapChainError NativeSwapChainImpl::GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
|
||||
DawnSwapChainError NativeSwapChainImpl::GetNextTexture(DawnSwapChainNextTexture* nextTexture) {
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawnSwapChainError NativeSwapChainImpl::Present() {
|
||||
DawnSwapChainError NativeSwapChainImpl::Present() {
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -184,12 +184,12 @@ namespace dawn_native { namespace null {
|
|||
public:
|
||||
using WSIContext = struct {};
|
||||
void Init(WSIContext* context);
|
||||
dawnSwapChainError Configure(dawnTextureFormat format,
|
||||
dawnTextureUsageBit,
|
||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||
DawnTextureUsageBit,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
|
||||
dawnSwapChainError Present();
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||
DawnSwapChainError Present();
|
||||
dawn::TextureFormat GetPreferredFormat() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
namespace dawn_native { namespace null {
|
||||
|
||||
dawnSwapChainImplementation CreateNativeSwapChainImpl() {
|
||||
dawnSwapChainImplementation impl;
|
||||
DawnSwapChainImplementation CreateNativeSwapChainImpl() {
|
||||
DawnSwapChainImplementation impl;
|
||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl());
|
||||
impl.textureUsage = DAWN_TEXTURE_USAGE_BIT_PRESENT;
|
||||
return impl;
|
||||
|
|
|
@ -33,8 +33,8 @@ namespace dawn_native { namespace opengl {
|
|||
|
||||
TextureBase* SwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
|
||||
const auto& im = GetImplementation();
|
||||
dawnSwapChainNextTexture next = {};
|
||||
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
DawnSwapChainNextTexture next = {};
|
||||
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
if (error) {
|
||||
GetDevice()->HandleError(error);
|
||||
return nullptr;
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace dawn_native { namespace vulkan {
|
|||
}
|
||||
}
|
||||
|
||||
void NativeSwapChainImpl::Init(dawnWSIContextVulkan* /*context*/) {
|
||||
void NativeSwapChainImpl::Init(DawnWSIContextVulkan* /*context*/) {
|
||||
if (mDevice->ConsumedError(
|
||||
GatherSurfaceInfo(*ToBackend(mDevice->GetAdapter()), mSurface, &mInfo))) {
|
||||
ASSERT(false);
|
||||
|
@ -68,8 +68,8 @@ namespace dawn_native { namespace vulkan {
|
|||
}
|
||||
}
|
||||
|
||||
dawnSwapChainError NativeSwapChainImpl::Configure(dawnTextureFormat format,
|
||||
dawnTextureUsageBit usage,
|
||||
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
||||
DawnTextureUsageBit usage,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
ASSERT(mInfo.capabilities.minImageExtent.width <= width);
|
||||
|
@ -77,7 +77,7 @@ namespace dawn_native { namespace vulkan {
|
|||
ASSERT(mInfo.capabilities.minImageExtent.height <= height);
|
||||
ASSERT(mInfo.capabilities.maxImageExtent.height >= height);
|
||||
|
||||
ASSERT(format == static_cast<dawnTextureFormat>(GetPreferredFormat()));
|
||||
ASSERT(format == static_cast<DawnTextureFormat>(GetPreferredFormat()));
|
||||
// TODO(cwallez@chromium.org): need to check usage works too
|
||||
|
||||
// Create the swapchain with the configuration we chose
|
||||
|
@ -151,7 +151,7 @@ namespace dawn_native { namespace vulkan {
|
|||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawnSwapChainError NativeSwapChainImpl::GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
|
||||
DawnSwapChainError NativeSwapChainImpl::GetNextTexture(DawnSwapChainNextTexture* nextTexture) {
|
||||
// Transiently create a semaphore that will be signaled when the presentation engine is done
|
||||
// with the swapchain image. Further operations on the image will wait for this semaphore.
|
||||
VkSemaphore semaphore = VK_NULL_HANDLE;
|
||||
|
@ -178,7 +178,7 @@ namespace dawn_native { namespace vulkan {
|
|||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawnSwapChainError NativeSwapChainImpl::Present() {
|
||||
DawnSwapChainError NativeSwapChainImpl::Present() {
|
||||
// This assumes that the image has already been transitioned to the PRESENT layout and
|
||||
// writes were made available to the stage.
|
||||
|
||||
|
|
|
@ -26,18 +26,18 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
class NativeSwapChainImpl {
|
||||
public:
|
||||
using WSIContext = dawnWSIContextVulkan;
|
||||
using WSIContext = DawnWSIContextVulkan;
|
||||
|
||||
NativeSwapChainImpl(Device* device, VkSurfaceKHR surface);
|
||||
~NativeSwapChainImpl();
|
||||
|
||||
void Init(dawnWSIContextVulkan* context);
|
||||
dawnSwapChainError Configure(dawnTextureFormat format,
|
||||
dawnTextureUsageBit,
|
||||
void Init(DawnWSIContextVulkan* context);
|
||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||
DawnTextureUsageBit,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
|
||||
dawnSwapChainError Present();
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||
DawnSwapChainError Present();
|
||||
|
||||
dawn::TextureFormat GetPreferredFormat() const;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace dawn_native { namespace vulkan {
|
|||
SwapChain::SwapChain(Device* device, const SwapChainDescriptor* descriptor)
|
||||
: SwapChainBase(device, descriptor) {
|
||||
const auto& im = GetImplementation();
|
||||
dawnWSIContextVulkan wsiContext = {};
|
||||
DawnWSIContextVulkan wsiContext = {};
|
||||
im.Init(im.userData, &wsiContext);
|
||||
|
||||
ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_BIT_NONE);
|
||||
|
@ -34,8 +34,8 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
TextureBase* SwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
|
||||
const auto& im = GetImplementation();
|
||||
dawnSwapChainNextTexture next = {};
|
||||
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
DawnSwapChainNextTexture next = {};
|
||||
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
|
||||
if (error) {
|
||||
GetDevice()->HandleError(error);
|
||||
|
|
|
@ -27,29 +27,29 @@
|
|||
|
||||
namespace dawn_native { namespace vulkan {
|
||||
|
||||
VkInstance GetInstance(dawnDevice device) {
|
||||
VkInstance GetInstance(DawnDevice device) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
return backendDevice->GetVkInstance();
|
||||
}
|
||||
|
||||
// Explicitly export this function because it uses the "native" type for surfaces while the
|
||||
// header as seen in this file uses the wrapped type.
|
||||
DAWN_NATIVE_EXPORT dawnSwapChainImplementation
|
||||
CreateNativeSwapChainImpl(dawnDevice device, VkSurfaceKHRNative surfaceNative) {
|
||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation
|
||||
CreateNativeSwapChainImpl(DawnDevice device, VkSurfaceKHRNative surfaceNative) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
VkSurfaceKHR surface = VkSurfaceKHR::CreateFromHandle(surfaceNative);
|
||||
|
||||
dawnSwapChainImplementation impl;
|
||||
DawnSwapChainImplementation impl;
|
||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, surface));
|
||||
impl.textureUsage = DAWN_TEXTURE_USAGE_BIT_PRESENT;
|
||||
|
||||
return impl;
|
||||
}
|
||||
|
||||
dawnTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
const dawnSwapChainImplementation* swapChain) {
|
||||
DawnTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
const DawnSwapChainImplementation* swapChain) {
|
||||
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
||||
return static_cast<dawnTextureFormat>(impl->GetPreferredFormat());
|
||||
return static_cast<DawnTextureFormat>(impl->GetPreferredFormat());
|
||||
}
|
||||
|
||||
}} // namespace dawn_native::vulkan
|
||||
|
|
|
@ -24,11 +24,11 @@ namespace dawn_wire {
|
|||
mImpl.reset();
|
||||
}
|
||||
|
||||
dawnDevice WireClient::GetDevice() const {
|
||||
DawnDevice WireClient::GetDevice() const {
|
||||
return mImpl->GetDevice();
|
||||
}
|
||||
|
||||
dawnProcTable WireClient::GetProcs() const {
|
||||
DawnProcTable WireClient::GetProcs() const {
|
||||
return client::GetProcs();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
namespace dawn_wire {
|
||||
|
||||
WireServer::WireServer(dawnDevice device,
|
||||
const dawnProcTable& procs,
|
||||
WireServer::WireServer(DawnDevice device,
|
||||
const DawnProcTable& procs,
|
||||
CommandSerializer* serializer)
|
||||
: mImpl(new server::Server(device, procs, serializer)) {
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
namespace dawn_wire { namespace client {
|
||||
|
||||
void ClientBufferMapReadAsync(dawnBuffer cBuffer,
|
||||
dawnBufferMapReadCallback callback,
|
||||
dawnCallbackUserdata userdata) {
|
||||
void ClientBufferMapReadAsync(DawnBuffer cBuffer,
|
||||
DawnBufferMapReadCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||
|
||||
uint32_t serial = buffer->requestSerial++;
|
||||
|
@ -43,9 +43,9 @@ namespace dawn_wire { namespace client {
|
|||
cmd.Serialize(allocatedBuffer);
|
||||
}
|
||||
|
||||
void ClientBufferMapWriteAsync(dawnBuffer cBuffer,
|
||||
dawnBufferMapWriteCallback callback,
|
||||
dawnCallbackUserdata userdata) {
|
||||
void ClientBufferMapWriteAsync(DawnBuffer cBuffer,
|
||||
DawnBufferMapWriteCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||
|
||||
uint32_t serial = buffer->requestSerial++;
|
||||
|
@ -68,15 +68,15 @@ namespace dawn_wire { namespace client {
|
|||
cmd.Serialize(allocatedBuffer);
|
||||
}
|
||||
|
||||
uint64_t ClientFenceGetCompletedValue(dawnFence cSelf) {
|
||||
uint64_t ClientFenceGetCompletedValue(DawnFence cSelf) {
|
||||
auto fence = reinterpret_cast<Fence*>(cSelf);
|
||||
return fence->completedValue;
|
||||
}
|
||||
|
||||
void ClientFenceOnCompletion(dawnFence cFence,
|
||||
void ClientFenceOnCompletion(DawnFence cFence,
|
||||
uint64_t value,
|
||||
dawnFenceOnCompletionCallback callback,
|
||||
dawnCallbackUserdata userdata) {
|
||||
DawnFenceOnCompletionCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
Fence* fence = reinterpret_cast<Fence*>(cFence);
|
||||
if (value > fence->signaledValue) {
|
||||
fence->device->HandleError("Value greater than fence signaled value");
|
||||
|
@ -95,7 +95,7 @@ namespace dawn_wire { namespace client {
|
|||
fence->requests.Enqueue(std::move(request), value);
|
||||
}
|
||||
|
||||
void ClientBufferUnmap(dawnBuffer cBuffer) {
|
||||
void ClientBufferUnmap(DawnBuffer cBuffer) {
|
||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||
|
||||
// Invalidate the local pointer, and cancel all other in-flight requests that would
|
||||
|
@ -133,7 +133,7 @@ namespace dawn_wire { namespace client {
|
|||
cmd.Serialize(allocatedBuffer, *buffer->device->GetClient());
|
||||
}
|
||||
|
||||
dawnFence ClientQueueCreateFence(dawnQueue cSelf, dawnFenceDescriptor const* descriptor) {
|
||||
DawnFence ClientQueueCreateFence(DawnQueue cSelf, DawnFenceDescriptor const* descriptor) {
|
||||
Queue* queue = reinterpret_cast<Queue*>(cSelf);
|
||||
Device* device = queue->device;
|
||||
|
||||
|
@ -147,7 +147,7 @@ namespace dawn_wire { namespace client {
|
|||
char* allocatedBuffer = static_cast<char*>(device->GetClient()->GetCmdSpace(requiredSize));
|
||||
cmd.Serialize(allocatedBuffer, *device->GetClient());
|
||||
|
||||
dawnFence cFence = reinterpret_cast<dawnFence>(allocation->object.get());
|
||||
DawnFence cFence = reinterpret_cast<DawnFence>(allocation->object.get());
|
||||
|
||||
Fence* fence = reinterpret_cast<Fence*>(cFence);
|
||||
fence->queue = queue;
|
||||
|
@ -156,7 +156,7 @@ namespace dawn_wire { namespace client {
|
|||
return cFence;
|
||||
}
|
||||
|
||||
void ClientQueueSignal(dawnQueue cQueue, dawnFence cFence, uint64_t signalValue) {
|
||||
void ClientQueueSignal(DawnQueue cQueue, DawnFence cFence, uint64_t signalValue) {
|
||||
Fence* fence = reinterpret_cast<Fence*>(cFence);
|
||||
Queue* queue = reinterpret_cast<Queue*>(cQueue);
|
||||
if (fence->queue != queue) {
|
||||
|
@ -181,15 +181,15 @@ namespace dawn_wire { namespace client {
|
|||
cmd.Serialize(allocatedBuffer, *fence->device->GetClient());
|
||||
}
|
||||
|
||||
void ClientDeviceReference(dawnDevice) {
|
||||
void ClientDeviceReference(DawnDevice) {
|
||||
}
|
||||
|
||||
void ClientDeviceRelease(dawnDevice) {
|
||||
void ClientDeviceRelease(DawnDevice) {
|
||||
}
|
||||
|
||||
void ClientDeviceSetErrorCallback(dawnDevice cSelf,
|
||||
dawnDeviceErrorCallback callback,
|
||||
dawnCallbackUserdata userdata) {
|
||||
void ClientDeviceSetErrorCallback(DawnDevice cSelf,
|
||||
DawnDeviceErrorCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
Device* device = reinterpret_cast<Device*>(cSelf);
|
||||
device->SetErrorCallback(callback, userdata);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace dawn_wire { namespace client {
|
|||
}
|
||||
}
|
||||
|
||||
void Buffer::ClearMapRequests(dawnBufferMapAsyncStatus status) {
|
||||
void Buffer::ClearMapRequests(DawnBufferMapAsyncStatus status) {
|
||||
for (auto& it : requests) {
|
||||
if (it.second.isWrite) {
|
||||
it.second.writeCallback(status, nullptr, 0, it.second.userdata);
|
||||
|
|
|
@ -27,15 +27,15 @@ namespace dawn_wire { namespace client {
|
|||
using ObjectBase::ObjectBase;
|
||||
|
||||
~Buffer();
|
||||
void ClearMapRequests(dawnBufferMapAsyncStatus status);
|
||||
void ClearMapRequests(DawnBufferMapAsyncStatus status);
|
||||
|
||||
// We want to defer all the validation to the server, which means we could have multiple
|
||||
// map request in flight at a single time and need to track them separately.
|
||||
// On well-behaved applications, only one request should exist at a single time.
|
||||
struct MapRequestData {
|
||||
dawnBufferMapReadCallback readCallback = nullptr;
|
||||
dawnBufferMapWriteCallback writeCallback = nullptr;
|
||||
dawnCallbackUserdata userdata = 0;
|
||||
DawnBufferMapReadCallback readCallback = nullptr;
|
||||
DawnBufferMapWriteCallback writeCallback = nullptr;
|
||||
DawnCallbackUserdata userdata = 0;
|
||||
bool isWrite = false;
|
||||
};
|
||||
std::map<uint32_t, MapRequestData> requests;
|
||||
|
|
|
@ -36,8 +36,8 @@ namespace dawn_wire { namespace client {
|
|||
return mSerializer->GetCmdSpace(size);
|
||||
}
|
||||
|
||||
dawnDevice GetDevice() const {
|
||||
return reinterpret_cast<dawnDeviceImpl*>(mDevice);
|
||||
DawnDevice GetDevice() const {
|
||||
return reinterpret_cast<DawnDeviceImpl*>(mDevice);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -48,7 +48,7 @@ namespace dawn_wire { namespace client {
|
|||
WireDeserializeAllocator mAllocator;
|
||||
};
|
||||
|
||||
dawnProcTable GetProcs();
|
||||
DawnProcTable GetProcs();
|
||||
|
||||
}} // namespace dawn_wire::client
|
||||
|
||||
|
|
|
@ -64,10 +64,10 @@ namespace dawn_wire { namespace client {
|
|||
buffer->mappedData = malloc(dataLength);
|
||||
memcpy(buffer->mappedData, data, dataLength);
|
||||
|
||||
request.readCallback(static_cast<dawnBufferMapAsyncStatus>(status), buffer->mappedData,
|
||||
request.readCallback(static_cast<DawnBufferMapAsyncStatus>(status), buffer->mappedData,
|
||||
dataLength, request.userdata);
|
||||
} else {
|
||||
request.readCallback(static_cast<dawnBufferMapAsyncStatus>(status), nullptr, 0,
|
||||
request.readCallback(static_cast<DawnBufferMapAsyncStatus>(status), nullptr, 0,
|
||||
request.userdata);
|
||||
}
|
||||
|
||||
|
@ -111,10 +111,10 @@ namespace dawn_wire { namespace client {
|
|||
buffer->mappedData = malloc(dataLength);
|
||||
memset(buffer->mappedData, 0, dataLength);
|
||||
|
||||
request.writeCallback(static_cast<dawnBufferMapAsyncStatus>(status), buffer->mappedData,
|
||||
request.writeCallback(static_cast<DawnBufferMapAsyncStatus>(status), buffer->mappedData,
|
||||
dataLength, request.userdata);
|
||||
} else {
|
||||
request.writeCallback(static_cast<dawnBufferMapAsyncStatus>(status), nullptr, 0,
|
||||
request.writeCallback(static_cast<DawnBufferMapAsyncStatus>(status), nullptr, 0,
|
||||
request.userdata);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ namespace dawn_wire { namespace client {
|
|||
}
|
||||
}
|
||||
|
||||
void Device::SetErrorCallback(dawnDeviceErrorCallback errorCallback,
|
||||
dawnCallbackUserdata errorUserdata) {
|
||||
void Device::SetErrorCallback(DawnDeviceErrorCallback errorCallback,
|
||||
DawnCallbackUserdata errorUserdata) {
|
||||
mErrorCallback = errorCallback;
|
||||
mErrorUserdata = errorUserdata;
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@ namespace dawn_wire { namespace client {
|
|||
|
||||
Client* GetClient();
|
||||
void HandleError(const char* message);
|
||||
void SetErrorCallback(dawnDeviceErrorCallback errorCallback,
|
||||
dawnCallbackUserdata errorUserdata);
|
||||
void SetErrorCallback(DawnDeviceErrorCallback errorCallback,
|
||||
DawnCallbackUserdata errorUserdata);
|
||||
|
||||
private:
|
||||
Client* mClient = nullptr;
|
||||
dawnDeviceErrorCallback mErrorCallback = nullptr;
|
||||
dawnCallbackUserdata mErrorUserdata;
|
||||
DawnDeviceErrorCallback mErrorCallback = nullptr;
|
||||
DawnCallbackUserdata mErrorUserdata;
|
||||
};
|
||||
|
||||
}} // namespace dawn_wire::client
|
||||
|
|
|
@ -30,8 +30,8 @@ namespace dawn_wire { namespace client {
|
|||
void CheckPassedFences();
|
||||
|
||||
struct OnCompletionData {
|
||||
dawnFenceOnCompletionCallback completionCallback = nullptr;
|
||||
dawnCallbackUserdata userdata = 0;
|
||||
DawnFenceOnCompletionCallback completionCallback = nullptr;
|
||||
DawnCallbackUserdata userdata = 0;
|
||||
};
|
||||
Queue* queue = nullptr;
|
||||
uint64_t signaledValue = 0;
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace dawn_wire { namespace client {
|
|||
class Device;
|
||||
|
||||
struct BuilderCallbackData {
|
||||
bool Call(dawnBuilderErrorStatus status, const char* message) {
|
||||
bool Call(DawnBuilderErrorStatus status, const char* message) {
|
||||
if (canCall && callback != nullptr) {
|
||||
canCall = true;
|
||||
callback(status, message, userdata1, userdata2);
|
||||
|
@ -33,9 +33,9 @@ namespace dawn_wire { namespace client {
|
|||
}
|
||||
|
||||
// For help with development, prints all builder errors by default.
|
||||
dawnBuilderErrorCallback callback = nullptr;
|
||||
dawnCallbackUserdata userdata1 = 0;
|
||||
dawnCallbackUserdata userdata2 = 0;
|
||||
DawnBuilderErrorCallback callback = nullptr;
|
||||
DawnCallbackUserdata userdata1 = 0;
|
||||
DawnCallbackUserdata userdata2 = 0;
|
||||
bool canCall = true;
|
||||
};
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace dawn_wire { namespace server {
|
|||
};
|
||||
|
||||
template <>
|
||||
struct ObjectData<dawnBuffer, false> : public ObjectDataBase<dawnBuffer> {
|
||||
struct ObjectData<DawnBuffer, false> : public ObjectDataBase<DawnBuffer> {
|
||||
void* mappedData = nullptr;
|
||||
size_t mappedDataSize = 0;
|
||||
};
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
|
||||
namespace dawn_wire { namespace server {
|
||||
|
||||
Server::Server(dawnDevice device, const dawnProcTable& procs, CommandSerializer* serializer)
|
||||
Server::Server(DawnDevice device, const DawnProcTable& procs, CommandSerializer* serializer)
|
||||
: mSerializer(serializer), mProcs(procs) {
|
||||
// The client-server knowledge is bootstrapped with device 1.
|
||||
auto* deviceData = DeviceObjects().Allocate(1);
|
||||
deviceData->handle = device;
|
||||
deviceData->valid = true;
|
||||
|
||||
auto userdata = static_cast<dawnCallbackUserdata>(reinterpret_cast<intptr_t>(this));
|
||||
auto userdata = static_cast<DawnCallbackUserdata>(reinterpret_cast<intptr_t>(this));
|
||||
procs.deviceSetErrorCallback(device, ForwardDeviceError, userdata);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace dawn_wire { namespace server {
|
|||
|
||||
class Server : public ServerBase {
|
||||
public:
|
||||
Server(dawnDevice device, const dawnProcTable& procs, CommandSerializer* serializer);
|
||||
Server(DawnDevice device, const DawnProcTable& procs, CommandSerializer* serializer);
|
||||
~Server();
|
||||
|
||||
const char* HandleCommands(const char* commands, size_t size);
|
||||
|
@ -46,25 +46,25 @@ namespace dawn_wire { namespace server {
|
|||
void* GetCmdSpace(size_t size);
|
||||
|
||||
// Forwarding callbacks
|
||||
static void ForwardDeviceError(const char* message, dawnCallbackUserdata userdata);
|
||||
static void ForwardBufferMapReadAsync(dawnBufferMapAsyncStatus status,
|
||||
static void ForwardDeviceError(const char* message, DawnCallbackUserdata userdata);
|
||||
static void ForwardBufferMapReadAsync(DawnBufferMapAsyncStatus status,
|
||||
const void* ptr,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata);
|
||||
static void ForwardBufferMapWriteAsync(dawnBufferMapAsyncStatus status,
|
||||
DawnCallbackUserdata userdata);
|
||||
static void ForwardBufferMapWriteAsync(DawnBufferMapAsyncStatus status,
|
||||
void* ptr,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata);
|
||||
static void ForwardFenceCompletedValue(dawnFenceCompletionStatus status,
|
||||
dawnCallbackUserdata userdata);
|
||||
DawnCallbackUserdata userdata);
|
||||
static void ForwardFenceCompletedValue(DawnFenceCompletionStatus status,
|
||||
DawnCallbackUserdata userdata);
|
||||
|
||||
// Error callbacks
|
||||
void OnDeviceError(const char* message);
|
||||
void OnBufferMapReadAsyncCallback(dawnBufferMapAsyncStatus status,
|
||||
void OnBufferMapReadAsyncCallback(DawnBufferMapAsyncStatus status,
|
||||
const void* ptr,
|
||||
uint32_t dataLength,
|
||||
MapUserdata* userdata);
|
||||
void OnBufferMapWriteAsyncCallback(dawnBufferMapAsyncStatus status,
|
||||
void OnBufferMapWriteAsyncCallback(DawnBufferMapAsyncStatus status,
|
||||
void* ptr,
|
||||
uint32_t dataLength,
|
||||
MapUserdata* userdata);
|
||||
|
@ -74,7 +74,7 @@ namespace dawn_wire { namespace server {
|
|||
|
||||
CommandSerializer* mSerializer = nullptr;
|
||||
WireDeserializeAllocator mAllocator;
|
||||
dawnProcTable mProcs;
|
||||
DawnProcTable mProcs;
|
||||
};
|
||||
|
||||
}} // namespace dawn_wire::server
|
||||
|
|
|
@ -93,23 +93,23 @@ namespace dawn_wire { namespace server {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Server::ForwardBufferMapReadAsync(dawnBufferMapAsyncStatus status,
|
||||
void Server::ForwardBufferMapReadAsync(DawnBufferMapAsyncStatus status,
|
||||
const void* ptr,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata) {
|
||||
DawnCallbackUserdata userdata) {
|
||||
auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
|
||||
data->server->OnBufferMapReadAsyncCallback(status, ptr, dataLength, data);
|
||||
}
|
||||
|
||||
void Server::ForwardBufferMapWriteAsync(dawnBufferMapAsyncStatus status,
|
||||
void Server::ForwardBufferMapWriteAsync(DawnBufferMapAsyncStatus status,
|
||||
void* ptr,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata) {
|
||||
DawnCallbackUserdata userdata) {
|
||||
auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
|
||||
data->server->OnBufferMapWriteAsyncCallback(status, ptr, dataLength, data);
|
||||
}
|
||||
|
||||
void Server::OnBufferMapReadAsyncCallback(dawnBufferMapAsyncStatus status,
|
||||
void Server::OnBufferMapReadAsyncCallback(DawnBufferMapAsyncStatus status,
|
||||
const void* ptr,
|
||||
uint32_t dataLength,
|
||||
MapUserdata* userdata) {
|
||||
|
@ -137,7 +137,7 @@ namespace dawn_wire { namespace server {
|
|||
cmd.Serialize(allocatedBuffer);
|
||||
}
|
||||
|
||||
void Server::OnBufferMapWriteAsyncCallback(dawnBufferMapAsyncStatus status,
|
||||
void Server::OnBufferMapWriteAsyncCallback(DawnBufferMapAsyncStatus status,
|
||||
void* ptr,
|
||||
uint32_t dataLength,
|
||||
MapUserdata* userdata) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
namespace dawn_wire { namespace server {
|
||||
|
||||
void Server::ForwardDeviceError(const char* message, dawnCallbackUserdata userdata) {
|
||||
void Server::ForwardDeviceError(const char* message, DawnCallbackUserdata userdata) {
|
||||
auto server = reinterpret_cast<Server*>(static_cast<intptr_t>(userdata));
|
||||
server->OnDeviceError(message);
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
namespace dawn_wire { namespace server {
|
||||
|
||||
void Server::ForwardFenceCompletedValue(dawnFenceCompletionStatus status,
|
||||
dawnCallbackUserdata userdata) {
|
||||
void Server::ForwardFenceCompletedValue(DawnFenceCompletionStatus status,
|
||||
DawnCallbackUserdata userdata) {
|
||||
auto data = reinterpret_cast<FenceCompletionUserdata*>(static_cast<uintptr_t>(userdata));
|
||||
if (status == DAWN_FENCE_COMPLETION_STATUS_SUCCESS) {
|
||||
data->server->OnFenceCompletedValueUpdated(data);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
namespace dawn_wire { namespace server {
|
||||
|
||||
bool Server::DoQueueSignal(dawnQueue cSelf, dawnFence cFence, uint64_t signalValue) {
|
||||
bool Server::DoQueueSignal(DawnQueue cSelf, DawnFence cFence, uint64_t signalValue) {
|
||||
if (cFence == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -35,10 +35,10 @@ class DevNull : public dawn_wire::CommandSerializer {
|
|||
std::vector<char> buf;
|
||||
};
|
||||
|
||||
static dawnProcDeviceCreateSwapChain originalDeviceCreateSwapChain = nullptr;
|
||||
static DawnProcDeviceCreateSwapChain originalDeviceCreateSwapChain = nullptr;
|
||||
|
||||
dawnSwapChain ErrorDeviceCreateSwapChain(dawnDevice device, const dawnSwapChainDescriptor*) {
|
||||
dawnSwapChainDescriptor desc;
|
||||
DawnSwapChain ErrorDeviceCreateSwapChain(DawnDevice device, const DawnSwapChainDescriptor*) {
|
||||
DawnSwapChainDescriptor desc;
|
||||
desc.nextInChain = nullptr;
|
||||
// A 0 implementation will trigger a swapchain creation error.
|
||||
desc.implementation = 0;
|
||||
|
@ -46,7 +46,7 @@ dawnSwapChain ErrorDeviceCreateSwapChain(dawnDevice device, const dawnSwapChainD
|
|||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
dawnProcTable procs = dawn_native::GetProcs();
|
||||
DawnProcTable procs = dawn_native::GetProcs();
|
||||
|
||||
// Swapchains receive a pointer to an implementation. The fuzzer will pass garbage in so we
|
||||
// intercept calls to create swapchains and make sure they always return error swapchains.
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
#include <dawn/dawn.h>
|
||||
|
||||
// Error message (or nullptr if there was no error)
|
||||
typedef const char* dawnSwapChainError;
|
||||
constexpr dawnSwapChainError DAWN_SWAP_CHAIN_NO_ERROR = nullptr;
|
||||
typedef const char* DawnSwapChainError;
|
||||
constexpr DawnSwapChainError DAWN_SWAP_CHAIN_NO_ERROR = nullptr;
|
||||
|
||||
typedef struct {
|
||||
/// Backend-specific texture id/name/pointer
|
||||
|
@ -28,40 +28,40 @@ typedef struct {
|
|||
uint64_t u64;
|
||||
uint32_t u32;
|
||||
} texture;
|
||||
} dawnSwapChainNextTexture;
|
||||
} DawnSwapChainNextTexture;
|
||||
|
||||
typedef struct {
|
||||
/// Initialize the swap chain implementation.
|
||||
/// (*wsiContext) is one of dawnWSIContext{D3D12,Metal,GL}
|
||||
/// (*wsiContext) is one of DawnWSIContext{D3D12,Metal,GL}
|
||||
void (*Init)(void* userData, void* wsiContext);
|
||||
|
||||
/// Destroy the swap chain implementation.
|
||||
void (*Destroy)(void* userData);
|
||||
|
||||
/// Configure/reconfigure the swap chain.
|
||||
dawnSwapChainError (*Configure)(void* userData,
|
||||
dawnTextureFormat format,
|
||||
dawnTextureUsageBit allowedUsage,
|
||||
DawnSwapChainError (*Configure)(void* userData,
|
||||
DawnTextureFormat format,
|
||||
DawnTextureUsageBit allowedUsage,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
|
||||
/// Acquire the next texture from the swap chain.
|
||||
dawnSwapChainError (*GetNextTexture)(void* userData, dawnSwapChainNextTexture* nextTexture);
|
||||
DawnSwapChainError (*GetNextTexture)(void* userData, DawnSwapChainNextTexture* nextTexture);
|
||||
|
||||
/// Present the last acquired texture to the screen.
|
||||
dawnSwapChainError (*Present)(void* userData);
|
||||
DawnSwapChainError (*Present)(void* userData);
|
||||
|
||||
/// Each function is called with userData as its first argument.
|
||||
void* userData;
|
||||
|
||||
/// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
|
||||
dawnTextureUsageBit textureUsage;
|
||||
} dawnSwapChainImplementation;
|
||||
DawnTextureUsageBit textureUsage;
|
||||
} DawnSwapChainImplementation;
|
||||
|
||||
#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
|
||||
typedef struct {
|
||||
dawnDevice device = nullptr;
|
||||
} dawnWSIContextD3D12;
|
||||
DawnDevice device = nullptr;
|
||||
} DawnWSIContextD3D12;
|
||||
#endif
|
||||
|
||||
#if defined(DAWN_ENABLE_BACKEND_METAL) && defined(__OBJC__)
|
||||
|
@ -69,17 +69,17 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
id<MTLDevice> device = nil;
|
||||
} dawnWSIContextMetal;
|
||||
} DawnWSIContextMetal;
|
||||
#endif
|
||||
|
||||
#ifdef DAWN_ENABLE_BACKEND_OPENGL
|
||||
typedef struct {
|
||||
} dawnWSIContextGL;
|
||||
} DawnWSIContextGL;
|
||||
#endif
|
||||
|
||||
#ifdef DAWN_ENABLE_BACKEND_VULKAN
|
||||
typedef struct {
|
||||
} dawnWSIContextVulkan;
|
||||
} DawnWSIContextVulkan;
|
||||
#endif
|
||||
|
||||
#endif // DAWN_DAWN_WSI_H
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
#include <windows.h>
|
||||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
DAWN_NATIVE_EXPORT dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device,
|
||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(DawnDevice device,
|
||||
HWND window);
|
||||
DAWN_NATIVE_EXPORT dawnTextureFormat
|
||||
GetNativeSwapChainPreferredFormat(const dawnSwapChainImplementation* swapChain);
|
||||
DAWN_NATIVE_EXPORT DawnTextureFormat
|
||||
GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
|
||||
}} // namespace dawn_native::d3d12
|
||||
|
||||
#endif // DAWNNATIVE_D3D12BACKEND_H_
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace dawn_native {
|
|||
// Create a device on this adapter, note that the interface will change to include at least
|
||||
// a device descriptor and a pointer to backend specific options.
|
||||
// On an error, nullptr is returned.
|
||||
dawnDevice CreateDevice();
|
||||
DawnDevice CreateDevice();
|
||||
|
||||
private:
|
||||
AdapterBase* mImpl = nullptr;
|
||||
|
@ -104,7 +104,7 @@ namespace dawn_native {
|
|||
};
|
||||
|
||||
// Backend-agnostic API for dawn_native
|
||||
DAWN_NATIVE_EXPORT dawnProcTable GetProcs();
|
||||
DAWN_NATIVE_EXPORT DawnProcTable GetProcs();
|
||||
|
||||
} // namespace dawn_native
|
||||
|
||||
|
|
|
@ -33,15 +33,15 @@ typedef __IOSurface* IOSurfaceRef;
|
|||
#endif //__OBJC__
|
||||
|
||||
namespace dawn_native { namespace metal {
|
||||
DAWN_NATIVE_EXPORT dawnTexture WrapIOSurface(dawnDevice device,
|
||||
const dawnTextureDescriptor* descriptor,
|
||||
DAWN_NATIVE_EXPORT DawnTexture WrapIOSurface(DawnDevice device,
|
||||
const DawnTextureDescriptor* descriptor,
|
||||
IOSurfaceRef ioSurface,
|
||||
uint32_t plane);
|
||||
}} // namespace dawn_native::metal
|
||||
|
||||
#ifdef __OBJC__
|
||||
namespace dawn_native { namespace metal {
|
||||
DAWN_NATIVE_EXPORT id<MTLDevice> GetMetalDevice(dawnDevice device);
|
||||
DAWN_NATIVE_EXPORT id<MTLDevice> GetMetalDevice(DawnDevice device);
|
||||
}} // namespace dawn_native::metal
|
||||
#endif // __OBJC__
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <dawn_native/DawnNative.h>
|
||||
|
||||
namespace dawn_native { namespace null {
|
||||
DAWN_NATIVE_EXPORT dawnSwapChainImplementation CreateNativeSwapChainImpl();
|
||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl();
|
||||
}} // namespace dawn_native::null
|
||||
|
||||
#endif // DAWNNATIVE_NULLBACKEND_H_
|
||||
|
|
|
@ -23,12 +23,12 @@
|
|||
#include <vector>
|
||||
|
||||
namespace dawn_native { namespace vulkan {
|
||||
DAWN_NATIVE_EXPORT VkInstance GetInstance(dawnDevice device);
|
||||
DAWN_NATIVE_EXPORT VkInstance GetInstance(DawnDevice device);
|
||||
|
||||
DAWN_NATIVE_EXPORT dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device,
|
||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(DawnDevice device,
|
||||
VkSurfaceKHR surface);
|
||||
DAWN_NATIVE_EXPORT dawnTextureFormat
|
||||
GetNativeSwapChainPreferredFormat(const dawnSwapChainImplementation* swapChain);
|
||||
DAWN_NATIVE_EXPORT DawnTextureFormat
|
||||
GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
|
||||
}} // namespace dawn_native::vulkan
|
||||
|
||||
#endif // DAWNNATIVE_VULKANBACKEND_H_
|
||||
|
|
|
@ -30,8 +30,8 @@ namespace dawn_wire {
|
|||
WireClient(CommandSerializer* serializer);
|
||||
~WireClient();
|
||||
|
||||
dawnDevice GetDevice() const;
|
||||
dawnProcTable GetProcs() const;
|
||||
DawnDevice GetDevice() const;
|
||||
DawnProcTable GetProcs() const;
|
||||
const char* HandleCommands(const char* commands, size_t size) override final;
|
||||
|
||||
private:
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace dawn_wire {
|
|||
|
||||
class DAWN_WIRE_EXPORT WireServer : public CommandHandler {
|
||||
public:
|
||||
WireServer(dawnDevice device, const dawnProcTable& procs, CommandSerializer* serializer);
|
||||
WireServer(DawnDevice device, const DawnProcTable& procs, CommandSerializer* serializer);
|
||||
~WireServer();
|
||||
|
||||
const char* HandleCommands(const char* commands, size_t size) override final;
|
||||
|
|
|
@ -262,8 +262,8 @@ void DawnTest::SetUp() {
|
|||
}
|
||||
|
||||
mPCIInfo = backendAdapter.GetPCIInfo();
|
||||
dawnDevice backendDevice = backendAdapter.CreateDevice();
|
||||
dawnProcTable backendProcs = dawn_native::GetProcs();
|
||||
DawnDevice backendDevice = backendAdapter.CreateDevice();
|
||||
DawnProcTable backendProcs = dawn_native::GetProcs();
|
||||
|
||||
// Get the test window and create the device using it (esp. for OpenGL)
|
||||
GLFWwindow* testWindow = gTestEnv->GetWindowForBackend(GetParam());
|
||||
|
@ -272,8 +272,8 @@ void DawnTest::SetUp() {
|
|||
DAWN_ASSERT(mBinding != nullptr);
|
||||
|
||||
// Choose whether to use the backend procs and devices directly, or set up the wire.
|
||||
dawnDevice cDevice = nullptr;
|
||||
dawnProcTable procs;
|
||||
DawnDevice cDevice = nullptr;
|
||||
DawnProcTable procs;
|
||||
|
||||
if (gTestEnv->UseWire()) {
|
||||
mC2sBuf = std::make_unique<utils::TerribleCommandBuffer>();
|
||||
|
@ -283,8 +283,8 @@ void DawnTest::SetUp() {
|
|||
mC2sBuf->SetHandler(mWireServer.get());
|
||||
|
||||
mWireClient.reset(new dawn_wire::WireClient(mC2sBuf.get()));
|
||||
dawnDevice clientDevice = mWireClient->GetDevice();
|
||||
dawnProcTable clientProcs = mWireClient->GetProcs();
|
||||
DawnDevice clientDevice = mWireClient->GetDevice();
|
||||
DawnProcTable clientProcs = mWireClient->GetProcs();
|
||||
mS2cBuf->SetHandler(mWireClient.get());
|
||||
|
||||
procs = clientProcs;
|
||||
|
@ -310,7 +310,7 @@ void DawnTest::SetUp() {
|
|||
dawn::TextureUsageBit::OutputAttachment, 400, 400);
|
||||
|
||||
device.SetErrorCallback(OnDeviceError,
|
||||
static_cast<dawnCallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
|
||||
static_cast<DawnCallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
|
||||
}
|
||||
|
||||
void DawnTest::TearDown() {
|
||||
|
@ -334,7 +334,7 @@ bool DawnTest::EndExpectDeviceError() {
|
|||
}
|
||||
|
||||
// static
|
||||
void DawnTest::OnDeviceError(const char* message, dawnCallbackUserdata userdata) {
|
||||
void DawnTest::OnDeviceError(const char* message, DawnCallbackUserdata userdata) {
|
||||
DawnTest* self = reinterpret_cast<DawnTest*>(static_cast<uintptr_t>(userdata));
|
||||
|
||||
ASSERT_TRUE(self->mExpectError) << "Got unexpected device error: " << message;
|
||||
|
@ -481,10 +481,10 @@ void DawnTest::MapSlotsSynchronously() {
|
|||
}
|
||||
|
||||
// static
|
||||
void DawnTest::SlotMapReadCallback(dawnBufferMapAsyncStatus status,
|
||||
void DawnTest::SlotMapReadCallback(DawnBufferMapAsyncStatus status,
|
||||
const void* data,
|
||||
uint32_t,
|
||||
dawnCallbackUserdata userdata_) {
|
||||
DawnCallbackUserdata userdata_) {
|
||||
DAWN_ASSERT(status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS);
|
||||
|
||||
auto userdata = reinterpret_cast<MapReadUserdata*>(static_cast<uintptr_t>(userdata_));
|
||||
|
|
|
@ -171,7 +171,7 @@ class DawnTest : public ::testing::TestWithParam<dawn_native::BackendType> {
|
|||
void FlushWire();
|
||||
|
||||
// Tracking for validation errors
|
||||
static void OnDeviceError(const char* message, dawnCallbackUserdata userdata);
|
||||
static void OnDeviceError(const char* message, DawnCallbackUserdata userdata);
|
||||
bool mExpectError = false;
|
||||
bool mError = false;
|
||||
|
||||
|
@ -185,10 +185,10 @@ class DawnTest : public ::testing::TestWithParam<dawn_native::BackendType> {
|
|||
|
||||
// Maps all the buffers and fill ReadbackSlot::mappedData
|
||||
void MapSlotsSynchronously();
|
||||
static void SlotMapReadCallback(dawnBufferMapAsyncStatus status,
|
||||
static void SlotMapReadCallback(DawnBufferMapAsyncStatus status,
|
||||
const void* data,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata);
|
||||
DawnCallbackUserdata userdata);
|
||||
size_t mNumPendingMapOperations = 0;
|
||||
|
||||
// Reserve space where the data for an expectation can be copied
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
class BufferMapReadTests : public DawnTest {
|
||||
protected:
|
||||
static void MapReadCallback(dawnBufferMapAsyncStatus status,
|
||||
static void MapReadCallback(DawnBufferMapAsyncStatus status,
|
||||
const void* data,
|
||||
uint32_t,
|
||||
dawnCallbackUserdata userdata) {
|
||||
DawnCallbackUserdata userdata) {
|
||||
ASSERT_EQ(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
||||
ASSERT_NE(nullptr, data);
|
||||
|
||||
|
@ -85,10 +85,10 @@ DAWN_INSTANTIATE_TEST(BufferMapReadTests, D3D12Backend, MetalBackend, OpenGLBack
|
|||
|
||||
class BufferMapWriteTests : public DawnTest {
|
||||
protected:
|
||||
static void MapWriteCallback(dawnBufferMapAsyncStatus status,
|
||||
static void MapWriteCallback(DawnBufferMapAsyncStatus status,
|
||||
void* data,
|
||||
uint32_t,
|
||||
dawnCallbackUserdata userdata) {
|
||||
DawnCallbackUserdata userdata) {
|
||||
ASSERT_EQ(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
||||
ASSERT_NE(nullptr, data);
|
||||
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
|
||||
class MockFenceOnCompletionCallback {
|
||||
public:
|
||||
MOCK_METHOD2(Call, void(dawnFenceCompletionStatus status, dawnCallbackUserdata userdata));
|
||||
MOCK_METHOD2(Call, void(DawnFenceCompletionStatus status, DawnCallbackUserdata userdata));
|
||||
};
|
||||
|
||||
static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback;
|
||||
static void ToMockFenceOnCompletionCallback(dawnFenceCompletionStatus status,
|
||||
dawnCallbackUserdata userdata) {
|
||||
static void ToMockFenceOnCompletionCallback(DawnFenceCompletionStatus status,
|
||||
DawnCallbackUserdata userdata) {
|
||||
mockFenceOnCompletionCallback->Call(status, userdata);
|
||||
}
|
||||
class FenceTests : public DawnTest {
|
||||
|
@ -33,10 +33,10 @@ class FenceTests : public DawnTest {
|
|||
struct CallbackInfo {
|
||||
FenceTests* test;
|
||||
uint64_t value;
|
||||
dawnFenceCompletionStatus status;
|
||||
DawnFenceCompletionStatus status;
|
||||
int32_t callIndex = -1; // If this is -1, the callback was not called
|
||||
|
||||
void Update(dawnFenceCompletionStatus status) {
|
||||
void Update(DawnFenceCompletionStatus status) {
|
||||
this->callIndex = test->mCallIndex++;
|
||||
this->status = status;
|
||||
}
|
||||
|
@ -89,10 +89,10 @@ TEST_P(FenceTests, OnCompletionOrdering) {
|
|||
|
||||
queue.Signal(fence, 4);
|
||||
|
||||
dawnCallbackUserdata userdata0 = 1282;
|
||||
dawnCallbackUserdata userdata1 = 4382;
|
||||
dawnCallbackUserdata userdata2 = 1211;
|
||||
dawnCallbackUserdata userdata3 = 1882;
|
||||
DawnCallbackUserdata userdata0 = 1282;
|
||||
DawnCallbackUserdata userdata1 = 4382;
|
||||
DawnCallbackUserdata userdata2 = 1211;
|
||||
DawnCallbackUserdata userdata3 = 1882;
|
||||
|
||||
{
|
||||
testing::InSequence s;
|
||||
|
@ -131,7 +131,7 @@ TEST_P(FenceTests, MultipleSignalOnCompletion) {
|
|||
queue.Signal(fence, 2);
|
||||
queue.Signal(fence, 4);
|
||||
|
||||
dawnCallbackUserdata userdata = 1234;
|
||||
DawnCallbackUserdata userdata = 1234;
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata))
|
||||
.Times(1);
|
||||
|
@ -148,10 +148,10 @@ TEST_P(FenceTests, OnCompletionMultipleCallbacks) {
|
|||
|
||||
queue.Signal(fence, 4);
|
||||
|
||||
dawnCallbackUserdata userdata0 = 2341;
|
||||
dawnCallbackUserdata userdata1 = 4598;
|
||||
dawnCallbackUserdata userdata2 = 5690;
|
||||
dawnCallbackUserdata userdata3 = 2783;
|
||||
DawnCallbackUserdata userdata0 = 2341;
|
||||
DawnCallbackUserdata userdata1 = 4598;
|
||||
DawnCallbackUserdata userdata2 = 5690;
|
||||
DawnCallbackUserdata userdata3 = 2783;
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata0))
|
||||
|
@ -192,10 +192,10 @@ TEST_P(FenceTests, DISABLED_DestroyBeforeOnCompletionEnd) {
|
|||
|
||||
queue.Signal(testFence, 4);
|
||||
|
||||
dawnCallbackUserdata userdata0 = 1341;
|
||||
dawnCallbackUserdata userdata1 = 1598;
|
||||
dawnCallbackUserdata userdata2 = 1690;
|
||||
dawnCallbackUserdata userdata3 = 1783;
|
||||
DawnCallbackUserdata userdata0 = 1341;
|
||||
DawnCallbackUserdata userdata1 = 1598;
|
||||
DawnCallbackUserdata userdata2 = 1690;
|
||||
DawnCallbackUserdata userdata3 = 1783;
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, userdata0))
|
||||
|
|
|
@ -96,8 +96,8 @@ namespace {
|
|||
dawn::Texture WrapIOSurface(const dawn::TextureDescriptor* descriptor,
|
||||
IOSurfaceRef ioSurface,
|
||||
uint32_t plane) {
|
||||
dawnTexture texture = dawn_native::metal::WrapIOSurface(
|
||||
device.Get(), reinterpret_cast<const dawnTextureDescriptor*>(descriptor), ioSurface,
|
||||
DawnTexture texture = dawn_native::metal::WrapIOSurface(
|
||||
device.Get(), reinterpret_cast<const DawnTextureDescriptor*>(descriptor), ioSurface,
|
||||
plane);
|
||||
return dawn::Texture::Acquire(texture);
|
||||
}
|
||||
|
|
|
@ -23,17 +23,17 @@ using namespace testing;
|
|||
class MockBufferMapReadCallback {
|
||||
public:
|
||||
MOCK_METHOD4(Call,
|
||||
void(dawnBufferMapAsyncStatus status,
|
||||
void(DawnBufferMapAsyncStatus status,
|
||||
const uint32_t* ptr,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata));
|
||||
DawnCallbackUserdata userdata));
|
||||
};
|
||||
|
||||
static std::unique_ptr<MockBufferMapReadCallback> mockBufferMapReadCallback;
|
||||
static void ToMockBufferMapReadCallback(dawnBufferMapAsyncStatus status,
|
||||
static void ToMockBufferMapReadCallback(DawnBufferMapAsyncStatus status,
|
||||
const void* ptr,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata) {
|
||||
DawnCallbackUserdata userdata) {
|
||||
// Assume the data is uint32_t to make writing matchers easier
|
||||
mockBufferMapReadCallback->Call(status, reinterpret_cast<const uint32_t*>(ptr), dataLength,
|
||||
userdata);
|
||||
|
@ -42,17 +42,17 @@ static void ToMockBufferMapReadCallback(dawnBufferMapAsyncStatus status,
|
|||
class MockBufferMapWriteCallback {
|
||||
public:
|
||||
MOCK_METHOD4(Call,
|
||||
void(dawnBufferMapAsyncStatus status,
|
||||
void(DawnBufferMapAsyncStatus status,
|
||||
uint32_t* ptr,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata));
|
||||
DawnCallbackUserdata userdata));
|
||||
};
|
||||
|
||||
static std::unique_ptr<MockBufferMapWriteCallback> mockBufferMapWriteCallback;
|
||||
static void ToMockBufferMapWriteCallback(dawnBufferMapAsyncStatus status,
|
||||
static void ToMockBufferMapWriteCallback(DawnBufferMapAsyncStatus status,
|
||||
void* ptr,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata) {
|
||||
DawnCallbackUserdata userdata) {
|
||||
// Assume the data is uint32_t to make writing matchers easier
|
||||
mockBufferMapWriteCallback->Call(status, reinterpret_cast<uint32_t*>(ptr), dataLength,
|
||||
userdata);
|
||||
|
|
|
@ -20,30 +20,30 @@ using namespace testing;
|
|||
|
||||
class MockFenceOnCompletionCallback {
|
||||
public:
|
||||
MOCK_METHOD2(Call, void(dawnFenceCompletionStatus status, dawnCallbackUserdata userdata));
|
||||
MOCK_METHOD2(Call, void(DawnFenceCompletionStatus status, DawnCallbackUserdata userdata));
|
||||
};
|
||||
|
||||
struct FenceOnCompletionExpectation {
|
||||
dawn::Fence fence;
|
||||
uint64_t value;
|
||||
dawnFenceCompletionStatus status;
|
||||
DawnFenceCompletionStatus status;
|
||||
};
|
||||
|
||||
static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback;
|
||||
static void ToMockFenceOnCompletionCallback(dawnFenceCompletionStatus status,
|
||||
dawnCallbackUserdata userdata) {
|
||||
static void ToMockFenceOnCompletionCallback(DawnFenceCompletionStatus status,
|
||||
DawnCallbackUserdata userdata) {
|
||||
mockFenceOnCompletionCallback->Call(status, userdata);
|
||||
}
|
||||
|
||||
class FenceValidationTest : public ValidationTest {
|
||||
protected:
|
||||
void TestOnCompletion(dawn::Fence fence, uint64_t value, dawnFenceCompletionStatus status) {
|
||||
void TestOnCompletion(dawn::Fence fence, uint64_t value, DawnFenceCompletionStatus status) {
|
||||
FenceOnCompletionExpectation* expectation = new FenceOnCompletionExpectation;
|
||||
expectation->fence = fence;
|
||||
expectation->value = value;
|
||||
expectation->status = status;
|
||||
dawnCallbackUserdata userdata =
|
||||
static_cast<dawnCallbackUserdata>(reinterpret_cast<uintptr_t>(expectation));
|
||||
DawnCallbackUserdata userdata =
|
||||
static_cast<DawnCallbackUserdata>(reinterpret_cast<uintptr_t>(expectation));
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(status, userdata)).Times(1);
|
||||
fence.OnCompletion(value, ToMockFenceOnCompletionCallback, userdata);
|
||||
|
@ -135,7 +135,7 @@ TEST_F(FenceValidationTest, GetCompletedValueInsideCallback) {
|
|||
queue.Signal(fence, 3);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, 0);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, 0))
|
||||
.WillOnce(Invoke([&](dawnFenceCompletionStatus status, dawnCallbackUserdata userdata) {
|
||||
.WillOnce(Invoke([&](DawnFenceCompletionStatus status, DawnCallbackUserdata userdata) {
|
||||
EXPECT_EQ(fence.GetCompletedValue(), 3u);
|
||||
}));
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@ namespace {
|
|||
class QueueSubmitValidationTest : public ValidationTest {
|
||||
};
|
||||
|
||||
static void StoreTrueMapWriteCallback(dawnBufferMapAsyncStatus status,
|
||||
static void StoreTrueMapWriteCallback(DawnBufferMapAsyncStatus status,
|
||||
void*,
|
||||
uint32_t,
|
||||
dawnCallbackUserdata userdata) {
|
||||
DawnCallbackUserdata userdata) {
|
||||
bool* userdataPtr = reinterpret_cast<bool*>(static_cast<intptr_t>(userdata));
|
||||
*userdataPtr = true;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
|||
|
||||
// Map the buffer, submitting when the buffer is mapped should fail
|
||||
bool mapWriteFinished = false;
|
||||
dawnCallbackUserdata userdata = static_cast<dawnCallbackUserdata>(reinterpret_cast<intptr_t>(&mapWriteFinished));
|
||||
DawnCallbackUserdata userdata = static_cast<DawnCallbackUserdata>(reinterpret_cast<intptr_t>(&mapWriteFinished));
|
||||
buffer.MapWriteAsync(StoreTrueMapWriteCallback, userdata);
|
||||
queue.Submit(0, nullptr);
|
||||
ASSERT_TRUE(mapWriteFinished);
|
||||
|
|
|
@ -39,10 +39,10 @@ ValidationTest::ValidationTest() {
|
|||
ASSERT(foundNullAdapter);
|
||||
device = dawn::Device::Acquire(nullAdapter.CreateDevice());
|
||||
|
||||
dawnProcTable procs = dawn_native::GetProcs();
|
||||
DawnProcTable procs = dawn_native::GetProcs();
|
||||
dawnSetProcs(&procs);
|
||||
|
||||
device.SetErrorCallback(ValidationTest::OnDeviceError, static_cast<dawnCallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
|
||||
device.SetErrorCallback(ValidationTest::OnDeviceError, static_cast<DawnCallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
|
||||
}
|
||||
|
||||
ValidationTest::~ValidationTest() {
|
||||
|
@ -85,7 +85,7 @@ std::string ValidationTest::GetLastDeviceErrorMessage() const {
|
|||
}
|
||||
|
||||
// static
|
||||
void ValidationTest::OnDeviceError(const char* message, dawnCallbackUserdata userdata) {
|
||||
void ValidationTest::OnDeviceError(const char* message, DawnCallbackUserdata userdata) {
|
||||
auto self = reinterpret_cast<ValidationTest*>(static_cast<uintptr_t>(userdata));
|
||||
self->mDeviceErrorMessage = message;
|
||||
|
||||
|
@ -102,7 +102,7 @@ void ValidationTest::OnDeviceError(const char* message, dawnCallbackUserdata use
|
|||
}
|
||||
|
||||
// static
|
||||
void ValidationTest::OnBuilderErrorStatus(dawnBuilderErrorStatus status, const char* message, dawn::CallbackUserdata userdata1, dawn::CallbackUserdata userdata2) {
|
||||
void ValidationTest::OnBuilderErrorStatus(DawnBuilderErrorStatus status, const char* message, dawn::CallbackUserdata userdata1, dawn::CallbackUserdata userdata2) {
|
||||
auto* self = reinterpret_cast<ValidationTest*>(static_cast<uintptr_t>(userdata1));
|
||||
size_t index = static_cast<size_t>(userdata2);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class ValidationTest : public testing::Test {
|
|||
private:
|
||||
std::unique_ptr<dawn_native::Instance> mInstance;
|
||||
|
||||
static void OnDeviceError(const char* message, dawnCallbackUserdata userdata);
|
||||
static void OnDeviceError(const char* message, DawnCallbackUserdata userdata);
|
||||
std::string mDeviceErrorMessage;
|
||||
bool mExpectError = false;
|
||||
bool mError = false;
|
||||
|
@ -85,14 +85,14 @@ class ValidationTest : public testing::Test {
|
|||
|
||||
bool gotStatus = false;
|
||||
std::string statusMessage;
|
||||
dawnBuilderErrorStatus status;
|
||||
DawnBuilderErrorStatus status;
|
||||
};
|
||||
std::vector<BuilderStatusExpectations> mExpectations;
|
||||
|
||||
template<typename Builder>
|
||||
Builder AddExpectation(Builder& builder, std::string debugName, bool expectSuccess);
|
||||
|
||||
static void OnBuilderErrorStatus(dawnBuilderErrorStatus status, const char* message, dawn::CallbackUserdata userdata1, dawn::CallbackUserdata userdata2);
|
||||
static void OnBuilderErrorStatus(DawnBuilderErrorStatus status, const char* message, dawn::CallbackUserdata userdata1, dawn::CallbackUserdata userdata2);
|
||||
};
|
||||
|
||||
// Template implementation details
|
||||
|
|
|
@ -28,14 +28,14 @@ class WireArgumentTests : public WireTest {
|
|||
|
||||
// Test that the wire is able to send numerical values
|
||||
TEST_F(WireArgumentTests, ValueArgument) {
|
||||
dawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
dawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder);
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder);
|
||||
dawnComputePassEncoderDispatch(pass, 1, 2, 3);
|
||||
|
||||
dawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
|
||||
DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)).WillOnce(Return(apiEncoder));
|
||||
|
||||
dawnComputePassEncoder apiPass = api.GetNewComputePassEncoder();
|
||||
DawnComputePassEncoder apiPass = api.GetNewComputePassEncoder();
|
||||
EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder)).WillOnce(Return(apiPass));
|
||||
|
||||
EXPECT_CALL(api, ComputePassEncoderDispatch(apiPass, 1, 2, 3)).Times(1);
|
||||
|
@ -58,15 +58,15 @@ bool CheckPushConstantValues(const uint32_t* values) {
|
|||
}
|
||||
|
||||
TEST_F(WireArgumentTests, ValueArrayArgument) {
|
||||
dawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
dawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder);
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder);
|
||||
dawnComputePassEncoderSetPushConstants(pass, DAWN_SHADER_STAGE_BIT_VERTEX, 0, 4,
|
||||
testPushConstantValues);
|
||||
|
||||
dawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
|
||||
DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)).WillOnce(Return(apiEncoder));
|
||||
|
||||
dawnComputePassEncoder apiPass = api.GetNewComputePassEncoder();
|
||||
DawnComputePassEncoder apiPass = api.GetNewComputePassEncoder();
|
||||
EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder)).WillOnce(Return(apiPass));
|
||||
|
||||
EXPECT_CALL(api,
|
||||
|
@ -81,19 +81,19 @@ TEST_F(WireArgumentTests, ValueArrayArgument) {
|
|||
// Test that the wire is able to send C strings
|
||||
TEST_F(WireArgumentTests, CStringArgument) {
|
||||
// Create shader module
|
||||
dawnShaderModuleDescriptor vertexDescriptor;
|
||||
DawnShaderModuleDescriptor vertexDescriptor;
|
||||
vertexDescriptor.nextInChain = nullptr;
|
||||
vertexDescriptor.codeSize = 0;
|
||||
dawnShaderModule vsModule = dawnDeviceCreateShaderModule(device, &vertexDescriptor);
|
||||
dawnShaderModule apiVsModule = api.GetNewShaderModule();
|
||||
DawnShaderModule vsModule = dawnDeviceCreateShaderModule(device, &vertexDescriptor);
|
||||
DawnShaderModule apiVsModule = api.GetNewShaderModule();
|
||||
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
|
||||
|
||||
// Create the color state descriptor
|
||||
dawnBlendDescriptor blendDescriptor;
|
||||
DawnBlendDescriptor blendDescriptor;
|
||||
blendDescriptor.operation = DAWN_BLEND_OPERATION_ADD;
|
||||
blendDescriptor.srcFactor = DAWN_BLEND_FACTOR_ONE;
|
||||
blendDescriptor.dstFactor = DAWN_BLEND_FACTOR_ONE;
|
||||
dawnColorStateDescriptor colorStateDescriptor;
|
||||
DawnColorStateDescriptor colorStateDescriptor;
|
||||
colorStateDescriptor.nextInChain = nullptr;
|
||||
colorStateDescriptor.format = DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
|
||||
colorStateDescriptor.alphaBlend = blendDescriptor;
|
||||
|
@ -101,24 +101,24 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
|||
colorStateDescriptor.colorWriteMask = DAWN_COLOR_WRITE_MASK_ALL;
|
||||
|
||||
// Create the input state
|
||||
dawnInputStateBuilder inputStateBuilder = dawnDeviceCreateInputStateBuilder(device);
|
||||
dawnInputStateBuilder apiInputStateBuilder = api.GetNewInputStateBuilder();
|
||||
DawnInputStateBuilder inputStateBuilder = dawnDeviceCreateInputStateBuilder(device);
|
||||
DawnInputStateBuilder apiInputStateBuilder = api.GetNewInputStateBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateInputStateBuilder(apiDevice))
|
||||
.WillOnce(Return(apiInputStateBuilder));
|
||||
|
||||
dawnInputState inputState = dawnInputStateBuilderGetResult(inputStateBuilder);
|
||||
dawnInputState apiInputState = api.GetNewInputState();
|
||||
DawnInputState inputState = dawnInputStateBuilderGetResult(inputStateBuilder);
|
||||
DawnInputState apiInputState = api.GetNewInputState();
|
||||
EXPECT_CALL(api, InputStateBuilderGetResult(apiInputStateBuilder))
|
||||
.WillOnce(Return(apiInputState));
|
||||
|
||||
// Create the depth-stencil state
|
||||
dawnStencilStateFaceDescriptor stencilFace;
|
||||
DawnStencilStateFaceDescriptor stencilFace;
|
||||
stencilFace.compare = DAWN_COMPARE_FUNCTION_ALWAYS;
|
||||
stencilFace.failOp = DAWN_STENCIL_OPERATION_KEEP;
|
||||
stencilFace.depthFailOp = DAWN_STENCIL_OPERATION_KEEP;
|
||||
stencilFace.passOp = DAWN_STENCIL_OPERATION_KEEP;
|
||||
|
||||
dawnDepthStencilStateDescriptor depthStencilState;
|
||||
DawnDepthStencilStateDescriptor depthStencilState;
|
||||
depthStencilState.nextInChain = nullptr;
|
||||
depthStencilState.format = DAWN_TEXTURE_FORMAT_D32_FLOAT_S8_UINT;
|
||||
depthStencilState.depthWriteEnabled = false;
|
||||
|
@ -129,32 +129,32 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
|||
depthStencilState.stencilWriteMask = 0xff;
|
||||
|
||||
// Create the pipeline layout
|
||||
dawnPipelineLayoutDescriptor layoutDescriptor;
|
||||
DawnPipelineLayoutDescriptor layoutDescriptor;
|
||||
layoutDescriptor.nextInChain = nullptr;
|
||||
layoutDescriptor.bindGroupLayoutCount = 0;
|
||||
layoutDescriptor.bindGroupLayouts = nullptr;
|
||||
dawnPipelineLayout layout = dawnDeviceCreatePipelineLayout(device, &layoutDescriptor);
|
||||
dawnPipelineLayout apiLayout = api.GetNewPipelineLayout();
|
||||
DawnPipelineLayout layout = dawnDeviceCreatePipelineLayout(device, &layoutDescriptor);
|
||||
DawnPipelineLayout apiLayout = api.GetNewPipelineLayout();
|
||||
EXPECT_CALL(api, DeviceCreatePipelineLayout(apiDevice, _)).WillOnce(Return(apiLayout));
|
||||
|
||||
// Create pipeline
|
||||
dawnRenderPipelineDescriptor pipelineDescriptor;
|
||||
DawnRenderPipelineDescriptor pipelineDescriptor;
|
||||
pipelineDescriptor.nextInChain = nullptr;
|
||||
|
||||
dawnPipelineStageDescriptor vertexStage;
|
||||
DawnPipelineStageDescriptor vertexStage;
|
||||
vertexStage.nextInChain = nullptr;
|
||||
vertexStage.module = vsModule;
|
||||
vertexStage.entryPoint = "main";
|
||||
pipelineDescriptor.vertexStage = &vertexStage;
|
||||
|
||||
dawnPipelineStageDescriptor fragmentStage;
|
||||
DawnPipelineStageDescriptor fragmentStage;
|
||||
fragmentStage.nextInChain = nullptr;
|
||||
fragmentStage.module = vsModule;
|
||||
fragmentStage.entryPoint = "main";
|
||||
pipelineDescriptor.fragmentStage = &fragmentStage;
|
||||
|
||||
pipelineDescriptor.colorStateCount = 1;
|
||||
dawnColorStateDescriptor* colorStatesPtr[] = {&colorStateDescriptor};
|
||||
DawnColorStateDescriptor* colorStatesPtr[] = {&colorStateDescriptor};
|
||||
pipelineDescriptor.colorStates = colorStatesPtr;
|
||||
|
||||
pipelineDescriptor.sampleCount = 1;
|
||||
|
@ -167,7 +167,7 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
|||
dawnDeviceCreateRenderPipeline(device, &pipelineDescriptor);
|
||||
EXPECT_CALL(api,
|
||||
DeviceCreateRenderPipeline(
|
||||
apiDevice, MatchesLambda([](const dawnRenderPipelineDescriptor* desc) -> bool {
|
||||
apiDevice, MatchesLambda([](const DawnRenderPipelineDescriptor* desc) -> bool {
|
||||
return desc->vertexStage->entryPoint == std::string("main");
|
||||
})))
|
||||
.WillOnce(Return(nullptr));
|
||||
|
@ -182,18 +182,18 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
|||
|
||||
// Test that the wire is able to send objects as value arguments
|
||||
TEST_F(WireArgumentTests, ObjectAsValueArgument) {
|
||||
dawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device);
|
||||
dawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
|
||||
DawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)).WillOnce(Return(apiEncoder));
|
||||
|
||||
dawnBufferDescriptor descriptor;
|
||||
DawnBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.size = 8;
|
||||
descriptor.usage = static_cast<dawnBufferUsageBit>(DAWN_BUFFER_USAGE_BIT_TRANSFER_SRC |
|
||||
descriptor.usage = static_cast<DawnBufferUsageBit>(DAWN_BUFFER_USAGE_BIT_TRANSFER_SRC |
|
||||
DAWN_BUFFER_USAGE_BIT_TRANSFER_DST);
|
||||
|
||||
dawnBuffer buffer = dawnDeviceCreateBuffer(device, &descriptor);
|
||||
dawnBuffer apiBuffer = api.GetNewBuffer();
|
||||
DawnBuffer buffer = dawnDeviceCreateBuffer(device, &descriptor);
|
||||
DawnBuffer apiBuffer = api.GetNewBuffer();
|
||||
EXPECT_CALL(api, DeviceCreateBuffer(apiDevice, _))
|
||||
.WillOnce(Return(apiBuffer))
|
||||
.RetiresOnSaturation();
|
||||
|
@ -209,17 +209,17 @@ TEST_F(WireArgumentTests, ObjectAsValueArgument) {
|
|||
|
||||
// Test that the wire is able to send array of objects
|
||||
TEST_F(WireArgumentTests, ObjectsAsPointerArgument) {
|
||||
dawnCommandBuffer cmdBufs[2];
|
||||
dawnCommandBuffer apiCmdBufs[2];
|
||||
DawnCommandBuffer cmdBufs[2];
|
||||
DawnCommandBuffer apiCmdBufs[2];
|
||||
|
||||
// Create two command buffers we need to use a GMock sequence otherwise the order of the
|
||||
// CreateCommandEncoder might be swapped since they are equivalent in term of matchers
|
||||
Sequence s;
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
dawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device);
|
||||
cmdBufs[i] = dawnCommandEncoderFinish(cmdBufEncoder);
|
||||
|
||||
dawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
|
||||
.InSequence(s)
|
||||
.WillOnce(Return(apiCmdBufEncoder));
|
||||
|
@ -232,15 +232,15 @@ TEST_F(WireArgumentTests, ObjectsAsPointerArgument) {
|
|||
}
|
||||
|
||||
// Create queue
|
||||
dawnQueue queue = dawnDeviceCreateQueue(device);
|
||||
dawnQueue apiQueue = api.GetNewQueue();
|
||||
DawnQueue queue = dawnDeviceCreateQueue(device);
|
||||
DawnQueue apiQueue = api.GetNewQueue();
|
||||
EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue));
|
||||
|
||||
// Submit command buffer and check we got a call with both API-side command buffers
|
||||
dawnQueueSubmit(queue, 2, cmdBufs);
|
||||
|
||||
EXPECT_CALL(
|
||||
api, QueueSubmit(apiQueue, 2, MatchesLambda([=](const dawnCommandBuffer* cmdBufs) -> bool {
|
||||
api, QueueSubmit(apiQueue, 2, MatchesLambda([=](const DawnCommandBuffer* cmdBufs) -> bool {
|
||||
return cmdBufs[0] == apiCmdBufs[0] && cmdBufs[1] == apiCmdBufs[1];
|
||||
})));
|
||||
|
||||
|
@ -250,7 +250,7 @@ TEST_F(WireArgumentTests, ObjectsAsPointerArgument) {
|
|||
|
||||
// Test that the wire is able to send structures that contain pure values (non-objects)
|
||||
TEST_F(WireArgumentTests, StructureOfValuesArgument) {
|
||||
dawnSamplerDescriptor descriptor;
|
||||
DawnSamplerDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.magFilter = DAWN_FILTER_MODE_LINEAR;
|
||||
descriptor.minFilter = DAWN_FILTER_MODE_NEAREST;
|
||||
|
@ -265,7 +265,7 @@ TEST_F(WireArgumentTests, StructureOfValuesArgument) {
|
|||
|
||||
dawnDeviceCreateSampler(device, &descriptor);
|
||||
EXPECT_CALL(api, DeviceCreateSampler(
|
||||
apiDevice, MatchesLambda([](const dawnSamplerDescriptor* desc) -> bool {
|
||||
apiDevice, MatchesLambda([](const DawnSamplerDescriptor* desc) -> bool {
|
||||
return desc->nextInChain == nullptr &&
|
||||
desc->magFilter == DAWN_FILTER_MODE_LINEAR &&
|
||||
desc->minFilter == DAWN_FILTER_MODE_NEAREST &&
|
||||
|
@ -284,15 +284,15 @@ TEST_F(WireArgumentTests, StructureOfValuesArgument) {
|
|||
|
||||
// Test that the wire is able to send structures that contain objects
|
||||
TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
|
||||
dawnBindGroupLayoutDescriptor bglDescriptor;
|
||||
DawnBindGroupLayoutDescriptor bglDescriptor;
|
||||
bglDescriptor.bindingCount = 0;
|
||||
bglDescriptor.bindings = nullptr;
|
||||
|
||||
dawnBindGroupLayout bgl = dawnDeviceCreateBindGroupLayout(device, &bglDescriptor);
|
||||
dawnBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
|
||||
DawnBindGroupLayout bgl = dawnDeviceCreateBindGroupLayout(device, &bglDescriptor);
|
||||
DawnBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
|
||||
EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _)).WillOnce(Return(apiBgl));
|
||||
|
||||
dawnPipelineLayoutDescriptor descriptor;
|
||||
DawnPipelineLayoutDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.bindGroupLayoutCount = 1;
|
||||
descriptor.bindGroupLayouts = &bgl;
|
||||
|
@ -300,7 +300,7 @@ TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
|
|||
dawnDeviceCreatePipelineLayout(device, &descriptor);
|
||||
EXPECT_CALL(api, DeviceCreatePipelineLayout(
|
||||
apiDevice,
|
||||
MatchesLambda([apiBgl](const dawnPipelineLayoutDescriptor* desc) -> bool {
|
||||
MatchesLambda([apiBgl](const DawnPipelineLayoutDescriptor* desc) -> bool {
|
||||
return desc->nextInChain == nullptr &&
|
||||
desc->bindGroupLayoutCount == 1 &&
|
||||
desc->bindGroupLayouts[0] == apiBgl;
|
||||
|
@ -314,24 +314,24 @@ TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
|
|||
// Test that the wire is able to send structures that contain objects
|
||||
TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
|
||||
static constexpr int NUM_BINDINGS = 3;
|
||||
dawnBindGroupLayoutBinding bindings[NUM_BINDINGS]{
|
||||
DawnBindGroupLayoutBinding bindings[NUM_BINDINGS]{
|
||||
{0, DAWN_SHADER_STAGE_BIT_VERTEX, DAWN_BINDING_TYPE_SAMPLER},
|
||||
{1, DAWN_SHADER_STAGE_BIT_VERTEX, DAWN_BINDING_TYPE_SAMPLED_TEXTURE},
|
||||
{2,
|
||||
static_cast<dawnShaderStageBit>(DAWN_SHADER_STAGE_BIT_VERTEX |
|
||||
static_cast<DawnShaderStageBit>(DAWN_SHADER_STAGE_BIT_VERTEX |
|
||||
DAWN_SHADER_STAGE_BIT_FRAGMENT),
|
||||
DAWN_BINDING_TYPE_UNIFORM_BUFFER},
|
||||
};
|
||||
dawnBindGroupLayoutDescriptor bglDescriptor;
|
||||
DawnBindGroupLayoutDescriptor bglDescriptor;
|
||||
bglDescriptor.bindingCount = NUM_BINDINGS;
|
||||
bglDescriptor.bindings = bindings;
|
||||
|
||||
dawnDeviceCreateBindGroupLayout(device, &bglDescriptor);
|
||||
dawnBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
|
||||
DawnBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
|
||||
EXPECT_CALL(
|
||||
api,
|
||||
DeviceCreateBindGroupLayout(
|
||||
apiDevice, MatchesLambda([bindings](const dawnBindGroupLayoutDescriptor* desc) -> bool {
|
||||
apiDevice, MatchesLambda([bindings](const DawnBindGroupLayoutDescriptor* desc) -> bool {
|
||||
for (int i = 0; i < NUM_BINDINGS; ++i) {
|
||||
const auto& a = desc->bindings[i];
|
||||
const auto& b = bindings[i];
|
||||
|
@ -350,9 +350,9 @@ TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
|
|||
|
||||
// Test passing nullptr instead of objects - array of objects version
|
||||
TEST_F(WireArgumentTests, DISABLED_NullptrInArray) {
|
||||
dawnBindGroupLayout nullBGL = nullptr;
|
||||
DawnBindGroupLayout nullBGL = nullptr;
|
||||
|
||||
dawnPipelineLayoutDescriptor descriptor;
|
||||
DawnPipelineLayoutDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.bindGroupLayoutCount = 1;
|
||||
descriptor.bindGroupLayouts = &nullBGL;
|
||||
|
@ -360,7 +360,7 @@ TEST_F(WireArgumentTests, DISABLED_NullptrInArray) {
|
|||
dawnDeviceCreatePipelineLayout(device, &descriptor);
|
||||
EXPECT_CALL(api,
|
||||
DeviceCreatePipelineLayout(
|
||||
apiDevice, MatchesLambda([](const dawnPipelineLayoutDescriptor* desc) -> bool {
|
||||
apiDevice, MatchesLambda([](const DawnPipelineLayoutDescriptor* desc) -> bool {
|
||||
return desc->nextInChain == nullptr && desc->bindGroupLayoutCount == 1 &&
|
||||
desc->bindGroupLayouts[0] == nullptr;
|
||||
})))
|
||||
|
|
|
@ -28,7 +28,7 @@ class WireBasicTests : public WireTest {
|
|||
TEST_F(WireBasicTests, CallForwarded) {
|
||||
dawnDeviceCreateCommandEncoder(device);
|
||||
|
||||
dawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
|
||||
.WillOnce(Return(apiCmdBufEncoder));
|
||||
|
||||
|
@ -38,14 +38,14 @@ TEST_F(WireBasicTests, CallForwarded) {
|
|||
|
||||
// Test that calling methods on a new object works as expected.
|
||||
TEST_F(WireBasicTests, CreateThenCall) {
|
||||
dawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
dawnCommandEncoderFinish(encoder);
|
||||
|
||||
dawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
|
||||
.WillOnce(Return(apiCmdBufEncoder));
|
||||
|
||||
dawnCommandBuffer apiCmdBuf = api.GetNewCommandBuffer();
|
||||
DawnCommandBuffer apiCmdBuf = api.GetNewCommandBuffer();
|
||||
EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder)).WillOnce(Return(apiCmdBuf));
|
||||
|
||||
EXPECT_CALL(api, CommandEncoderRelease(apiCmdBufEncoder));
|
||||
|
@ -55,12 +55,12 @@ TEST_F(WireBasicTests, CreateThenCall) {
|
|||
|
||||
// Test that client reference/release do not call the backend API.
|
||||
TEST_F(WireBasicTests, RefCountKeptInClient) {
|
||||
dawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
|
||||
dawnCommandEncoderReference(encoder);
|
||||
dawnCommandEncoderRelease(encoder);
|
||||
|
||||
dawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
|
||||
.WillOnce(Return(apiCmdBufEncoder));
|
||||
EXPECT_CALL(api, CommandEncoderRelease(apiCmdBufEncoder));
|
||||
|
@ -70,11 +70,11 @@ TEST_F(WireBasicTests, RefCountKeptInClient) {
|
|||
|
||||
// Test that client reference/release do not call the backend API.
|
||||
TEST_F(WireBasicTests, ReleaseCalledOnRefCount0) {
|
||||
dawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
|
||||
dawnCommandEncoderRelease(encoder);
|
||||
|
||||
dawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
|
||||
.WillOnce(Return(apiCmdBufEncoder));
|
||||
|
||||
|
|
|
@ -23,17 +23,17 @@ namespace {
|
|||
class MockBufferMapReadCallback {
|
||||
public:
|
||||
MOCK_METHOD4(Call,
|
||||
void(dawnBufferMapAsyncStatus status,
|
||||
void(DawnBufferMapAsyncStatus status,
|
||||
const uint32_t* ptr,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata));
|
||||
DawnCallbackUserdata userdata));
|
||||
};
|
||||
|
||||
std::unique_ptr<MockBufferMapReadCallback> mockBufferMapReadCallback;
|
||||
void ToMockBufferMapReadCallback(dawnBufferMapAsyncStatus status,
|
||||
void ToMockBufferMapReadCallback(DawnBufferMapAsyncStatus status,
|
||||
const void* ptr,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata) {
|
||||
DawnCallbackUserdata userdata) {
|
||||
// Assume the data is uint32_t to make writing matchers easier
|
||||
mockBufferMapReadCallback->Call(status, static_cast<const uint32_t*>(ptr), dataLength,
|
||||
userdata);
|
||||
|
@ -42,18 +42,18 @@ namespace {
|
|||
class MockBufferMapWriteCallback {
|
||||
public:
|
||||
MOCK_METHOD4(Call,
|
||||
void(dawnBufferMapAsyncStatus status,
|
||||
void(DawnBufferMapAsyncStatus status,
|
||||
uint32_t* ptr,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata));
|
||||
DawnCallbackUserdata userdata));
|
||||
};
|
||||
|
||||
std::unique_ptr<MockBufferMapWriteCallback> mockBufferMapWriteCallback;
|
||||
uint32_t* lastMapWritePointer = nullptr;
|
||||
void ToMockBufferMapWriteCallback(dawnBufferMapAsyncStatus status,
|
||||
void ToMockBufferMapWriteCallback(DawnBufferMapAsyncStatus status,
|
||||
void* ptr,
|
||||
uint32_t dataLength,
|
||||
dawnCallbackUserdata userdata) {
|
||||
DawnCallbackUserdata userdata) {
|
||||
// Assume the data is uint32_t to make writing matchers easier
|
||||
lastMapWritePointer = static_cast<uint32_t*>(ptr);
|
||||
mockBufferMapWriteCallback->Call(status, lastMapWritePointer, dataLength, userdata);
|
||||
|
@ -74,7 +74,7 @@ class WireBufferMappingTests : public WireTest {
|
|||
mockBufferMapWriteCallback = std::make_unique<MockBufferMapWriteCallback>();
|
||||
|
||||
{
|
||||
dawnBufferDescriptor descriptor;
|
||||
DawnBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
|
||||
apiBuffer = api.GetNewBuffer();
|
||||
|
@ -87,7 +87,7 @@ class WireBufferMappingTests : public WireTest {
|
|||
FlushClient();
|
||||
}
|
||||
{
|
||||
dawnBufferDescriptor descriptor;
|
||||
DawnBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
|
||||
errorBuffer = dawnDeviceCreateBuffer(device, &descriptor);
|
||||
|
@ -109,18 +109,18 @@ class WireBufferMappingTests : public WireTest {
|
|||
|
||||
protected:
|
||||
// A successfully created buffer
|
||||
dawnBuffer buffer;
|
||||
dawnBuffer apiBuffer;
|
||||
DawnBuffer buffer;
|
||||
DawnBuffer apiBuffer;
|
||||
|
||||
// An buffer that wasn't created on the server side
|
||||
dawnBuffer errorBuffer;
|
||||
DawnBuffer errorBuffer;
|
||||
};
|
||||
|
||||
// MapRead-specific tests
|
||||
|
||||
// Check mapping for reading a succesfully created buffer
|
||||
TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
|
||||
dawnCallbackUserdata userdata = 8653;
|
||||
DawnCallbackUserdata userdata = 8653;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
|
@ -148,7 +148,7 @@ TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
|
|||
// Check that things work correctly when a validation error happens when mapping the buffer for
|
||||
// reading
|
||||
TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
|
||||
dawnCallbackUserdata userdata = 8654;
|
||||
DawnCallbackUserdata userdata = 8654;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||
|
@ -167,7 +167,7 @@ TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
|
|||
|
||||
// Check mapping for reading a buffer that didn't get created on the server side
|
||||
TEST_F(WireBufferMappingTests, MappingForReadErrorBuffer) {
|
||||
dawnCallbackUserdata userdata = 8655;
|
||||
DawnCallbackUserdata userdata = 8655;
|
||||
dawnBufferMapReadAsync(errorBuffer, ToMockBufferMapReadCallback, userdata);
|
||||
|
||||
FlushClient();
|
||||
|
@ -186,7 +186,7 @@ TEST_F(WireBufferMappingTests, MappingForReadErrorBuffer) {
|
|||
// Check that the map read callback is called with UNKNOWN when the buffer is destroyed before the
|
||||
// request is finished
|
||||
TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
|
||||
dawnCallbackUserdata userdata = 8656;
|
||||
DawnCallbackUserdata userdata = 8656;
|
||||
dawnBufferMapReadAsync(errorBuffer, ToMockBufferMapReadCallback, userdata);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
|
@ -199,7 +199,7 @@ TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
|
|||
// Check the map read callback is called with UNKNOWN when the map request would have worked, but
|
||||
// Unmap was called
|
||||
TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
|
||||
dawnCallbackUserdata userdata = 8657;
|
||||
DawnCallbackUserdata userdata = 8657;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
|
@ -224,7 +224,7 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
|
|||
// Check that an error map read callback gets nullptr while a buffer is already mapped
|
||||
TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullptr) {
|
||||
// Successful map
|
||||
dawnCallbackUserdata userdata = 34098;
|
||||
DawnCallbackUserdata userdata = 34098;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
|
@ -263,7 +263,7 @@ TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullp
|
|||
|
||||
// Test that the MapReadCallback isn't fired twice when unmap() is called inside the callback
|
||||
TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) {
|
||||
dawnCallbackUserdata userdata = 2039;
|
||||
DawnCallbackUserdata userdata = 2039;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
|
@ -290,7 +290,7 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) {
|
|||
// Test that the MapReadCallback isn't fired twice the buffer external refcount reaches 0 in the
|
||||
// callback
|
||||
TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) {
|
||||
dawnCallbackUserdata userdata = 2039;
|
||||
DawnCallbackUserdata userdata = 2039;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
|
@ -316,7 +316,7 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) {
|
|||
|
||||
// Check mapping for writing a succesfully created buffer
|
||||
TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
|
||||
dawnCallbackUserdata userdata = 8653;
|
||||
DawnCallbackUserdata userdata = 8653;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
|
||||
uint32_t serverBufferContent = 31337;
|
||||
|
@ -353,7 +353,7 @@ TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
|
|||
// Check that things work correctly when a validation error happens when mapping the buffer for
|
||||
// writing
|
||||
TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
|
||||
dawnCallbackUserdata userdata = 8654;
|
||||
DawnCallbackUserdata userdata = 8654;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||
|
@ -372,7 +372,7 @@ TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
|
|||
|
||||
// Check mapping for writing a buffer that didn't get created on the server side
|
||||
TEST_F(WireBufferMappingTests, MappingForWriteErrorBuffer) {
|
||||
dawnCallbackUserdata userdata = 8655;
|
||||
DawnCallbackUserdata userdata = 8655;
|
||||
dawnBufferMapWriteAsync(errorBuffer, ToMockBufferMapWriteCallback, userdata);
|
||||
|
||||
FlushClient();
|
||||
|
@ -391,7 +391,7 @@ TEST_F(WireBufferMappingTests, MappingForWriteErrorBuffer) {
|
|||
// Check that the map write callback is called with UNKNOWN when the buffer is destroyed before the
|
||||
// request is finished
|
||||
TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
|
||||
dawnCallbackUserdata userdata = 8656;
|
||||
DawnCallbackUserdata userdata = 8656;
|
||||
dawnBufferMapWriteAsync(errorBuffer, ToMockBufferMapWriteCallback, userdata);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
|
@ -404,7 +404,7 @@ TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
|
|||
// Check the map read callback is called with UNKNOWN when the map request would have worked, but
|
||||
// Unmap was called
|
||||
TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) {
|
||||
dawnCallbackUserdata userdata = 8657;
|
||||
DawnCallbackUserdata userdata = 8657;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
|
@ -429,7 +429,7 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) {
|
|||
// Check that an error map read callback gets nullptr while a buffer is already mapped
|
||||
TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullptr) {
|
||||
// Successful map
|
||||
dawnCallbackUserdata userdata = 34098;
|
||||
DawnCallbackUserdata userdata = 34098;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
|
@ -468,7 +468,7 @@ TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullp
|
|||
|
||||
// Test that the MapWriteCallback isn't fired twice when unmap() is called inside the callback
|
||||
TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) {
|
||||
dawnCallbackUserdata userdata = 2039;
|
||||
DawnCallbackUserdata userdata = 2039;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
|
@ -495,7 +495,7 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) {
|
|||
// Test that the MapWriteCallback isn't fired twice the buffer external refcount reaches 0 in the
|
||||
// callback
|
||||
TEST_F(WireBufferMappingTests, DestroyInsideMapWriteCallback) {
|
||||
dawnCallbackUserdata userdata = 2039;
|
||||
DawnCallbackUserdata userdata = 2039;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
|
|
|
@ -22,28 +22,28 @@ namespace {
|
|||
// Mock classes to add expectations on the wire calling callbacks
|
||||
class MockDeviceErrorCallback {
|
||||
public:
|
||||
MOCK_METHOD2(Call, void(const char* message, dawnCallbackUserdata userdata));
|
||||
MOCK_METHOD2(Call, void(const char* message, DawnCallbackUserdata userdata));
|
||||
};
|
||||
|
||||
std::unique_ptr<MockDeviceErrorCallback> mockDeviceErrorCallback;
|
||||
void ToMockDeviceErrorCallback(const char* message, dawnCallbackUserdata userdata) {
|
||||
void ToMockDeviceErrorCallback(const char* message, DawnCallbackUserdata userdata) {
|
||||
mockDeviceErrorCallback->Call(message, userdata);
|
||||
}
|
||||
|
||||
class MockBuilderErrorCallback {
|
||||
public:
|
||||
MOCK_METHOD4(Call,
|
||||
void(dawnBuilderErrorStatus status,
|
||||
void(DawnBuilderErrorStatus status,
|
||||
const char* message,
|
||||
dawnCallbackUserdata userdata1,
|
||||
dawnCallbackUserdata userdata2));
|
||||
DawnCallbackUserdata userdata1,
|
||||
DawnCallbackUserdata userdata2));
|
||||
};
|
||||
|
||||
std::unique_ptr<MockBuilderErrorCallback> mockBuilderErrorCallback;
|
||||
void ToMockBuilderErrorCallback(dawnBuilderErrorStatus status,
|
||||
void ToMockBuilderErrorCallback(DawnBuilderErrorStatus status,
|
||||
const char* message,
|
||||
dawnCallbackUserdata userdata1,
|
||||
dawnCallbackUserdata userdata2) {
|
||||
DawnCallbackUserdata userdata1,
|
||||
DawnCallbackUserdata userdata2) {
|
||||
mockBuilderErrorCallback->Call(status, message, userdata1, userdata2);
|
||||
}
|
||||
|
||||
|
@ -73,17 +73,17 @@ class WireCallbackTests : public WireTest {
|
|||
|
||||
// Test that we get a success builder error status when no error happens
|
||||
TEST_F(WireCallbackTests, SuccessCallbackOnBuilderSuccess) {
|
||||
dawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
DawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
dawnBufferBuilderSetErrorCallback(bufferBuilder, ToMockBuilderErrorCallback, 1, 2);
|
||||
dawnBufferBuilderGetResult(bufferBuilder);
|
||||
|
||||
dawnBufferBuilder apiBufferBuilder = api.GetNewBufferBuilder();
|
||||
DawnBufferBuilder apiBufferBuilder = api.GetNewBufferBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateBufferBuilderForTesting(apiDevice))
|
||||
.WillOnce(Return(apiBufferBuilder));
|
||||
|
||||
dawnBuffer apiBuffer = api.GetNewBuffer();
|
||||
DawnBuffer apiBuffer = api.GetNewBuffer();
|
||||
EXPECT_CALL(api, BufferBuilderGetResult(apiBufferBuilder))
|
||||
.WillOnce(InvokeWithoutArgs([&]() -> dawnBuffer {
|
||||
.WillOnce(InvokeWithoutArgs([&]() -> DawnBuffer {
|
||||
api.CallBuilderErrorCallback(apiBufferBuilder, DAWN_BUILDER_ERROR_STATUS_SUCCESS,
|
||||
"I like cheese");
|
||||
return apiBuffer;
|
||||
|
@ -103,7 +103,7 @@ TEST_F(WireCallbackTests, SuccessCallbackOnBuilderSuccess) {
|
|||
TEST_F(WireCallbackTests, UnknownBuilderErrorStatusCallback) {
|
||||
// The builder is destroyed before the object is built
|
||||
{
|
||||
dawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
DawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
dawnBufferBuilderSetErrorCallback(bufferBuilder, ToMockBuilderErrorCallback, 1, 2);
|
||||
|
||||
EXPECT_CALL(*mockBuilderErrorCallback, Call(DAWN_BUILDER_ERROR_STATUS_UNKNOWN, _, 1, 2))
|
||||
|
@ -114,7 +114,7 @@ TEST_F(WireCallbackTests, UnknownBuilderErrorStatusCallback) {
|
|||
|
||||
// If the builder has been consumed, it doesn't fire the callback with unknown
|
||||
{
|
||||
dawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
DawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
dawnBufferBuilderSetErrorCallback(bufferBuilder, ToMockBuilderErrorCallback, 3, 4);
|
||||
dawnBufferBuilderGetResult(bufferBuilder);
|
||||
|
||||
|
@ -127,9 +127,9 @@ TEST_F(WireCallbackTests, UnknownBuilderErrorStatusCallback) {
|
|||
// If the builder has been consumed, and the object is destroyed before the result comes from
|
||||
// the server, then the callback is fired with unknown
|
||||
{
|
||||
dawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
DawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
dawnBufferBuilderSetErrorCallback(bufferBuilder, ToMockBuilderErrorCallback, 5, 6);
|
||||
dawnBuffer buffer = dawnBufferBuilderGetResult(bufferBuilder);
|
||||
DawnBuffer buffer = dawnBufferBuilderGetResult(bufferBuilder);
|
||||
|
||||
EXPECT_CALL(*mockBuilderErrorCallback, Call(DAWN_BUILDER_ERROR_STATUS_UNKNOWN, _, 5, 6))
|
||||
.Times(1);
|
||||
|
@ -142,16 +142,16 @@ TEST_F(WireCallbackTests, UnknownBuilderErrorStatusCallback) {
|
|||
TEST_F(WireCallbackTests, SuccessCallbackNotForwardedToDevice) {
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, 0);
|
||||
|
||||
dawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
DawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
dawnBufferBuilderGetResult(bufferBuilder);
|
||||
|
||||
dawnBufferBuilder apiBufferBuilder = api.GetNewBufferBuilder();
|
||||
DawnBufferBuilder apiBufferBuilder = api.GetNewBufferBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateBufferBuilderForTesting(apiDevice))
|
||||
.WillOnce(Return(apiBufferBuilder));
|
||||
|
||||
dawnBuffer apiBuffer = api.GetNewBuffer();
|
||||
DawnBuffer apiBuffer = api.GetNewBuffer();
|
||||
EXPECT_CALL(api, BufferBuilderGetResult(apiBufferBuilder))
|
||||
.WillOnce(InvokeWithoutArgs([&]() -> dawnBuffer {
|
||||
.WillOnce(InvokeWithoutArgs([&]() -> DawnBuffer {
|
||||
api.CallBuilderErrorCallback(apiBufferBuilder, DAWN_BUILDER_ERROR_STATUS_SUCCESS,
|
||||
"I like cheese");
|
||||
return apiBuffer;
|
||||
|
@ -168,15 +168,15 @@ TEST_F(WireCallbackTests, ErrorCallbackForwardedToDevice) {
|
|||
uint64_t userdata = 30495;
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, userdata);
|
||||
|
||||
dawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
DawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
dawnBufferBuilderGetResult(bufferBuilder);
|
||||
|
||||
dawnBufferBuilder apiBufferBuilder = api.GetNewBufferBuilder();
|
||||
DawnBufferBuilder apiBufferBuilder = api.GetNewBufferBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateBufferBuilderForTesting(apiDevice))
|
||||
.WillOnce(Return(apiBufferBuilder));
|
||||
|
||||
EXPECT_CALL(api, BufferBuilderGetResult(apiBufferBuilder))
|
||||
.WillOnce(InvokeWithoutArgs([&]() -> dawnBuffer {
|
||||
.WillOnce(InvokeWithoutArgs([&]() -> DawnBuffer {
|
||||
api.CallBuilderErrorCallback(apiBufferBuilder, DAWN_BUILDER_ERROR_STATUS_ERROR,
|
||||
"Error :(");
|
||||
return nullptr;
|
||||
|
@ -213,9 +213,9 @@ TEST_F(WireCallbackTests, BuilderErrorCallback) {
|
|||
uint64_t userdata2 = 982734239028;
|
||||
|
||||
// Create the buffer builder, the callback is set immediately on the server side
|
||||
dawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
DawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
|
||||
dawnBufferBuilder apiBufferBuilder = api.GetNewBufferBuilder();
|
||||
DawnBufferBuilder apiBufferBuilder = api.GetNewBufferBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateBufferBuilderForTesting(apiDevice))
|
||||
.WillOnce(Return(apiBufferBuilder));
|
||||
|
||||
|
@ -231,9 +231,9 @@ TEST_F(WireCallbackTests, BuilderErrorCallback) {
|
|||
// Create an object so that it is a valid case to call the error callback
|
||||
dawnBufferBuilderGetResult(bufferBuilder);
|
||||
|
||||
dawnBuffer apiBuffer = api.GetNewBuffer();
|
||||
DawnBuffer apiBuffer = api.GetNewBuffer();
|
||||
EXPECT_CALL(api, BufferBuilderGetResult(apiBufferBuilder))
|
||||
.WillOnce(InvokeWithoutArgs([&]() -> dawnBuffer {
|
||||
.WillOnce(InvokeWithoutArgs([&]() -> DawnBuffer {
|
||||
api.CallBuilderErrorCallback(apiBufferBuilder, DAWN_BUILDER_ERROR_STATUS_SUCCESS,
|
||||
"Success!");
|
||||
return apiBuffer;
|
||||
|
|
|
@ -22,22 +22,22 @@ namespace {
|
|||
// Mock classes to add expectations on the wire calling callbacks
|
||||
class MockDeviceErrorCallback {
|
||||
public:
|
||||
MOCK_METHOD2(Call, void(const char* message, dawnCallbackUserdata userdata));
|
||||
MOCK_METHOD2(Call, void(const char* message, DawnCallbackUserdata userdata));
|
||||
};
|
||||
|
||||
std::unique_ptr<MockDeviceErrorCallback> mockDeviceErrorCallback;
|
||||
void ToMockDeviceErrorCallback(const char* message, dawnCallbackUserdata userdata) {
|
||||
void ToMockDeviceErrorCallback(const char* message, DawnCallbackUserdata userdata) {
|
||||
mockDeviceErrorCallback->Call(message, userdata);
|
||||
}
|
||||
|
||||
class MockFenceOnCompletionCallback {
|
||||
public:
|
||||
MOCK_METHOD2(Call, void(dawnFenceCompletionStatus status, dawnCallbackUserdata userdata));
|
||||
MOCK_METHOD2(Call, void(DawnFenceCompletionStatus status, DawnCallbackUserdata userdata));
|
||||
};
|
||||
|
||||
std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback;
|
||||
void ToMockFenceOnCompletionCallback(dawnFenceCompletionStatus status,
|
||||
dawnCallbackUserdata userdata) {
|
||||
void ToMockFenceOnCompletionCallback(DawnFenceCompletionStatus status,
|
||||
DawnCallbackUserdata userdata) {
|
||||
mockFenceOnCompletionCallback->Call(status, userdata);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ class WireFenceTests : public WireTest {
|
|||
FlushClient();
|
||||
}
|
||||
{
|
||||
dawnFenceDescriptor descriptor;
|
||||
DawnFenceDescriptor descriptor;
|
||||
descriptor.initialValue = 1;
|
||||
descriptor.nextInChain = nullptr;
|
||||
|
||||
|
@ -98,11 +98,11 @@ class WireFenceTests : public WireTest {
|
|||
}
|
||||
|
||||
// A successfully created fence
|
||||
dawnFence fence;
|
||||
dawnFence apiFence;
|
||||
DawnFence fence;
|
||||
DawnFence apiFence;
|
||||
|
||||
dawnQueue queue;
|
||||
dawnQueue apiQueue;
|
||||
DawnQueue queue;
|
||||
DawnQueue apiQueue;
|
||||
};
|
||||
|
||||
// Check that signaling a fence succeeds
|
||||
|
@ -116,7 +116,7 @@ TEST_F(WireFenceTests, QueueSignalSuccess) {
|
|||
// Without any flushes, it is valid to signal a value greater than the current
|
||||
// signaled value
|
||||
TEST_F(WireFenceTests, QueueSignalSynchronousValidationSuccess) {
|
||||
dawnCallbackUserdata userdata = 9157;
|
||||
DawnCallbackUserdata userdata = 9157;
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, userdata);
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, userdata)).Times(0);
|
||||
|
||||
|
@ -128,7 +128,7 @@ TEST_F(WireFenceTests, QueueSignalSynchronousValidationSuccess) {
|
|||
// Without any flushes, errors should be generated when signaling a value less
|
||||
// than or equal to the current signaled value
|
||||
TEST_F(WireFenceTests, QueueSignalSynchronousValidationError) {
|
||||
dawnCallbackUserdata userdata = 3157;
|
||||
DawnCallbackUserdata userdata = 3157;
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, userdata);
|
||||
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, userdata)).Times(1);
|
||||
|
@ -152,7 +152,7 @@ TEST_F(WireFenceTests, QueueSignalSynchronousValidationError) {
|
|||
TEST_F(WireFenceTests, OnCompletionImmediate) {
|
||||
// Can call on value < (initial) signaled value happens immediately
|
||||
{
|
||||
dawnCallbackUserdata userdata = 9847;
|
||||
DawnCallbackUserdata userdata = 9847;
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata))
|
||||
.Times(1);
|
||||
|
@ -161,7 +161,7 @@ TEST_F(WireFenceTests, OnCompletionImmediate) {
|
|||
|
||||
// Can call on value == (initial) signaled value happens immediately
|
||||
{
|
||||
dawnCallbackUserdata userdata = 4347;
|
||||
DawnCallbackUserdata userdata = 4347;
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata))
|
||||
.Times(1);
|
||||
|
@ -174,10 +174,10 @@ TEST_F(WireFenceTests, OnCompletionMultiple) {
|
|||
DoQueueSignal(3u);
|
||||
DoQueueSignal(6u);
|
||||
|
||||
dawnCallbackUserdata userdata0 = 2134;
|
||||
dawnCallbackUserdata userdata1 = 7134;
|
||||
dawnCallbackUserdata userdata2 = 3144;
|
||||
dawnCallbackUserdata userdata3 = 1130;
|
||||
DawnCallbackUserdata userdata0 = 2134;
|
||||
DawnCallbackUserdata userdata1 = 7134;
|
||||
DawnCallbackUserdata userdata2 = 3144;
|
||||
DawnCallbackUserdata userdata3 = 1130;
|
||||
|
||||
// Add callbacks in a non-monotonic order. They should still be called
|
||||
// in order of increasing fence value.
|
||||
|
@ -221,8 +221,8 @@ TEST_F(WireFenceTests, OnCompletionSynchronousValidationSuccess) {
|
|||
// Without any flushes, errors should be generated when waiting on a value greater
|
||||
// than the last signaled value
|
||||
TEST_F(WireFenceTests, OnCompletionSynchronousValidationError) {
|
||||
dawnCallbackUserdata userdata1 = 3817;
|
||||
dawnCallbackUserdata userdata2 = 3857;
|
||||
DawnCallbackUserdata userdata1 = 3817;
|
||||
DawnCallbackUserdata userdata2 = 3857;
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, userdata2);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_ERROR, userdata1))
|
||||
|
@ -255,7 +255,7 @@ TEST_F(WireFenceTests, GetCompletedValueNoUpdate) {
|
|||
// Check that the callback is called with UNKNOWN when the fence is destroyed
|
||||
// before the completed value is updated
|
||||
TEST_F(WireFenceTests, DestroyBeforeOnCompletionEnd) {
|
||||
dawnCallbackUserdata userdata = 8616;
|
||||
DawnCallbackUserdata userdata = 8616;
|
||||
dawnQueueSignal(queue, fence, 3u);
|
||||
dawnFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, userdata);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
|
@ -267,13 +267,13 @@ TEST_F(WireFenceTests, DestroyBeforeOnCompletionEnd) {
|
|||
|
||||
// Test that signaling a fence on a wrong queue is invalid
|
||||
TEST_F(WireFenceTests, SignalWrongQueue) {
|
||||
dawnQueue queue2 = dawnDeviceCreateQueue(device);
|
||||
dawnQueue apiQueue2 = api.GetNewQueue();
|
||||
DawnQueue queue2 = dawnDeviceCreateQueue(device);
|
||||
DawnQueue apiQueue2 = api.GetNewQueue();
|
||||
EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue2));
|
||||
EXPECT_CALL(api, QueueRelease(apiQueue2));
|
||||
FlushClient();
|
||||
|
||||
dawnCallbackUserdata userdata = 1520;
|
||||
DawnCallbackUserdata userdata = 1520;
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, userdata);
|
||||
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, userdata)).Times(1);
|
||||
|
@ -282,13 +282,13 @@ TEST_F(WireFenceTests, SignalWrongQueue) {
|
|||
|
||||
// Test that signaling a fence on a wrong queue does not update fence signaled value
|
||||
TEST_F(WireFenceTests, SignalWrongQueueDoesNotUpdateValue) {
|
||||
dawnQueue queue2 = dawnDeviceCreateQueue(device);
|
||||
dawnQueue apiQueue2 = api.GetNewQueue();
|
||||
DawnQueue queue2 = dawnDeviceCreateQueue(device);
|
||||
DawnQueue apiQueue2 = api.GetNewQueue();
|
||||
EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue2));
|
||||
EXPECT_CALL(api, QueueRelease(apiQueue2));
|
||||
FlushClient();
|
||||
|
||||
dawnCallbackUserdata userdata = 1024;
|
||||
DawnCallbackUserdata userdata = 1024;
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, userdata);
|
||||
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, userdata)).Times(1);
|
||||
|
|
|
@ -26,23 +26,23 @@ class WireOptionalTests : public WireTest {
|
|||
|
||||
// Test passing nullptr instead of objects - object as value version
|
||||
TEST_F(WireOptionalTests, OptionalObjectValue) {
|
||||
dawnBindGroupLayoutDescriptor bglDesc;
|
||||
DawnBindGroupLayoutDescriptor bglDesc;
|
||||
bglDesc.nextInChain = nullptr;
|
||||
bglDesc.bindingCount = 0;
|
||||
dawnBindGroupLayout bgl = dawnDeviceCreateBindGroupLayout(device, &bglDesc);
|
||||
DawnBindGroupLayout bgl = dawnDeviceCreateBindGroupLayout(device, &bglDesc);
|
||||
|
||||
dawnBindGroupLayout apiBindGroupLayout = api.GetNewBindGroupLayout();
|
||||
DawnBindGroupLayout apiBindGroupLayout = api.GetNewBindGroupLayout();
|
||||
EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _))
|
||||
.WillOnce(Return(apiBindGroupLayout));
|
||||
|
||||
// The `sampler`, `textureView` and `buffer` members of a binding are optional.
|
||||
dawnBindGroupBinding binding;
|
||||
DawnBindGroupBinding binding;
|
||||
binding.binding = 0;
|
||||
binding.sampler = nullptr;
|
||||
binding.textureView = nullptr;
|
||||
binding.buffer = nullptr;
|
||||
|
||||
dawnBindGroupDescriptor bgDesc;
|
||||
DawnBindGroupDescriptor bgDesc;
|
||||
bgDesc.nextInChain = nullptr;
|
||||
bgDesc.layout = bgl;
|
||||
bgDesc.bindingCount = 1;
|
||||
|
@ -50,7 +50,7 @@ TEST_F(WireOptionalTests, OptionalObjectValue) {
|
|||
|
||||
dawnDeviceCreateBindGroup(device, &bgDesc);
|
||||
EXPECT_CALL(api, DeviceCreateBindGroup(
|
||||
apiDevice, MatchesLambda([](const dawnBindGroupDescriptor* desc) -> bool {
|
||||
apiDevice, MatchesLambda([](const DawnBindGroupDescriptor* desc) -> bool {
|
||||
return desc->nextInChain == nullptr && desc->bindingCount == 1 &&
|
||||
desc->bindings[0].binding == 0 &&
|
||||
desc->bindings[0].sampler == nullptr &&
|
||||
|
@ -66,19 +66,19 @@ TEST_F(WireOptionalTests, OptionalObjectValue) {
|
|||
// Test that the wire is able to send optional pointers to structures
|
||||
TEST_F(WireOptionalTests, OptionalStructPointer) {
|
||||
// Create shader module
|
||||
dawnShaderModuleDescriptor vertexDescriptor;
|
||||
DawnShaderModuleDescriptor vertexDescriptor;
|
||||
vertexDescriptor.nextInChain = nullptr;
|
||||
vertexDescriptor.codeSize = 0;
|
||||
dawnShaderModule vsModule = dawnDeviceCreateShaderModule(device, &vertexDescriptor);
|
||||
dawnShaderModule apiVsModule = api.GetNewShaderModule();
|
||||
DawnShaderModule vsModule = dawnDeviceCreateShaderModule(device, &vertexDescriptor);
|
||||
DawnShaderModule apiVsModule = api.GetNewShaderModule();
|
||||
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
|
||||
|
||||
// Create the color state descriptor
|
||||
dawnBlendDescriptor blendDescriptor;
|
||||
DawnBlendDescriptor blendDescriptor;
|
||||
blendDescriptor.operation = DAWN_BLEND_OPERATION_ADD;
|
||||
blendDescriptor.srcFactor = DAWN_BLEND_FACTOR_ONE;
|
||||
blendDescriptor.dstFactor = DAWN_BLEND_FACTOR_ONE;
|
||||
dawnColorStateDescriptor colorStateDescriptor;
|
||||
DawnColorStateDescriptor colorStateDescriptor;
|
||||
colorStateDescriptor.nextInChain = nullptr;
|
||||
colorStateDescriptor.format = DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
|
||||
colorStateDescriptor.alphaBlend = blendDescriptor;
|
||||
|
@ -86,24 +86,24 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
|
|||
colorStateDescriptor.colorWriteMask = DAWN_COLOR_WRITE_MASK_ALL;
|
||||
|
||||
// Create the input state
|
||||
dawnInputStateBuilder inputStateBuilder = dawnDeviceCreateInputStateBuilder(device);
|
||||
dawnInputStateBuilder apiInputStateBuilder = api.GetNewInputStateBuilder();
|
||||
DawnInputStateBuilder inputStateBuilder = dawnDeviceCreateInputStateBuilder(device);
|
||||
DawnInputStateBuilder apiInputStateBuilder = api.GetNewInputStateBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateInputStateBuilder(apiDevice))
|
||||
.WillOnce(Return(apiInputStateBuilder));
|
||||
|
||||
dawnInputState inputState = dawnInputStateBuilderGetResult(inputStateBuilder);
|
||||
dawnInputState apiInputState = api.GetNewInputState();
|
||||
DawnInputState inputState = dawnInputStateBuilderGetResult(inputStateBuilder);
|
||||
DawnInputState apiInputState = api.GetNewInputState();
|
||||
EXPECT_CALL(api, InputStateBuilderGetResult(apiInputStateBuilder))
|
||||
.WillOnce(Return(apiInputState));
|
||||
|
||||
// Create the depth-stencil state
|
||||
dawnStencilStateFaceDescriptor stencilFace;
|
||||
DawnStencilStateFaceDescriptor stencilFace;
|
||||
stencilFace.compare = DAWN_COMPARE_FUNCTION_ALWAYS;
|
||||
stencilFace.failOp = DAWN_STENCIL_OPERATION_KEEP;
|
||||
stencilFace.depthFailOp = DAWN_STENCIL_OPERATION_KEEP;
|
||||
stencilFace.passOp = DAWN_STENCIL_OPERATION_KEEP;
|
||||
|
||||
dawnDepthStencilStateDescriptor depthStencilState;
|
||||
DawnDepthStencilStateDescriptor depthStencilState;
|
||||
depthStencilState.nextInChain = nullptr;
|
||||
depthStencilState.format = DAWN_TEXTURE_FORMAT_D32_FLOAT_S8_UINT;
|
||||
depthStencilState.depthWriteEnabled = false;
|
||||
|
@ -114,32 +114,32 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
|
|||
depthStencilState.stencilWriteMask = 0xff;
|
||||
|
||||
// Create the pipeline layout
|
||||
dawnPipelineLayoutDescriptor layoutDescriptor;
|
||||
DawnPipelineLayoutDescriptor layoutDescriptor;
|
||||
layoutDescriptor.nextInChain = nullptr;
|
||||
layoutDescriptor.bindGroupLayoutCount = 0;
|
||||
layoutDescriptor.bindGroupLayouts = nullptr;
|
||||
dawnPipelineLayout layout = dawnDeviceCreatePipelineLayout(device, &layoutDescriptor);
|
||||
dawnPipelineLayout apiLayout = api.GetNewPipelineLayout();
|
||||
DawnPipelineLayout layout = dawnDeviceCreatePipelineLayout(device, &layoutDescriptor);
|
||||
DawnPipelineLayout apiLayout = api.GetNewPipelineLayout();
|
||||
EXPECT_CALL(api, DeviceCreatePipelineLayout(apiDevice, _)).WillOnce(Return(apiLayout));
|
||||
|
||||
// Create pipeline
|
||||
dawnRenderPipelineDescriptor pipelineDescriptor;
|
||||
DawnRenderPipelineDescriptor pipelineDescriptor;
|
||||
pipelineDescriptor.nextInChain = nullptr;
|
||||
|
||||
dawnPipelineStageDescriptor vertexStage;
|
||||
DawnPipelineStageDescriptor vertexStage;
|
||||
vertexStage.nextInChain = nullptr;
|
||||
vertexStage.module = vsModule;
|
||||
vertexStage.entryPoint = "main";
|
||||
pipelineDescriptor.vertexStage = &vertexStage;
|
||||
|
||||
dawnPipelineStageDescriptor fragmentStage;
|
||||
DawnPipelineStageDescriptor fragmentStage;
|
||||
fragmentStage.nextInChain = nullptr;
|
||||
fragmentStage.module = vsModule;
|
||||
fragmentStage.entryPoint = "main";
|
||||
pipelineDescriptor.fragmentStage = &fragmentStage;
|
||||
|
||||
pipelineDescriptor.colorStateCount = 1;
|
||||
dawnColorStateDescriptor* colorStatesPtr[] = {&colorStateDescriptor};
|
||||
DawnColorStateDescriptor* colorStatesPtr[] = {&colorStateDescriptor};
|
||||
pipelineDescriptor.colorStates = colorStatesPtr;
|
||||
|
||||
pipelineDescriptor.sampleCount = 1;
|
||||
|
@ -154,7 +154,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
|
|||
EXPECT_CALL(
|
||||
api,
|
||||
DeviceCreateRenderPipeline(
|
||||
apiDevice, MatchesLambda([](const dawnRenderPipelineDescriptor* desc) -> bool {
|
||||
apiDevice, MatchesLambda([](const DawnRenderPipelineDescriptor* desc) -> bool {
|
||||
return desc->depthStencilState != nullptr &&
|
||||
desc->depthStencilState->nextInChain == nullptr &&
|
||||
desc->depthStencilState->depthWriteEnabled == false &&
|
||||
|
@ -185,7 +185,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
|
|||
dawnDeviceCreateRenderPipeline(device, &pipelineDescriptor);
|
||||
EXPECT_CALL(api,
|
||||
DeviceCreateRenderPipeline(
|
||||
apiDevice, MatchesLambda([](const dawnRenderPipelineDescriptor* desc) -> bool {
|
||||
apiDevice, MatchesLambda([](const DawnRenderPipelineDescriptor* desc) -> bool {
|
||||
return desc->depthStencilState == nullptr;
|
||||
})))
|
||||
.WillOnce(Return(nullptr));
|
||||
|
|
|
@ -28,8 +28,8 @@ WireTest::~WireTest() {
|
|||
}
|
||||
|
||||
void WireTest::SetUp() {
|
||||
dawnProcTable mockProcs;
|
||||
dawnDevice mockDevice;
|
||||
DawnProcTable mockProcs;
|
||||
DawnDevice mockDevice;
|
||||
api.GetProcTableAndDevice(&mockProcs, &mockDevice);
|
||||
|
||||
// This SetCallback call cannot be ignored because it is done as soon as we start the server
|
||||
|
@ -49,7 +49,7 @@ void WireTest::SetUp() {
|
|||
mS2cBuf->SetHandler(mWireClient.get());
|
||||
|
||||
device = mWireClient->GetDevice();
|
||||
dawnProcTable clientProcs = mWireClient->GetProcs();
|
||||
DawnProcTable clientProcs = mWireClient->GetProcs();
|
||||
dawnSetProcs(&clientProcs);
|
||||
|
||||
apiDevice = mockDevice;
|
||||
|
|
|
@ -86,8 +86,8 @@ class WireTest : public testing::Test {
|
|||
void FlushServer();
|
||||
|
||||
MockProcTable api;
|
||||
dawnDevice apiDevice;
|
||||
dawnDevice device;
|
||||
DawnDevice apiDevice;
|
||||
DawnDevice device;
|
||||
|
||||
private:
|
||||
bool mIgnoreSetCallbackCalls = false;
|
||||
|
|
|
@ -25,22 +25,22 @@
|
|||
namespace utils {
|
||||
|
||||
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||
BackendBinding* CreateD3D12Binding(GLFWwindow* window, dawnDevice device);
|
||||
BackendBinding* CreateD3D12Binding(GLFWwindow* window, DawnDevice device);
|
||||
#endif
|
||||
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
||||
BackendBinding* CreateMetalBinding(GLFWwindow* window, dawnDevice device);
|
||||
BackendBinding* CreateMetalBinding(GLFWwindow* window, DawnDevice device);
|
||||
#endif
|
||||
#if defined(DAWN_ENABLE_BACKEND_NULL)
|
||||
BackendBinding* CreateNullBinding(GLFWwindow* window, dawnDevice device);
|
||||
BackendBinding* CreateNullBinding(GLFWwindow* window, DawnDevice device);
|
||||
#endif
|
||||
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, dawnDevice device);
|
||||
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, DawnDevice device);
|
||||
#endif
|
||||
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
|
||||
BackendBinding* CreateVulkanBinding(GLFWwindow* window, dawnDevice device);
|
||||
BackendBinding* CreateVulkanBinding(GLFWwindow* window, DawnDevice device);
|
||||
#endif
|
||||
|
||||
BackendBinding::BackendBinding(GLFWwindow* window, dawnDevice device)
|
||||
BackendBinding::BackendBinding(GLFWwindow* window, DawnDevice device)
|
||||
: mWindow(window), mDevice(device) {
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ namespace utils {
|
|||
|
||||
BackendBinding* CreateBinding(dawn_native::BackendType type,
|
||||
GLFWwindow* window,
|
||||
dawnDevice device) {
|
||||
DawnDevice device) {
|
||||
switch (type) {
|
||||
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||
case dawn_native::BackendType::D3D12:
|
||||
|
|
|
@ -27,13 +27,13 @@ namespace utils {
|
|||
virtual ~BackendBinding() = default;
|
||||
|
||||
virtual uint64_t GetSwapChainImplementation() = 0;
|
||||
virtual dawnTextureFormat GetPreferredSwapChainTextureFormat() = 0;
|
||||
virtual DawnTextureFormat GetPreferredSwapChainTextureFormat() = 0;
|
||||
|
||||
protected:
|
||||
BackendBinding(GLFWwindow* window, dawnDevice device);
|
||||
BackendBinding(GLFWwindow* window, DawnDevice device);
|
||||
|
||||
GLFWwindow* mWindow = nullptr;
|
||||
dawnDevice mDevice = nullptr;
|
||||
DawnDevice mDevice = nullptr;
|
||||
};
|
||||
|
||||
void SetupGLFWWindowHintsForBackend(dawn_native::BackendType type);
|
||||
|
@ -42,7 +42,7 @@ namespace utils {
|
|||
dawn_native::BackendType type);
|
||||
BackendBinding* CreateBinding(dawn_native::BackendType type,
|
||||
GLFWwindow* window,
|
||||
dawnDevice device);
|
||||
DawnDevice device);
|
||||
|
||||
} // namespace utils
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace utils {
|
|||
|
||||
class D3D12Binding : public BackendBinding {
|
||||
public:
|
||||
D3D12Binding(GLFWwindow* window, dawnDevice device) : BackendBinding(window, device) {
|
||||
D3D12Binding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
|
||||
}
|
||||
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
|
@ -39,16 +39,16 @@ namespace utils {
|
|||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||
}
|
||||
|
||||
dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||
ASSERT(mSwapchainImpl.userData != nullptr);
|
||||
return dawn_native::d3d12::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
|
||||
}
|
||||
|
||||
private:
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
DawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
BackendBinding* CreateD3D12Binding(GLFWwindow* window, dawnDevice device) {
|
||||
BackendBinding* CreateD3D12Binding(GLFWwindow* window, DawnDevice device) {
|
||||
return new D3D12Binding(window, device);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
namespace utils {
|
||||
class SwapChainImplMTL {
|
||||
public:
|
||||
using WSIContext = dawnWSIContextMetal;
|
||||
using WSIContext = DawnWSIContextMetal;
|
||||
|
||||
SwapChainImplMTL(id nsWindow) : mNsWindow(nsWindow) {
|
||||
}
|
||||
|
@ -37,13 +37,13 @@ namespace utils {
|
|||
[mCurrentDrawable release];
|
||||
}
|
||||
|
||||
void Init(dawnWSIContextMetal* ctx) {
|
||||
void Init(DawnWSIContextMetal* ctx) {
|
||||
mMtlDevice = ctx->device;
|
||||
mCommandQueue = [mMtlDevice newCommandQueue];
|
||||
}
|
||||
|
||||
dawnSwapChainError Configure(dawnTextureFormat format,
|
||||
dawnTextureUsageBit usage,
|
||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||
DawnTextureUsageBit usage,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
if (format != DAWN_TEXTURE_FORMAT_B8_G8_R8_A8_UNORM) {
|
||||
|
@ -76,7 +76,7 @@ namespace utils {
|
|||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture) {
|
||||
[mCurrentDrawable release];
|
||||
mCurrentDrawable = [mLayer nextDrawable];
|
||||
[mCurrentDrawable retain];
|
||||
|
@ -90,7 +90,7 @@ namespace utils {
|
|||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawnSwapChainError Present() {
|
||||
DawnSwapChainError Present() {
|
||||
id<MTLCommandBuffer> commandBuffer = [mCommandQueue commandBuffer];
|
||||
[commandBuffer presentDrawable:mCurrentDrawable];
|
||||
[commandBuffer commit];
|
||||
|
@ -110,7 +110,7 @@ namespace utils {
|
|||
|
||||
class MetalBinding : public BackendBinding {
|
||||
public:
|
||||
MetalBinding(GLFWwindow* window, dawnDevice device) : BackendBinding(window, device) {
|
||||
MetalBinding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
|
||||
}
|
||||
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
|
@ -121,15 +121,15 @@ namespace utils {
|
|||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||
}
|
||||
|
||||
dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||
return DAWN_TEXTURE_FORMAT_B8_G8_R8_A8_UNORM;
|
||||
}
|
||||
|
||||
private:
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
DawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
BackendBinding* CreateMetalBinding(GLFWwindow* window, dawnDevice device) {
|
||||
BackendBinding* CreateMetalBinding(GLFWwindow* window, DawnDevice device) {
|
||||
return new MetalBinding(window, device);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace utils {
|
|||
|
||||
class NullBinding : public BackendBinding {
|
||||
public:
|
||||
NullBinding(GLFWwindow* window, dawnDevice device) : BackendBinding(window, device) {
|
||||
NullBinding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
|
||||
}
|
||||
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
|
@ -32,15 +32,15 @@ namespace utils {
|
|||
}
|
||||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||
}
|
||||
dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||
return DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
|
||||
}
|
||||
|
||||
private:
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
DawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
BackendBinding* CreateNullBinding(GLFWwindow* window, dawnDevice device) {
|
||||
BackendBinding* CreateNullBinding(GLFWwindow* window, DawnDevice device) {
|
||||
return new NullBinding(window, device);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
namespace utils {
|
||||
class SwapChainImplGL {
|
||||
public:
|
||||
using WSIContext = dawnWSIContextGL;
|
||||
using WSIContext = DawnWSIContextGL;
|
||||
|
||||
SwapChainImplGL(GLFWwindow* window) : mWindow(window) {
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace utils {
|
|||
glDeleteFramebuffers(1, &mBackFBO);
|
||||
}
|
||||
|
||||
void Init(dawnWSIContextGL*) {
|
||||
void Init(DawnWSIContextGL*) {
|
||||
glGenTextures(1, &mBackTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, mBackTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||
|
@ -50,8 +50,8 @@ namespace utils {
|
|||
mBackTexture, 0);
|
||||
}
|
||||
|
||||
dawnSwapChainError Configure(dawnTextureFormat format,
|
||||
dawnTextureUsageBit,
|
||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||
DawnTextureUsageBit,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
if (format != DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM) {
|
||||
|
@ -70,12 +70,12 @@ namespace utils {
|
|||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture) {
|
||||
nextTexture->texture.u32 = mBackTexture;
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawnSwapChainError Present() {
|
||||
DawnSwapChainError Present() {
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, mBackFBO);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
glBlitFramebuffer(0, 0, mWidth, mHeight, 0, mHeight, mWidth, 0, GL_COLOR_BUFFER_BIT,
|
||||
|
@ -95,7 +95,7 @@ namespace utils {
|
|||
|
||||
class OpenGLBinding : public BackendBinding {
|
||||
public:
|
||||
OpenGLBinding(GLFWwindow* window, dawnDevice device) : BackendBinding(window, device) {
|
||||
OpenGLBinding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
|
||||
// Load the GL entry points in our copy of the glad static library
|
||||
gladLoadGLLoader(reinterpret_cast<GLADloadproc>(glfwGetProcAddress));
|
||||
}
|
||||
|
@ -107,15 +107,15 @@ namespace utils {
|
|||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||
}
|
||||
|
||||
dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||
return DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
|
||||
}
|
||||
|
||||
private:
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
DawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, dawnDevice device) {
|
||||
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, DawnDevice device) {
|
||||
return new OpenGLBinding(window, device);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace utils {
|
|||
|
||||
class VulkanBinding : public BackendBinding {
|
||||
public:
|
||||
VulkanBinding(GLFWwindow* window, dawnDevice device) : BackendBinding(window, device) {
|
||||
VulkanBinding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
|
||||
}
|
||||
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
|
@ -41,16 +41,16 @@ namespace utils {
|
|||
}
|
||||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||
}
|
||||
dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||
ASSERT(mSwapchainImpl.userData != nullptr);
|
||||
return dawn_native::vulkan::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
|
||||
}
|
||||
|
||||
private:
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
DawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
BackendBinding* CreateVulkanBinding(GLFWwindow* window, dawnDevice device) {
|
||||
BackendBinding* CreateVulkanBinding(GLFWwindow* window, DawnDevice device) {
|
||||
return new VulkanBinding(window, device);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue