Change the API prefix in generators from nxt to dawn
This commit is contained in:
parent
ae79c03d45
commit
b1669e3fa4
|
@ -17,26 +17,26 @@
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/DawnHelpers.h"
|
||||||
#include "utils/SystemUtils.h"
|
#include "utils/SystemUtils.h"
|
||||||
|
|
||||||
nxtDevice device;
|
dawnDevice device;
|
||||||
nxtQueue queue;
|
dawnQueue queue;
|
||||||
nxtSwapChain swapchain;
|
dawnSwapChain swapchain;
|
||||||
nxtRenderPipeline pipeline;
|
dawnRenderPipeline pipeline;
|
||||||
|
|
||||||
nxtTextureFormat swapChainFormat;
|
dawnTextureFormat swapChainFormat;
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
device = CreateCppDawnDevice().Release();
|
device = CreateCppDawnDevice().Release();
|
||||||
queue = nxtDeviceCreateQueue(device);
|
queue = dawnDeviceCreateQueue(device);
|
||||||
|
|
||||||
{
|
{
|
||||||
nxtSwapChainBuilder builder = nxtDeviceCreateSwapChainBuilder(device);
|
dawnSwapChainBuilder builder = dawnDeviceCreateSwapChainBuilder(device);
|
||||||
uint64_t swapchainImpl = GetSwapChainImplementation();
|
uint64_t swapchainImpl = GetSwapChainImplementation();
|
||||||
nxtSwapChainBuilderSetImplementation(builder, swapchainImpl);
|
dawnSwapChainBuilderSetImplementation(builder, swapchainImpl);
|
||||||
swapchain = nxtSwapChainBuilderGetResult(builder);
|
swapchain = dawnSwapChainBuilderGetResult(builder);
|
||||||
nxtSwapChainBuilderRelease(builder);
|
dawnSwapChainBuilderRelease(builder);
|
||||||
}
|
}
|
||||||
swapChainFormat = static_cast<nxtTextureFormat>(GetPreferredSwapChainTextureFormat());
|
swapChainFormat = static_cast<dawnTextureFormat>(GetPreferredSwapChainTextureFormat());
|
||||||
nxtSwapChainConfigure(swapchain, swapChainFormat, NXT_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT, 640,
|
dawnSwapChainConfigure(swapchain, swapChainFormat, DAWN_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT, 640,
|
||||||
480);
|
480);
|
||||||
|
|
||||||
const char* vs =
|
const char* vs =
|
||||||
|
@ -45,7 +45,7 @@ void init() {
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
" gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n"
|
" gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
nxtShaderModule 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 =
|
const char* fs =
|
||||||
"#version 450\n"
|
"#version 450\n"
|
||||||
|
@ -53,52 +53,52 @@ void init() {
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
" fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
|
" fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
nxtShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fs).Release();
|
dawnShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fs).Release();
|
||||||
|
|
||||||
{
|
{
|
||||||
nxtRenderPipelineBuilder builder = nxtDeviceCreateRenderPipelineBuilder(device);
|
dawnRenderPipelineBuilder builder = dawnDeviceCreateRenderPipelineBuilder(device);
|
||||||
nxtRenderPipelineBuilderSetColorAttachmentFormat(builder, 0, swapChainFormat);
|
dawnRenderPipelineBuilderSetColorAttachmentFormat(builder, 0, swapChainFormat);
|
||||||
nxtRenderPipelineBuilderSetStage(builder, NXT_SHADER_STAGE_VERTEX, vsModule, "main");
|
dawnRenderPipelineBuilderSetStage(builder, DAWN_SHADER_STAGE_VERTEX, vsModule, "main");
|
||||||
nxtRenderPipelineBuilderSetStage(builder, NXT_SHADER_STAGE_FRAGMENT, fsModule, "main");
|
dawnRenderPipelineBuilderSetStage(builder, DAWN_SHADER_STAGE_FRAGMENT, fsModule, "main");
|
||||||
pipeline = nxtRenderPipelineBuilderGetResult(builder);
|
pipeline = dawnRenderPipelineBuilderGetResult(builder);
|
||||||
nxtRenderPipelineBuilderRelease(builder);
|
dawnRenderPipelineBuilderRelease(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtShaderModuleRelease(vsModule);
|
dawnShaderModuleRelease(vsModule);
|
||||||
nxtShaderModuleRelease(fsModule);
|
dawnShaderModuleRelease(fsModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
void frame() {
|
void frame() {
|
||||||
nxtTexture backbuffer = nxtSwapChainGetNextTexture(swapchain);
|
dawnTexture backbuffer = dawnSwapChainGetNextTexture(swapchain);
|
||||||
nxtTextureView backbufferView;
|
dawnTextureView backbufferView;
|
||||||
{
|
{
|
||||||
nxtTextureViewBuilder builder = nxtTextureCreateTextureViewBuilder(backbuffer);
|
dawnTextureViewBuilder builder = dawnTextureCreateTextureViewBuilder(backbuffer);
|
||||||
backbufferView = nxtTextureViewBuilderGetResult(builder);
|
backbufferView = dawnTextureViewBuilderGetResult(builder);
|
||||||
nxtTextureViewBuilderRelease(builder);
|
dawnTextureViewBuilderRelease(builder);
|
||||||
}
|
}
|
||||||
nxtRenderPassDescriptor renderpassInfo;
|
dawnRenderPassDescriptor renderpassInfo;
|
||||||
{
|
{
|
||||||
nxtRenderPassDescriptorBuilder builder = nxtDeviceCreateRenderPassDescriptorBuilder(device);
|
dawnRenderPassDescriptorBuilder builder = dawnDeviceCreateRenderPassDescriptorBuilder(device);
|
||||||
nxtRenderPassDescriptorBuilderSetColorAttachment(builder, 0, backbufferView, NXT_LOAD_OP_CLEAR);
|
dawnRenderPassDescriptorBuilderSetColorAttachment(builder, 0, backbufferView, DAWN_LOAD_OP_CLEAR);
|
||||||
renderpassInfo = nxtRenderPassDescriptorBuilderGetResult(builder);
|
renderpassInfo = dawnRenderPassDescriptorBuilderGetResult(builder);
|
||||||
nxtRenderPassDescriptorBuilderRelease(builder);
|
dawnRenderPassDescriptorBuilderRelease(builder);
|
||||||
}
|
}
|
||||||
nxtCommandBuffer commands;
|
dawnCommandBuffer commands;
|
||||||
{
|
{
|
||||||
nxtCommandBufferBuilder builder = nxtDeviceCreateCommandBufferBuilder(device);
|
dawnCommandBufferBuilder builder = dawnDeviceCreateCommandBufferBuilder(device);
|
||||||
nxtCommandBufferBuilderBeginRenderPass(builder, renderpassInfo);
|
dawnCommandBufferBuilderBeginRenderPass(builder, renderpassInfo);
|
||||||
nxtCommandBufferBuilderSetRenderPipeline(builder, pipeline);
|
dawnCommandBufferBuilderSetRenderPipeline(builder, pipeline);
|
||||||
nxtCommandBufferBuilderDrawArrays(builder, 3, 1, 0, 0);
|
dawnCommandBufferBuilderDrawArrays(builder, 3, 1, 0, 0);
|
||||||
nxtCommandBufferBuilderEndRenderPass(builder);
|
dawnCommandBufferBuilderEndRenderPass(builder);
|
||||||
commands = nxtCommandBufferBuilderGetResult(builder);
|
commands = dawnCommandBufferBuilderGetResult(builder);
|
||||||
nxtCommandBufferBuilderRelease(builder);
|
dawnCommandBufferBuilderRelease(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtQueueSubmit(queue, 1, &commands);
|
dawnQueueSubmit(queue, 1, &commands);
|
||||||
nxtCommandBufferRelease(commands);
|
dawnCommandBufferRelease(commands);
|
||||||
nxtSwapChainPresent(swapchain, backbuffer);
|
dawnSwapChainPresent(swapchain, backbuffer);
|
||||||
nxtRenderPassDescriptorRelease(renderpassInfo);
|
dawnRenderPassDescriptorRelease(renderpassInfo);
|
||||||
nxtTextureViewRelease(backbufferView);
|
dawnTextureViewRelease(backbufferView);
|
||||||
|
|
||||||
DoFlush();
|
DoFlush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,11 +84,11 @@ dawn::Device CreateCppDawnDevice() {
|
||||||
|
|
||||||
binding->SetWindow(window);
|
binding->SetWindow(window);
|
||||||
|
|
||||||
nxtDevice backendDevice;
|
dawnDevice backendDevice;
|
||||||
nxtProcTable backendProcs;
|
nxtProcTable backendProcs;
|
||||||
binding->GetProcAndDevice(&backendProcs, &backendDevice);
|
binding->GetProcAndDevice(&backendProcs, &backendDevice);
|
||||||
|
|
||||||
nxtDevice cDevice = nullptr;
|
dawnDevice cDevice = nullptr;
|
||||||
nxtProcTable procs;
|
nxtProcTable procs;
|
||||||
switch (cmdBufType) {
|
switch (cmdBufType) {
|
||||||
case CmdBufType::None:
|
case CmdBufType::None:
|
||||||
|
@ -104,7 +104,7 @@ dawn::Device CreateCppDawnDevice() {
|
||||||
wireServer = dawn::wire::NewServerCommandHandler(backendDevice, backendProcs, s2cBuf);
|
wireServer = dawn::wire::NewServerCommandHandler(backendDevice, backendProcs, s2cBuf);
|
||||||
c2sBuf->SetHandler(wireServer);
|
c2sBuf->SetHandler(wireServer);
|
||||||
|
|
||||||
nxtDevice clientDevice;
|
dawnDevice clientDevice;
|
||||||
nxtProcTable clientProcs;
|
nxtProcTable clientProcs;
|
||||||
wireClient = dawn::wire::NewClientDevice(&clientProcs, &clientDevice, c2sBuf);
|
wireClient = dawn::wire::NewClientDevice(&clientProcs, &clientDevice, c2sBuf);
|
||||||
s2cBuf->SetHandler(wireClient);
|
s2cBuf->SetHandler(wireClient);
|
||||||
|
|
|
@ -314,7 +314,7 @@ def as_cType(name):
|
||||||
if name.native:
|
if name.native:
|
||||||
return name.concatcase()
|
return name.concatcase()
|
||||||
else:
|
else:
|
||||||
return 'nxt' + name.CamelCase()
|
return 'dawn' + name.CamelCase()
|
||||||
|
|
||||||
def as_cppType(name):
|
def as_cppType(name):
|
||||||
if name.native:
|
if name.native:
|
||||||
|
@ -338,7 +338,7 @@ def annotated(typ, arg):
|
||||||
|
|
||||||
def as_cEnum(type_name, value_name):
|
def as_cEnum(type_name, value_name):
|
||||||
assert(not type_name.native and not value_name.native)
|
assert(not type_name.native and not value_name.native)
|
||||||
return 'NXT' + '_' + type_name.SNAKE_CASE() + '_' + value_name.SNAKE_CASE()
|
return 'DAWN' + '_' + type_name.SNAKE_CASE() + '_' + value_name.SNAKE_CASE()
|
||||||
|
|
||||||
def as_cppEnum(value_name):
|
def as_cppEnum(value_name):
|
||||||
assert(not value_name.native)
|
assert(not value_name.native)
|
||||||
|
@ -348,7 +348,7 @@ def as_cppEnum(value_name):
|
||||||
|
|
||||||
def as_cMethod(type_name, method_name):
|
def as_cMethod(type_name, method_name):
|
||||||
assert(not type_name.native and not method_name.native)
|
assert(not type_name.native and not method_name.native)
|
||||||
return 'nxt' + type_name.CamelCase() + method_name.CamelCase()
|
return 'dawn' + type_name.CamelCase() + method_name.CamelCase()
|
||||||
|
|
||||||
def as_MethodSuffix(type_name, method_name):
|
def as_MethodSuffix(type_name, method_name):
|
||||||
assert(not type_name.native and not method_name.native)
|
assert(not type_name.native and not method_name.native)
|
||||||
|
@ -356,7 +356,7 @@ def as_MethodSuffix(type_name, method_name):
|
||||||
|
|
||||||
def as_cProc(type_name, method_name):
|
def as_cProc(type_name, method_name):
|
||||||
assert(not type_name.native and not method_name.native)
|
assert(not type_name.native and not method_name.native)
|
||||||
return 'nxt' + 'Proc' + type_name.CamelCase() + method_name.CamelCase()
|
return 'dawn' + 'Proc' + type_name.CamelCase() + method_name.CamelCase()
|
||||||
|
|
||||||
def as_backendType(typ):
|
def as_backendType(typ):
|
||||||
if typ.category == 'object':
|
if typ.category == 'object':
|
||||||
|
|
|
@ -45,11 +45,11 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
// Custom types depending on the target language
|
// Custom types depending on the target language
|
||||||
typedef uint64_t nxtCallbackUserdata;
|
typedef uint64_t dawnCallbackUserdata;
|
||||||
typedef void (*nxtDeviceErrorCallback)(const char* message, nxtCallbackUserdata userdata);
|
typedef void (*dawnDeviceErrorCallback)(const char* message, dawnCallbackUserdata userdata);
|
||||||
typedef void (*nxtBuilderErrorCallback)(nxtBuilderErrorStatus status, const char* message, nxtCallbackUserdata userdata1, nxtCallbackUserdata userdata2);
|
typedef void (*dawnBuilderErrorCallback)(dawnBuilderErrorStatus status, const char* message, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2);
|
||||||
typedef void (*nxtBufferMapReadCallback)(nxtBufferMapAsyncStatus status, const void* data, nxtCallbackUserdata userdata);
|
typedef void (*dawnBufferMapReadCallback)(dawnBufferMapAsyncStatus status, const void* data, dawnCallbackUserdata userdata);
|
||||||
typedef void (*nxtBufferMapWriteCallback)(nxtBufferMapAsyncStatus status, void* data, nxtCallbackUserdata userdata);
|
typedef void (*dawnBufferMapWriteCallback)(dawnBufferMapAsyncStatus status, void* data, dawnCallbackUserdata userdata);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace {
|
||||||
ProcTableAsClass::~ProcTableAsClass() {
|
ProcTableAsClass::~ProcTableAsClass() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcTableAsClass::GetProcTableAndDevice(nxtProcTable* table, nxtDevice* device) {
|
void ProcTableAsClass::GetProcTableAndDevice(nxtProcTable* table, dawnDevice* device) {
|
||||||
*device = GetNewDevice();
|
*device = GetNewDevice();
|
||||||
|
|
||||||
{% for type in by_category["object"] %}
|
{% for type in by_category["object"] %}
|
||||||
|
@ -48,7 +48,7 @@ void ProcTableAsClass::GetProcTableAndDevice(nxtProcTable* table, nxtDevice* dev
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcTableAsClass::DeviceSetErrorCallback(nxtDevice self, nxtDeviceErrorCallback callback, nxtCallbackUserdata userdata) {
|
void ProcTableAsClass::DeviceSetErrorCallback(dawnDevice self, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata) {
|
||||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||||
object->deviceErrorCallback = callback;
|
object->deviceErrorCallback = callback;
|
||||||
object->userdata1 = userdata;
|
object->userdata1 = userdata;
|
||||||
|
@ -56,7 +56,7 @@ void ProcTableAsClass::DeviceSetErrorCallback(nxtDevice self, nxtDeviceErrorCall
|
||||||
OnDeviceSetErrorCallback(self, callback, userdata);
|
OnDeviceSetErrorCallback(self, callback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcTableAsClass::BufferMapReadAsync(nxtBuffer self, uint32_t start, uint32_t size, nxtBufferMapReadCallback callback, nxtCallbackUserdata userdata) {
|
void ProcTableAsClass::BufferMapReadAsync(dawnBuffer self, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata) {
|
||||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||||
object->mapReadCallback = callback;
|
object->mapReadCallback = callback;
|
||||||
object->userdata1 = userdata;
|
object->userdata1 = userdata;
|
||||||
|
@ -64,7 +64,7 @@ void ProcTableAsClass::BufferMapReadAsync(nxtBuffer self, uint32_t start, uint32
|
||||||
OnBufferMapReadAsyncCallback(self, start, size, callback, userdata);
|
OnBufferMapReadAsyncCallback(self, start, size, callback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcTableAsClass::BufferMapWriteAsync(nxtBuffer self, uint32_t start, uint32_t size, nxtBufferMapWriteCallback callback, nxtCallbackUserdata userdata) {
|
void ProcTableAsClass::BufferMapWriteAsync(dawnBuffer self, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata) {
|
||||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||||
object->mapWriteCallback = callback;
|
object->mapWriteCallback = callback;
|
||||||
object->userdata1 = userdata;
|
object->userdata1 = userdata;
|
||||||
|
@ -72,32 +72,32 @@ void ProcTableAsClass::BufferMapWriteAsync(nxtBuffer self, uint32_t start, uint3
|
||||||
OnBufferMapWriteAsyncCallback(self, start, size, callback, userdata);
|
OnBufferMapWriteAsyncCallback(self, start, size, callback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcTableAsClass::CallDeviceErrorCallback(nxtDevice device, const char* message) {
|
void ProcTableAsClass::CallDeviceErrorCallback(dawnDevice device, const char* message) {
|
||||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(device);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(device);
|
||||||
object->deviceErrorCallback(message, object->userdata1);
|
object->deviceErrorCallback(message, object->userdata1);
|
||||||
}
|
}
|
||||||
void ProcTableAsClass::CallBuilderErrorCallback(void* builder , nxtBuilderErrorStatus status, const char* message) {
|
void ProcTableAsClass::CallBuilderErrorCallback(void* builder , dawnBuilderErrorStatus status, const char* message) {
|
||||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(builder);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(builder);
|
||||||
object->builderErrorCallback(status, message, object->userdata1, object->userdata2);
|
object->builderErrorCallback(status, message, object->userdata1, object->userdata2);
|
||||||
}
|
}
|
||||||
void ProcTableAsClass::CallMapReadCallback(nxtBuffer buffer, nxtBufferMapAsyncStatus status, const void* data) {
|
void ProcTableAsClass::CallMapReadCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, const void* data) {
|
||||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
||||||
object->mapReadCallback(status, data, object->userdata1);
|
object->mapReadCallback(status, data, object->userdata1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcTableAsClass::CallMapWriteCallback(nxtBuffer buffer, nxtBufferMapAsyncStatus status, void* data) {
|
void ProcTableAsClass::CallMapWriteCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, void* data) {
|
||||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
||||||
object->mapWriteCallback(status, data, object->userdata1);
|
object->mapWriteCallback(status, data, object->userdata1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{% for type in by_category["object"] if type.is_builder %}
|
{% 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, nxtBuilderErrorCallback callback, nxtCallbackUserdata userdata1, nxtCallbackUserdata 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);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||||
object->builderErrorCallback = callback;
|
object->builderErrorCallback = callback;
|
||||||
object->userdata1 = userdata1;
|
object->userdata1 = userdata1;
|
||||||
object->userdata2 = userdata2;
|
object->userdata2 = userdata2;
|
||||||
|
|
||||||
OnBuilderSetErrorCallback(reinterpret_cast<nxtBufferBuilder>(self), callback, userdata1, userdata2);
|
OnBuilderSetErrorCallback(reinterpret_cast<dawnBufferBuilder>(self), callback, userdata1, userdata2);
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ProcTableAsClass {
|
||||||
public:
|
public:
|
||||||
virtual ~ProcTableAsClass();
|
virtual ~ProcTableAsClass();
|
||||||
|
|
||||||
void GetProcTableAndDevice(nxtProcTable* table, nxtDevice* device);
|
void GetProcTableAndDevice(nxtProcTable* table, dawnDevice* device);
|
||||||
|
|
||||||
// Creates an object that can be returned by a mocked call as in WillOnce(Return(foo)).
|
// 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.
|
// It returns an object of the write type that isn't equal to any previously returned object.
|
||||||
|
@ -51,36 +51,36 @@ class ProcTableAsClass {
|
||||||
|
|
||||||
// Stores callback and userdata and calls OnBuilderSetErrorCallback
|
// Stores callback and userdata and calls OnBuilderSetErrorCallback
|
||||||
{% if type.is_builder %}
|
{% if type.is_builder %}
|
||||||
void {{as_MethodSuffix(type.name, Name("set error callback"))}}({{as_cType(type.name)}} self, nxtBuilderErrorCallback callback, nxtCallbackUserdata userdata1, nxtCallbackUserdata userdata2);
|
void {{as_MethodSuffix(type.name, Name("set error callback"))}}({{as_cType(type.name)}} self, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
// Stores callback and userdata and calls the On* methods
|
// Stores callback and userdata and calls the On* methods
|
||||||
void DeviceSetErrorCallback(nxtDevice self, nxtDeviceErrorCallback callback, nxtCallbackUserdata userdata);
|
void DeviceSetErrorCallback(dawnDevice self, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata);
|
||||||
void BufferMapReadAsync(nxtBuffer self, uint32_t start, uint32_t size, nxtBufferMapReadCallback callback, nxtCallbackUserdata userdata);
|
void BufferMapReadAsync(dawnBuffer self, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata);
|
||||||
void BufferMapWriteAsync(nxtBuffer self, uint32_t start, uint32_t size, nxtBufferMapWriteCallback callback, nxtCallbackUserdata userdata);
|
void BufferMapWriteAsync(dawnBuffer self, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata);
|
||||||
|
|
||||||
|
|
||||||
// Special cased mockable methods
|
// Special cased mockable methods
|
||||||
virtual void OnDeviceSetErrorCallback(nxtDevice device, nxtDeviceErrorCallback callback, nxtCallbackUserdata userdata) = 0;
|
virtual void OnDeviceSetErrorCallback(dawnDevice device, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata) = 0;
|
||||||
virtual void OnBuilderSetErrorCallback(nxtBufferBuilder builder, nxtBuilderErrorCallback callback, nxtCallbackUserdata userdata1, nxtCallbackUserdata userdata2) = 0;
|
virtual void OnBuilderSetErrorCallback(dawnBufferBuilder builder, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2) = 0;
|
||||||
virtual void OnBufferMapReadAsyncCallback(nxtBuffer buffer, uint32_t start, uint32_t size, nxtBufferMapReadCallback callback, nxtCallbackUserdata userdata) = 0;
|
virtual void OnBufferMapReadAsyncCallback(dawnBuffer buffer, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata) = 0;
|
||||||
virtual void OnBufferMapWriteAsyncCallback(nxtBuffer buffer, uint32_t start, uint32_t size, nxtBufferMapWriteCallback callback, nxtCallbackUserdata userdata) = 0;
|
virtual void OnBufferMapWriteAsyncCallback(dawnBuffer buffer, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata) = 0;
|
||||||
|
|
||||||
// Calls the stored callbacks
|
// Calls the stored callbacks
|
||||||
void CallDeviceErrorCallback(nxtDevice device, const char* message);
|
void CallDeviceErrorCallback(dawnDevice device, const char* message);
|
||||||
void CallBuilderErrorCallback(void* builder , nxtBuilderErrorStatus status, const char* message);
|
void CallBuilderErrorCallback(void* builder , dawnBuilderErrorStatus status, const char* message);
|
||||||
void CallMapReadCallback(nxtBuffer buffer, nxtBufferMapAsyncStatus status, const void* data);
|
void CallMapReadCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, const void* data);
|
||||||
void CallMapWriteCallback(nxtBuffer buffer, nxtBufferMapAsyncStatus status, void* data);
|
void CallMapWriteCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, void* data);
|
||||||
|
|
||||||
struct Object {
|
struct Object {
|
||||||
ProcTableAsClass* procs = nullptr;
|
ProcTableAsClass* procs = nullptr;
|
||||||
nxtDeviceErrorCallback deviceErrorCallback = nullptr;
|
dawnDeviceErrorCallback deviceErrorCallback = nullptr;
|
||||||
nxtBuilderErrorCallback builderErrorCallback = nullptr;
|
dawnBuilderErrorCallback builderErrorCallback = nullptr;
|
||||||
nxtBufferMapReadCallback mapReadCallback = nullptr;
|
dawnBufferMapReadCallback mapReadCallback = nullptr;
|
||||||
nxtBufferMapWriteCallback mapWriteCallback = nullptr;
|
dawnBufferMapWriteCallback mapWriteCallback = nullptr;
|
||||||
nxtCallbackUserdata userdata1 = 0;
|
dawnCallbackUserdata userdata1 = 0;
|
||||||
nxtCallbackUserdata userdata2 = 0;
|
dawnCallbackUserdata userdata2 = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -106,10 +106,10 @@ class MockProcTable : public ProcTableAsClass {
|
||||||
MOCK_METHOD1({{as_MethodSuffix(type.name, Name("release"))}}, void({{as_cType(type.name)}} self));
|
MOCK_METHOD1({{as_MethodSuffix(type.name, Name("release"))}}, void({{as_cType(type.name)}} self));
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
MOCK_METHOD3(OnDeviceSetErrorCallback, void(nxtDevice device, nxtDeviceErrorCallback callback, nxtCallbackUserdata userdata));
|
MOCK_METHOD3(OnDeviceSetErrorCallback, void(dawnDevice device, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata));
|
||||||
MOCK_METHOD4(OnBuilderSetErrorCallback, void(nxtBufferBuilder builder, nxtBuilderErrorCallback callback, nxtCallbackUserdata userdata1, nxtCallbackUserdata userdata2));
|
MOCK_METHOD4(OnBuilderSetErrorCallback, void(dawnBufferBuilder builder, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2));
|
||||||
MOCK_METHOD5(OnBufferMapReadAsyncCallback, void(nxtBuffer buffer, uint32_t start, uint32_t size, nxtBufferMapReadCallback callback, nxtCallbackUserdata userdata));
|
MOCK_METHOD5(OnBufferMapReadAsyncCallback, void(dawnBuffer buffer, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata));
|
||||||
MOCK_METHOD5(OnBufferMapWriteAsyncCallback, void(nxtBuffer buffer, uint32_t start, uint32_t size, nxtBufferMapWriteCallback callback, nxtCallbackUserdata userdata));
|
MOCK_METHOD5(OnBufferMapWriteAsyncCallback, void(dawnBuffer buffer, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata));
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MOCK_NXT_H
|
#endif // MOCK_NXT_H
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace dawn { namespace wire {
|
||||||
class Device;
|
class Device;
|
||||||
|
|
||||||
struct BuilderCallbackData {
|
struct BuilderCallbackData {
|
||||||
bool Call(nxtBuilderErrorStatus status, const char* message) {
|
bool Call(dawnBuilderErrorStatus status, const char* message) {
|
||||||
if (canCall && callback != nullptr) {
|
if (canCall && callback != nullptr) {
|
||||||
canCall = true;
|
canCall = true;
|
||||||
callback(status, message, userdata1, userdata2);
|
callback(status, message, userdata1, userdata2);
|
||||||
|
@ -43,9 +43,9 @@ namespace dawn { namespace wire {
|
||||||
}
|
}
|
||||||
|
|
||||||
//* For help with development, prints all builder errors by default.
|
//* For help with development, prints all builder errors by default.
|
||||||
nxtBuilderErrorCallback callback = nullptr;
|
dawnBuilderErrorCallback callback = nullptr;
|
||||||
nxtCallbackUserdata userdata1 = 0;
|
dawnCallbackUserdata userdata1 = 0;
|
||||||
nxtCallbackUserdata userdata2 = 0;
|
dawnCallbackUserdata userdata2 = 0;
|
||||||
bool canCall = true;
|
bool canCall = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,14 +81,14 @@ namespace dawn { namespace wire {
|
||||||
~Buffer() {
|
~Buffer() {
|
||||||
//* Callbacks need to be fired in all cases, as they can handle freeing resources
|
//* Callbacks need to be fired in all cases, as they can handle freeing resources
|
||||||
//* so we call them with "Unknown" status.
|
//* so we call them with "Unknown" status.
|
||||||
ClearMapRequests(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN);
|
ClearMapRequests(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN);
|
||||||
|
|
||||||
if (mappedData) {
|
if (mappedData) {
|
||||||
free(mappedData);
|
free(mappedData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearMapRequests(nxtBufferMapAsyncStatus status) {
|
void ClearMapRequests(dawnBufferMapAsyncStatus status) {
|
||||||
for (auto& it : requests) {
|
for (auto& it : requests) {
|
||||||
if (it.second.isWrite) {
|
if (it.second.isWrite) {
|
||||||
it.second.writeCallback(status, nullptr, it.second.userdata);
|
it.second.writeCallback(status, nullptr, it.second.userdata);
|
||||||
|
@ -103,9 +103,9 @@ namespace dawn { namespace wire {
|
||||||
//* map request in flight at a single time and need to track them separately.
|
//* 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.
|
//* On well-behaved applications, only one request should exist at a single time.
|
||||||
struct MapRequestData {
|
struct MapRequestData {
|
||||||
nxtBufferMapReadCallback readCallback = nullptr;
|
dawnBufferMapReadCallback readCallback = nullptr;
|
||||||
nxtBufferMapWriteCallback writeCallback = nullptr;
|
dawnBufferMapWriteCallback writeCallback = nullptr;
|
||||||
nxtCallbackUserdata userdata = 0;
|
dawnCallbackUserdata userdata = 0;
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
bool isWrite = false;
|
bool isWrite = false;
|
||||||
};
|
};
|
||||||
|
@ -225,8 +225,8 @@ namespace dawn { namespace wire {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtDeviceErrorCallback errorCallback = nullptr;
|
dawnDeviceErrorCallback errorCallback = nullptr;
|
||||||
nxtCallbackUserdata errorUserdata;
|
dawnCallbackUserdata errorUserdata;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CommandSerializer* mSerializer = nullptr;
|
CommandSerializer* mSerializer = nullptr;
|
||||||
|
@ -286,9 +286,9 @@ namespace dawn { namespace wire {
|
||||||
|
|
||||||
{% if type.is_builder %}
|
{% if type.is_builder %}
|
||||||
void Client{{as_MethodSuffix(type.name, Name("set error callback"))}}({{Type}}* self,
|
void Client{{as_MethodSuffix(type.name, Name("set error callback"))}}({{Type}}* self,
|
||||||
nxtBuilderErrorCallback callback,
|
dawnBuilderErrorCallback callback,
|
||||||
nxtCallbackUserdata userdata1,
|
dawnCallbackUserdata userdata1,
|
||||||
nxtCallbackUserdata userdata2) {
|
dawnCallbackUserdata userdata2) {
|
||||||
self->builderCallback.callback = callback;
|
self->builderCallback.callback = callback;
|
||||||
self->builderCallback.userdata1 = userdata1;
|
self->builderCallback.userdata1 = userdata1;
|
||||||
self->builderCallback.userdata2 = userdata2;
|
self->builderCallback.userdata2 = userdata2;
|
||||||
|
@ -304,7 +304,7 @@ namespace dawn { namespace wire {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj->builderCallback.Call(NXT_BUILDER_ERROR_STATUS_UNKNOWN, "Unknown");
|
obj->builderCallback.Call(DAWN_BUILDER_ERROR_STATUS_UNKNOWN, "Unknown");
|
||||||
|
|
||||||
wire::{{as_MethodSuffix(type.name, Name("destroy"))}}Cmd cmd;
|
wire::{{as_MethodSuffix(type.name, Name("destroy"))}}Cmd cmd;
|
||||||
cmd.objectId = obj->id;
|
cmd.objectId = obj->id;
|
||||||
|
@ -321,7 +321,7 @@ namespace dawn { namespace wire {
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
void ClientBufferMapReadAsync(Buffer* buffer, uint32_t start, uint32_t size, nxtBufferMapReadCallback callback, nxtCallbackUserdata userdata) {
|
void ClientBufferMapReadAsync(Buffer* buffer, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata) {
|
||||||
uint32_t serial = buffer->requestSerial++;
|
uint32_t serial = buffer->requestSerial++;
|
||||||
ASSERT(buffer->requests.find(serial) == buffer->requests.end());
|
ASSERT(buffer->requests.find(serial) == buffer->requests.end());
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ namespace dawn { namespace wire {
|
||||||
*allocCmd = cmd;
|
*allocCmd = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientBufferMapWriteAsync(Buffer* buffer, uint32_t start, uint32_t size, nxtBufferMapWriteCallback callback, nxtCallbackUserdata userdata) {
|
void ClientBufferMapWriteAsync(Buffer* buffer, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata) {
|
||||||
uint32_t serial = buffer->requestSerial++;
|
uint32_t serial = buffer->requestSerial++;
|
||||||
ASSERT(buffer->requests.find(serial) == buffer->requests.end());
|
ASSERT(buffer->requests.find(serial) == buffer->requests.end());
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ namespace dawn { namespace wire {
|
||||||
*allocCmd = cmd;
|
*allocCmd = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProxyClientBufferUnmap(nxtBuffer cBuffer) {
|
void ProxyClientBufferUnmap(dawnBuffer cBuffer) {
|
||||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||||
|
|
||||||
//* Invalidate the local pointer, and cancel all other in-flight requests that would turn into
|
//* Invalidate the local pointer, and cancel all other in-flight requests that would turn into
|
||||||
|
@ -393,7 +393,7 @@ namespace dawn { namespace wire {
|
||||||
free(buffer->mappedData);
|
free(buffer->mappedData);
|
||||||
buffer->mappedData = nullptr;
|
buffer->mappedData = nullptr;
|
||||||
}
|
}
|
||||||
buffer->ClearMapRequests(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN);
|
buffer->ClearMapRequests(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN);
|
||||||
|
|
||||||
ClientBufferUnmap(cBuffer);
|
ClientBufferUnmap(cBuffer);
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,7 @@ namespace dawn { namespace wire {
|
||||||
void ClientDeviceRelease(Device*) {
|
void ClientDeviceRelease(Device*) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientDeviceSetErrorCallback(Device* self, nxtDeviceErrorCallback callback, nxtCallbackUserdata userdata) {
|
void ClientDeviceSetErrorCallback(Device* self, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata) {
|
||||||
self->errorCallback = callback;
|
self->errorCallback = callback;
|
||||||
self->errorUserdata = userdata;
|
self->errorUserdata = userdata;
|
||||||
}
|
}
|
||||||
|
@ -535,10 +535,10 @@ namespace dawn { namespace wire {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool called = builtObject->builderCallback.Call(static_cast<nxtBuilderErrorStatus>(cmd->status), message);
|
bool called = builtObject->builderCallback.Call(static_cast<dawnBuilderErrorStatus>(cmd->status), message);
|
||||||
|
|
||||||
// Unhandled builder errors are forwarded to the device
|
// Unhandled builder errors are forwarded to the device
|
||||||
if (!called && cmd->status != NXT_BUILDER_ERROR_STATUS_SUCCESS && cmd->status != NXT_BUILDER_ERROR_STATUS_UNKNOWN) {
|
if (!called && cmd->status != DAWN_BUILDER_ERROR_STATUS_SUCCESS && cmd->status != DAWN_BUILDER_ERROR_STATUS_UNKNOWN) {
|
||||||
mDevice->HandleError(("Unhandled builder error: " + std::string(message)).c_str());
|
mDevice->HandleError(("Unhandled builder error: " + std::string(message)).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,7 +555,7 @@ namespace dawn { namespace wire {
|
||||||
//* Unconditionnally get the data from the buffer so that the correct amount of data is
|
//* Unconditionnally get the data from the buffer so that the correct amount of data is
|
||||||
//* consumed from the buffer, even when we ignore the command and early out.
|
//* consumed from the buffer, even when we ignore the command and early out.
|
||||||
const char* requestData = nullptr;
|
const char* requestData = nullptr;
|
||||||
if (cmd->status == NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (cmd->status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
||||||
requestData = GetData<char>(commands, size, cmd->dataLength);
|
requestData = GetData<char>(commands, size, cmd->dataLength);
|
||||||
if (requestData == nullptr) {
|
if (requestData == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -587,7 +587,7 @@ namespace dawn { namespace wire {
|
||||||
buffer->requests.erase(requestIt);
|
buffer->requests.erase(requestIt);
|
||||||
|
|
||||||
//* On success, we copy the data locally because the IPC buffer isn't valid outside of this function
|
//* On success, we copy the data locally because the IPC buffer isn't valid outside of this function
|
||||||
if (cmd->status == NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (cmd->status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
||||||
//* The server didn't send the right amount of data, this is an error and could cause
|
//* The server didn't send the right amount of data, this is an error and could cause
|
||||||
//* the application to crash if we did call the callback.
|
//* the application to crash if we did call the callback.
|
||||||
if (request.size != cmd->dataLength) {
|
if (request.size != cmd->dataLength) {
|
||||||
|
@ -605,9 +605,9 @@ namespace dawn { namespace wire {
|
||||||
buffer->mappedData = malloc(request.size);
|
buffer->mappedData = malloc(request.size);
|
||||||
memcpy(buffer->mappedData, requestData, request.size);
|
memcpy(buffer->mappedData, requestData, request.size);
|
||||||
|
|
||||||
request.readCallback(static_cast<nxtBufferMapAsyncStatus>(cmd->status), buffer->mappedData, request.userdata);
|
request.readCallback(static_cast<dawnBufferMapAsyncStatus>(cmd->status), buffer->mappedData, request.userdata);
|
||||||
} else {
|
} else {
|
||||||
request.readCallback(static_cast<nxtBufferMapAsyncStatus>(cmd->status), nullptr, request.userdata);
|
request.readCallback(static_cast<dawnBufferMapAsyncStatus>(cmd->status), nullptr, request.userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -643,7 +643,7 @@ namespace dawn { namespace wire {
|
||||||
buffer->requests.erase(requestIt);
|
buffer->requests.erase(requestIt);
|
||||||
|
|
||||||
//* On success, we copy the data locally because the IPC buffer isn't valid outside of this function
|
//* On success, we copy the data locally because the IPC buffer isn't valid outside of this function
|
||||||
if (cmd->status == NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (cmd->status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
||||||
if (buffer->mappedData != nullptr) {
|
if (buffer->mappedData != nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -653,9 +653,9 @@ namespace dawn { namespace wire {
|
||||||
buffer->mappedData = malloc(request.size);
|
buffer->mappedData = malloc(request.size);
|
||||||
memset(buffer->mappedData, 0, request.size);
|
memset(buffer->mappedData, 0, request.size);
|
||||||
|
|
||||||
request.writeCallback(static_cast<nxtBufferMapAsyncStatus>(cmd->status), buffer->mappedData, request.userdata);
|
request.writeCallback(static_cast<dawnBufferMapAsyncStatus>(cmd->status), buffer->mappedData, request.userdata);
|
||||||
} else {
|
} else {
|
||||||
request.writeCallback(static_cast<nxtBufferMapAsyncStatus>(cmd->status), nullptr, request.userdata);
|
request.writeCallback(static_cast<dawnBufferMapAsyncStatus>(cmd->status), nullptr, request.userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -664,10 +664,10 @@ namespace dawn { namespace wire {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandHandler* NewClientDevice(nxtProcTable* procs, nxtDevice* device, CommandSerializer* serializer) {
|
CommandHandler* NewClientDevice(nxtProcTable* procs, dawnDevice* device, CommandSerializer* serializer) {
|
||||||
auto clientDevice = new client::Device(serializer);
|
auto clientDevice = new client::Device(serializer);
|
||||||
|
|
||||||
*device = reinterpret_cast<nxtDeviceImpl*>(clientDevice);
|
*device = reinterpret_cast<dawnDeviceImpl*>(clientDevice);
|
||||||
*procs = client::GetProcs();
|
*procs = client::GetProcs();
|
||||||
|
|
||||||
return new client::Client(clientDevice);
|
return new client::Client(clientDevice);
|
||||||
|
|
|
@ -141,14 +141,14 @@ namespace dawn { namespace wire {
|
||||||
std::vector<Data> mKnown;
|
std::vector<Data> mKnown;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ForwardDeviceErrorToServer(const char* message, nxtCallbackUserdata userdata);
|
void ForwardDeviceErrorToServer(const char* message, dawnCallbackUserdata userdata);
|
||||||
|
|
||||||
{% for type in by_category["object"] if type.is_builder%}
|
{% for type in by_category["object"] if type.is_builder%}
|
||||||
void Forward{{type.name.CamelCase()}}ToClient(nxtBuilderErrorStatus status, const char* message, nxtCallbackUserdata userdata1, nxtCallbackUserdata userdata2);
|
void Forward{{type.name.CamelCase()}}ToClient(dawnBuilderErrorStatus status, const char* message, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2);
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
void ForwardBufferMapReadAsync(nxtBufferMapAsyncStatus status, const void* ptr, nxtCallbackUserdata userdata);
|
void ForwardBufferMapReadAsync(dawnBufferMapAsyncStatus status, const void* ptr, dawnCallbackUserdata userdata);
|
||||||
void ForwardBufferMapWriteAsync(nxtBufferMapAsyncStatus status, void* ptr, nxtCallbackUserdata userdata);
|
void ForwardBufferMapWriteAsync(dawnBufferMapAsyncStatus status, void* ptr, dawnCallbackUserdata userdata);
|
||||||
|
|
||||||
// A really really simple implementation of the DeserializeAllocator. It's main feature
|
// A really really simple implementation of the DeserializeAllocator. It's main feature
|
||||||
// is that it has some inline storage so as to avoid allocations for the majority of
|
// is that it has some inline storage so as to avoid allocations for the majority of
|
||||||
|
@ -205,14 +205,14 @@ namespace dawn { namespace wire {
|
||||||
|
|
||||||
class Server : public CommandHandler, public ObjectIdResolver {
|
class Server : public CommandHandler, public ObjectIdResolver {
|
||||||
public:
|
public:
|
||||||
Server(nxtDevice device, const nxtProcTable& procs, CommandSerializer* serializer)
|
Server(dawnDevice device, const nxtProcTable& procs, CommandSerializer* serializer)
|
||||||
: mProcs(procs), mSerializer(serializer) {
|
: mProcs(procs), mSerializer(serializer) {
|
||||||
//* The client-server knowledge is bootstrapped with device 1.
|
//* The client-server knowledge is bootstrapped with device 1.
|
||||||
auto* deviceData = mKnownDevice.Allocate(1);
|
auto* deviceData = mKnownDevice.Allocate(1);
|
||||||
deviceData->handle = device;
|
deviceData->handle = device;
|
||||||
deviceData->valid = true;
|
deviceData->valid = true;
|
||||||
|
|
||||||
auto userdata = static_cast<nxtCallbackUserdata>(reinterpret_cast<intptr_t>(this));
|
auto userdata = static_cast<dawnCallbackUserdata>(reinterpret_cast<intptr_t>(this));
|
||||||
procs.deviceSetErrorCallback(device, ForwardDeviceErrorToServer, userdata);
|
procs.deviceSetErrorCallback(device, ForwardDeviceErrorToServer, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,18 +229,18 @@ namespace dawn { namespace wire {
|
||||||
|
|
||||||
{% for type in by_category["object"] if type.is_builder%}
|
{% for type in by_category["object"] if type.is_builder%}
|
||||||
{% set Type = type.name.CamelCase() %}
|
{% set Type = type.name.CamelCase() %}
|
||||||
void On{{Type}}Error(nxtBuilderErrorStatus 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) {
|
||||||
auto* builder = mKnown{{Type}}.Get(id);
|
auto* builder = mKnown{{Type}}.Get(id);
|
||||||
|
|
||||||
if (builder == nullptr || builder->serial != serial) {
|
if (builder == nullptr || builder->serial != serial) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status != NXT_BUILDER_ERROR_STATUS_SUCCESS) {
|
if (status != DAWN_BUILDER_ERROR_STATUS_SUCCESS) {
|
||||||
builder->valid = false;
|
builder->valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status != NXT_BUILDER_ERROR_STATUS_UNKNOWN) {
|
if (status != DAWN_BUILDER_ERROR_STATUS_UNKNOWN) {
|
||||||
//* Unknown is the only status that can be returned without a call to GetResult
|
//* Unknown is the only status that can be returned without a call to GetResult
|
||||||
//* so we are guaranteed to have created an object.
|
//* so we are guaranteed to have created an object.
|
||||||
ASSERT(builder->builtObjectId != 0);
|
ASSERT(builder->builtObjectId != 0);
|
||||||
|
@ -259,7 +259,7 @@ namespace dawn { namespace wire {
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
void OnMapReadAsyncCallback(nxtBufferMapAsyncStatus status, const void* ptr, MapUserdata* data) {
|
void OnMapReadAsyncCallback(dawnBufferMapAsyncStatus status, const void* ptr, MapUserdata* data) {
|
||||||
ReturnBufferMapReadAsyncCallbackCmd cmd;
|
ReturnBufferMapReadAsyncCallbackCmd cmd;
|
||||||
cmd.bufferId = data->bufferId;
|
cmd.bufferId = data->bufferId;
|
||||||
cmd.bufferSerial = data->bufferSerial;
|
cmd.bufferSerial = data->bufferSerial;
|
||||||
|
@ -270,7 +270,7 @@ namespace dawn { namespace wire {
|
||||||
auto allocCmd = static_cast<ReturnBufferMapReadAsyncCallbackCmd*>(GetCmdSpace(sizeof(cmd)));
|
auto allocCmd = static_cast<ReturnBufferMapReadAsyncCallbackCmd*>(GetCmdSpace(sizeof(cmd)));
|
||||||
*allocCmd = cmd;
|
*allocCmd = cmd;
|
||||||
|
|
||||||
if (status == NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
||||||
allocCmd->dataLength = data->size;
|
allocCmd->dataLength = data->size;
|
||||||
|
|
||||||
void* dataAlloc = GetCmdSpace(data->size);
|
void* dataAlloc = GetCmdSpace(data->size);
|
||||||
|
@ -280,7 +280,7 @@ namespace dawn { namespace wire {
|
||||||
delete data;
|
delete data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnMapWriteAsyncCallback(nxtBufferMapAsyncStatus status, void* ptr, MapUserdata* data) {
|
void OnMapWriteAsyncCallback(dawnBufferMapAsyncStatus status, void* ptr, MapUserdata* data) {
|
||||||
ReturnBufferMapWriteAsyncCallbackCmd cmd;
|
ReturnBufferMapWriteAsyncCallbackCmd cmd;
|
||||||
cmd.bufferId = data->bufferId;
|
cmd.bufferId = data->bufferId;
|
||||||
cmd.bufferSerial = data->bufferSerial;
|
cmd.bufferSerial = data->bufferSerial;
|
||||||
|
@ -290,7 +290,7 @@ namespace dawn { namespace wire {
|
||||||
auto allocCmd = static_cast<ReturnBufferMapWriteAsyncCallbackCmd*>(GetCmdSpace(sizeof(cmd)));
|
auto allocCmd = static_cast<ReturnBufferMapWriteAsyncCallbackCmd*>(GetCmdSpace(sizeof(cmd)));
|
||||||
*allocCmd = cmd;
|
*allocCmd = cmd;
|
||||||
|
|
||||||
if (status == NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
||||||
auto* selfData = mKnownBuffer.Get(data->bufferId);
|
auto* selfData = mKnownBuffer.Get(data->bufferId);
|
||||||
ASSERT(selfData != nullptr);
|
ASSERT(selfData != nullptr);
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ namespace dawn { namespace wire {
|
||||||
selfData->valid = false;
|
selfData->valid = false;
|
||||||
//* If we are in GetResult, fake an error callback
|
//* If we are in GetResult, fake an error callback
|
||||||
{% if returns %}
|
{% if returns %}
|
||||||
On{{type.name.CamelCase()}}Error(NXT_BUILDER_ERROR_STATUS_ERROR, "Maybe monad", cmd.selfId, selfData->serial);
|
On{{type.name.CamelCase()}}Error(DAWN_BUILDER_ERROR_STATUS_ERROR, "Maybe monad", cmd.selfId, selfData->serial);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
return true;
|
return true;
|
||||||
|
@ -555,9 +555,9 @@ namespace dawn { namespace wire {
|
||||||
if (!buffer->valid) {
|
if (!buffer->valid) {
|
||||||
//* Fake the buffer returning a failure, data will be freed in this call.
|
//* Fake the buffer returning a failure, data will be freed in this call.
|
||||||
if (isWrite) {
|
if (isWrite) {
|
||||||
ForwardBufferMapWriteAsync(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
|
ForwardBufferMapWriteAsync(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
|
||||||
} else {
|
} else {
|
||||||
ForwardBufferMapReadAsync(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
|
ForwardBufferMapReadAsync(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -597,13 +597,13 @@ namespace dawn { namespace wire {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void ForwardDeviceErrorToServer(const char* message, nxtCallbackUserdata userdata) {
|
void ForwardDeviceErrorToServer(const char* message, dawnCallbackUserdata userdata) {
|
||||||
auto server = reinterpret_cast<Server*>(static_cast<intptr_t>(userdata));
|
auto server = reinterpret_cast<Server*>(static_cast<intptr_t>(userdata));
|
||||||
server->OnDeviceError(message);
|
server->OnDeviceError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
{% for type in by_category["object"] if type.is_builder%}
|
{% for type in by_category["object"] if type.is_builder%}
|
||||||
void Forward{{type.name.CamelCase()}}ToClient(nxtBuilderErrorStatus status, const char* message, nxtCallbackUserdata userdata1, nxtCallbackUserdata userdata2) {
|
void Forward{{type.name.CamelCase()}}ToClient(dawnBuilderErrorStatus status, const char* message, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2) {
|
||||||
auto server = reinterpret_cast<Server*>(static_cast<uintptr_t>(userdata1));
|
auto server = reinterpret_cast<Server*>(static_cast<uintptr_t>(userdata1));
|
||||||
uint32_t id = userdata2 & 0xFFFFFFFFu;
|
uint32_t id = userdata2 & 0xFFFFFFFFu;
|
||||||
uint32_t serial = userdata2 >> uint64_t(32);
|
uint32_t serial = userdata2 >> uint64_t(32);
|
||||||
|
@ -611,18 +611,18 @@ namespace dawn { namespace wire {
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
void ForwardBufferMapReadAsync(nxtBufferMapAsyncStatus status, const void* ptr, nxtCallbackUserdata userdata) {
|
void ForwardBufferMapReadAsync(dawnBufferMapAsyncStatus status, const void* ptr, dawnCallbackUserdata userdata) {
|
||||||
auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
|
auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
|
||||||
data->server->OnMapReadAsyncCallback(status, ptr, data);
|
data->server->OnMapReadAsyncCallback(status, ptr, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardBufferMapWriteAsync(nxtBufferMapAsyncStatus status, void* ptr, nxtCallbackUserdata userdata) {
|
void ForwardBufferMapWriteAsync(dawnBufferMapAsyncStatus status, void* ptr, dawnCallbackUserdata userdata) {
|
||||||
auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
|
auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
|
||||||
data->server->OnMapWriteAsyncCallback(status, ptr, data);
|
data->server->OnMapWriteAsyncCallback(status, ptr, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandHandler* NewServerCommandHandler(nxtDevice device, const nxtProcTable& procs, CommandSerializer* serializer) {
|
CommandHandler* NewServerCommandHandler(dawnDevice device, const nxtProcTable& procs, CommandSerializer* serializer) {
|
||||||
return new server::Server(device, procs, serializer);
|
return new server::Server(device, procs, serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ namespace backend {
|
||||||
|
|
||||||
BufferBase::~BufferBase() {
|
BufferBase::~BufferBase() {
|
||||||
if (mIsMapped) {
|
if (mIsMapped) {
|
||||||
CallMapReadCallback(mMapSerial, NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
|
CallMapReadCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
|
||||||
CallMapWriteCallback(mMapSerial, NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
|
CallMapWriteCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,26 +52,26 @@ namespace backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::CallMapReadCallback(uint32_t serial,
|
void BufferBase::CallMapReadCallback(uint32_t serial,
|
||||||
nxtBufferMapAsyncStatus status,
|
dawnBufferMapAsyncStatus status,
|
||||||
const void* pointer) {
|
const void* pointer) {
|
||||||
if (mMapReadCallback != nullptr && serial == mMapSerial) {
|
if (mMapReadCallback != nullptr && serial == mMapSerial) {
|
||||||
ASSERT(mMapWriteCallback == nullptr);
|
ASSERT(mMapWriteCallback == nullptr);
|
||||||
// Tag the callback as fired before firing it, otherwise it could fire a second time if
|
// 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.
|
// for example buffer.Unmap() is called inside the application-provided callback.
|
||||||
nxtBufferMapReadCallback callback = mMapReadCallback;
|
dawnBufferMapReadCallback callback = mMapReadCallback;
|
||||||
mMapReadCallback = nullptr;
|
mMapReadCallback = nullptr;
|
||||||
callback(status, pointer, mMapUserdata);
|
callback(status, pointer, mMapUserdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::CallMapWriteCallback(uint32_t serial,
|
void BufferBase::CallMapWriteCallback(uint32_t serial,
|
||||||
nxtBufferMapAsyncStatus status,
|
dawnBufferMapAsyncStatus status,
|
||||||
void* pointer) {
|
void* pointer) {
|
||||||
if (mMapWriteCallback != nullptr && serial == mMapSerial) {
|
if (mMapWriteCallback != nullptr && serial == mMapSerial) {
|
||||||
ASSERT(mMapReadCallback == nullptr);
|
ASSERT(mMapReadCallback == nullptr);
|
||||||
// Tag the callback as fired before firing it, otherwise it could fire a second time if
|
// 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.
|
// for example buffer.Unmap() is called inside the application-provided callback.
|
||||||
nxtBufferMapWriteCallback callback = mMapWriteCallback;
|
dawnBufferMapWriteCallback callback = mMapWriteCallback;
|
||||||
mMapWriteCallback = nullptr;
|
mMapWriteCallback = nullptr;
|
||||||
callback(status, pointer, mMapUserdata);
|
callback(status, pointer, mMapUserdata);
|
||||||
}
|
}
|
||||||
|
@ -93,10 +93,10 @@ namespace backend {
|
||||||
|
|
||||||
void BufferBase::MapReadAsync(uint32_t start,
|
void BufferBase::MapReadAsync(uint32_t start,
|
||||||
uint32_t size,
|
uint32_t size,
|
||||||
nxtBufferMapReadCallback callback,
|
dawnBufferMapReadCallback callback,
|
||||||
nxtCallbackUserdata userdata) {
|
dawnCallbackUserdata userdata) {
|
||||||
if (!ValidateMapBase(start, size, dawn::BufferUsageBit::MapRead)) {
|
if (!ValidateMapBase(start, size, dawn::BufferUsageBit::MapRead)) {
|
||||||
callback(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
|
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,10 +113,10 @@ namespace backend {
|
||||||
|
|
||||||
void BufferBase::MapWriteAsync(uint32_t start,
|
void BufferBase::MapWriteAsync(uint32_t start,
|
||||||
uint32_t size,
|
uint32_t size,
|
||||||
nxtBufferMapWriteCallback callback,
|
dawnBufferMapWriteCallback callback,
|
||||||
nxtCallbackUserdata userdata) {
|
dawnCallbackUserdata userdata) {
|
||||||
if (!ValidateMapBase(start, size, dawn::BufferUsageBit::MapWrite)) {
|
if (!ValidateMapBase(start, size, dawn::BufferUsageBit::MapWrite)) {
|
||||||
callback(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
|
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,8 +139,8 @@ namespace backend {
|
||||||
|
|
||||||
// A map request can only be called once, so this will fire only if the request wasn't
|
// A map request can only be called once, so this will fire only if the request wasn't
|
||||||
// completed before the Unmap
|
// completed before the Unmap
|
||||||
CallMapReadCallback(mMapSerial, NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
|
CallMapReadCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
|
||||||
CallMapWriteCallback(mMapSerial, NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
|
CallMapWriteCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
|
||||||
UnmapImpl();
|
UnmapImpl();
|
||||||
mIsMapped = false;
|
mIsMapped = false;
|
||||||
mMapReadCallback = nullptr;
|
mMapReadCallback = nullptr;
|
||||||
|
|
|
@ -46,19 +46,19 @@ namespace backend {
|
||||||
void SetSubData(uint32_t start, uint32_t count, const uint8_t* data);
|
void SetSubData(uint32_t start, uint32_t count, const uint8_t* data);
|
||||||
void MapReadAsync(uint32_t start,
|
void MapReadAsync(uint32_t start,
|
||||||
uint32_t size,
|
uint32_t size,
|
||||||
nxtBufferMapReadCallback callback,
|
dawnBufferMapReadCallback callback,
|
||||||
nxtCallbackUserdata userdata);
|
dawnCallbackUserdata userdata);
|
||||||
void MapWriteAsync(uint32_t start,
|
void MapWriteAsync(uint32_t start,
|
||||||
uint32_t size,
|
uint32_t size,
|
||||||
nxtBufferMapWriteCallback callback,
|
dawnBufferMapWriteCallback callback,
|
||||||
nxtCallbackUserdata userdata);
|
dawnCallbackUserdata userdata);
|
||||||
void Unmap();
|
void Unmap();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CallMapReadCallback(uint32_t serial,
|
void CallMapReadCallback(uint32_t serial,
|
||||||
nxtBufferMapAsyncStatus status,
|
dawnBufferMapAsyncStatus status,
|
||||||
const void* pointer);
|
const void* pointer);
|
||||||
void CallMapWriteCallback(uint32_t serial, nxtBufferMapAsyncStatus status, void* pointer);
|
void CallMapWriteCallback(uint32_t serial, dawnBufferMapAsyncStatus status, void* pointer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) = 0;
|
virtual void SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) = 0;
|
||||||
|
@ -72,9 +72,9 @@ namespace backend {
|
||||||
uint32_t mSize;
|
uint32_t mSize;
|
||||||
dawn::BufferUsageBit mAllowedUsage = dawn::BufferUsageBit::None;
|
dawn::BufferUsageBit mAllowedUsage = dawn::BufferUsageBit::None;
|
||||||
|
|
||||||
nxtBufferMapReadCallback mMapReadCallback = nullptr;
|
dawnBufferMapReadCallback mMapReadCallback = nullptr;
|
||||||
nxtBufferMapWriteCallback mMapWriteCallback = nullptr;
|
dawnBufferMapWriteCallback mMapWriteCallback = nullptr;
|
||||||
nxtCallbackUserdata mMapUserdata = 0;
|
dawnCallbackUserdata mMapUserdata = 0;
|
||||||
uint32_t mMapSerial = 0;
|
uint32_t mMapSerial = 0;
|
||||||
|
|
||||||
bool mIsMapped = false;
|
bool mIsMapped = false;
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace backend {
|
||||||
|
|
||||||
BuilderBase::~BuilderBase() {
|
BuilderBase::~BuilderBase() {
|
||||||
if (!mIsConsumed && mCallback != nullptr) {
|
if (!mIsConsumed && mCallback != nullptr) {
|
||||||
mCallback(NXT_BUILDER_ERROR_STATUS_UNKNOWN, "Builder destroyed before GetResult",
|
mCallback(DAWN_BUILDER_ERROR_STATUS_UNKNOWN, "Builder destroyed before GetResult",
|
||||||
mUserdata1, mUserdata2);
|
mUserdata1, mUserdata2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ namespace backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCallback != nullptr) {
|
if (mCallback != nullptr) {
|
||||||
mCallback(static_cast<nxtBuilderErrorStatus>(mStoredStatus), mStoredMessage.c_str(),
|
mCallback(static_cast<dawnBuilderErrorStatus>(mStoredStatus), mStoredMessage.c_str(),
|
||||||
mUserdata1, mUserdata2);
|
mUserdata1, mUserdata2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,8 @@ namespace backend {
|
||||||
mAllowedUsage = allowedUsage;
|
mAllowedUsage = allowedUsage;
|
||||||
mWidth = width;
|
mWidth = width;
|
||||||
mHeight = height;
|
mHeight = height;
|
||||||
mImplementation.Configure(mImplementation.userData, static_cast<nxtTextureFormat>(format),
|
mImplementation.Configure(mImplementation.userData, static_cast<dawnTextureFormat>(format),
|
||||||
static_cast<nxtTextureUsageBit>(allowedUsage), width, height);
|
static_cast<dawnTextureUsageBit>(allowedUsage), width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureBase* SwapChainBase::GetNextTexture() {
|
TextureBase* SwapChainBase::GetNextTexture() {
|
||||||
|
|
|
@ -155,9 +155,9 @@ namespace backend { namespace d3d12 {
|
||||||
|
|
||||||
void Buffer::OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite) {
|
void Buffer::OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite) {
|
||||||
if (isWrite) {
|
if (isWrite) {
|
||||||
CallMapWriteCallback(mapSerial, NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
||||||
} else {
|
} else {
|
||||||
CallMapReadCallback(mapSerial, NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,26 +43,26 @@ namespace backend { namespace d3d12 {
|
||||||
nxtProcTable GetNonValidatingProcs();
|
nxtProcTable GetNonValidatingProcs();
|
||||||
nxtProcTable GetValidatingProcs();
|
nxtProcTable GetValidatingProcs();
|
||||||
|
|
||||||
void Init(nxtProcTable* procs, nxtDevice* device) {
|
void Init(nxtProcTable* procs, dawnDevice* device) {
|
||||||
*device = nullptr;
|
*device = nullptr;
|
||||||
*procs = GetValidatingProcs();
|
*procs = GetValidatingProcs();
|
||||||
*device = reinterpret_cast<nxtDevice>(new Device());
|
*device = reinterpret_cast<dawnDevice>(new Device());
|
||||||
}
|
}
|
||||||
|
|
||||||
dawnSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, HWND window) {
|
dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device, HWND window) {
|
||||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||||
|
|
||||||
dawnSwapChainImplementation impl;
|
dawnSwapChainImplementation impl;
|
||||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, window));
|
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, window));
|
||||||
impl.textureUsage = NXT_TEXTURE_USAGE_BIT_PRESENT;
|
impl.textureUsage = DAWN_TEXTURE_USAGE_BIT_PRESENT;
|
||||||
|
|
||||||
return impl;
|
return impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
dawnTextureFormat GetNativeSwapChainPreferredFormat(
|
||||||
const dawnSwapChainImplementation* swapChain) {
|
const dawnSwapChainImplementation* swapChain) {
|
||||||
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
||||||
return static_cast<nxtTextureFormat>(impl->GetPreferredFormat());
|
return static_cast<dawnTextureFormat>(impl->GetPreferredFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASSERT_SUCCESS(HRESULT hr) {
|
void ASSERT_SUCCESS(HRESULT hr) {
|
||||||
|
|
|
@ -21,15 +21,15 @@
|
||||||
namespace backend { namespace d3d12 {
|
namespace backend { namespace d3d12 {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
DXGI_USAGE D3D12SwapChainBufferUsage(nxtTextureUsageBit allowedUsages) {
|
DXGI_USAGE D3D12SwapChainBufferUsage(dawnTextureUsageBit allowedUsages) {
|
||||||
DXGI_USAGE usage = DXGI_CPU_ACCESS_NONE;
|
DXGI_USAGE usage = DXGI_CPU_ACCESS_NONE;
|
||||||
if (allowedUsages & NXT_TEXTURE_USAGE_BIT_SAMPLED) {
|
if (allowedUsages & DAWN_TEXTURE_USAGE_BIT_SAMPLED) {
|
||||||
usage |= DXGI_USAGE_SHADER_INPUT;
|
usage |= DXGI_USAGE_SHADER_INPUT;
|
||||||
}
|
}
|
||||||
if (allowedUsages & NXT_TEXTURE_USAGE_BIT_STORAGE) {
|
if (allowedUsages & DAWN_TEXTURE_USAGE_BIT_STORAGE) {
|
||||||
usage |= DXGI_USAGE_UNORDERED_ACCESS;
|
usage |= DXGI_USAGE_UNORDERED_ACCESS;
|
||||||
}
|
}
|
||||||
if (allowedUsages & NXT_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT) {
|
if (allowedUsages & DAWN_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT) {
|
||||||
usage |= DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
usage |= DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
}
|
}
|
||||||
return usage;
|
return usage;
|
||||||
|
@ -48,13 +48,13 @@ namespace backend { namespace d3d12 {
|
||||||
void NativeSwapChainImpl::Init(dawnWSIContextD3D12* /*context*/) {
|
void NativeSwapChainImpl::Init(dawnWSIContextD3D12* /*context*/) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawnSwapChainError NativeSwapChainImpl::Configure(nxtTextureFormat format,
|
dawnSwapChainError NativeSwapChainImpl::Configure(dawnTextureFormat format,
|
||||||
nxtTextureUsageBit usage,
|
dawnTextureUsageBit usage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
ASSERT(width > 0);
|
ASSERT(width > 0);
|
||||||
ASSERT(height > 0);
|
ASSERT(height > 0);
|
||||||
ASSERT(format == static_cast<nxtTextureFormat>(GetPreferredFormat()));
|
ASSERT(format == static_cast<dawnTextureFormat>(GetPreferredFormat()));
|
||||||
|
|
||||||
ComPtr<IDXGIFactory4> factory = mDevice->GetFactory();
|
ComPtr<IDXGIFactory4> factory = mDevice->GetFactory();
|
||||||
ComPtr<ID3D12CommandQueue> queue = mDevice->GetCommandQueue();
|
ComPtr<ID3D12CommandQueue> queue = mDevice->GetCommandQueue();
|
||||||
|
|
|
@ -34,8 +34,8 @@ namespace backend { namespace d3d12 {
|
||||||
~NativeSwapChainImpl();
|
~NativeSwapChainImpl();
|
||||||
|
|
||||||
void Init(dawnWSIContextD3D12* context);
|
void Init(dawnWSIContextD3D12* context);
|
||||||
dawnSwapChainError Configure(nxtTextureFormat format,
|
dawnSwapChainError Configure(dawnTextureFormat format,
|
||||||
nxtTextureUsageBit,
|
dawnTextureUsageBit,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
|
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
|
||||||
|
|
|
@ -24,10 +24,10 @@ namespace backend { namespace d3d12 {
|
||||||
SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
|
SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
|
||||||
const auto& im = GetImplementation();
|
const auto& im = GetImplementation();
|
||||||
dawnWSIContextD3D12 wsiContext = {};
|
dawnWSIContextD3D12 wsiContext = {};
|
||||||
wsiContext.device = reinterpret_cast<nxtDevice>(GetDevice());
|
wsiContext.device = reinterpret_cast<dawnDevice>(GetDevice());
|
||||||
im.Init(im.userData, &wsiContext);
|
im.Init(im.userData, &wsiContext);
|
||||||
|
|
||||||
ASSERT(im.textureUsage != NXT_TEXTURE_USAGE_BIT_NONE);
|
ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_BIT_NONE);
|
||||||
mTextureUsage = static_cast<dawn::TextureUsageBit>(im.textureUsage);
|
mTextureUsage = static_cast<dawn::TextureUsageBit>(im.textureUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,9 @@ namespace backend { namespace metal {
|
||||||
void Buffer::OnMapCommandSerialFinished(uint32_t mapSerial, uint32_t offset, bool isWrite) {
|
void Buffer::OnMapCommandSerialFinished(uint32_t mapSerial, uint32_t offset, bool isWrite) {
|
||||||
char* data = reinterpret_cast<char*>([mMtlBuffer contents]);
|
char* data = reinterpret_cast<char*>([mMtlBuffer contents]);
|
||||||
if (isWrite) {
|
if (isWrite) {
|
||||||
CallMapWriteCallback(mapSerial, NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data + offset);
|
CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data + offset);
|
||||||
} else {
|
} else {
|
||||||
CallMapReadCallback(mapSerial, NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data + offset);
|
CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data + offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,11 @@ namespace backend { namespace metal {
|
||||||
nxtProcTable GetNonValidatingProcs();
|
nxtProcTable GetNonValidatingProcs();
|
||||||
nxtProcTable GetValidatingProcs();
|
nxtProcTable GetValidatingProcs();
|
||||||
|
|
||||||
void Init(id<MTLDevice> metalDevice, nxtProcTable* procs, nxtDevice* device) {
|
void Init(id<MTLDevice> metalDevice, nxtProcTable* procs, dawnDevice* device) {
|
||||||
*device = nullptr;
|
*device = nullptr;
|
||||||
|
|
||||||
*procs = GetValidatingProcs();
|
*procs = GetValidatingProcs();
|
||||||
*device = reinterpret_cast<nxtDevice>(new Device(metalDevice));
|
*device = reinterpret_cast<dawnDevice>(new Device(metalDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Device
|
// Device
|
||||||
|
|
|
@ -23,9 +23,9 @@ namespace backend { namespace null {
|
||||||
nxtProcTable GetNonValidatingProcs();
|
nxtProcTable GetNonValidatingProcs();
|
||||||
nxtProcTable GetValidatingProcs();
|
nxtProcTable GetValidatingProcs();
|
||||||
|
|
||||||
void Init(nxtProcTable* procs, nxtDevice* device) {
|
void Init(nxtProcTable* procs, dawnDevice* device) {
|
||||||
*procs = GetValidatingProcs();
|
*procs = GetValidatingProcs();
|
||||||
*device = reinterpret_cast<nxtDevice>(new Device);
|
*device = reinterpret_cast<dawnDevice>(new Device);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Device
|
// Device
|
||||||
|
@ -135,9 +135,9 @@ namespace backend { namespace null {
|
||||||
|
|
||||||
void Buffer::MapReadOperationCompleted(uint32_t serial, void* ptr, bool isWrite) {
|
void Buffer::MapReadOperationCompleted(uint32_t serial, void* ptr, bool isWrite) {
|
||||||
if (isWrite) {
|
if (isWrite) {
|
||||||
CallMapWriteCallback(serial, NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, ptr);
|
CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, ptr);
|
||||||
} else {
|
} else {
|
||||||
CallMapReadCallback(serial, NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, ptr);
|
CallMapReadCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace backend { namespace opengl {
|
||||||
// version of OpenGL that would let us map the buffer unsynchronized.
|
// version of OpenGL that would let us map the buffer unsynchronized.
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
||||||
void* data = glMapBufferRange(GL_ARRAY_BUFFER, start, count, GL_MAP_READ_BIT);
|
void* data = glMapBufferRange(GL_ARRAY_BUFFER, start, count, GL_MAP_READ_BIT);
|
||||||
CallMapReadCallback(serial, NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
CallMapReadCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
|
void Buffer::MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
|
||||||
|
@ -46,7 +46,7 @@ namespace backend { namespace opengl {
|
||||||
// version of OpenGL that would let us map the buffer unsynchronized.
|
// version of OpenGL that would let us map the buffer unsynchronized.
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
||||||
void* data = glMapBufferRange(GL_ARRAY_BUFFER, start, count, GL_MAP_WRITE_BIT);
|
void* data = glMapBufferRange(GL_ARRAY_BUFFER, start, count, GL_MAP_WRITE_BIT);
|
||||||
CallMapWriteCallback(serial, NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::UnmapImpl() {
|
void Buffer::UnmapImpl() {
|
||||||
|
|
|
@ -35,13 +35,13 @@ namespace backend { namespace opengl {
|
||||||
nxtProcTable GetNonValidatingProcs();
|
nxtProcTable GetNonValidatingProcs();
|
||||||
nxtProcTable GetValidatingProcs();
|
nxtProcTable GetValidatingProcs();
|
||||||
|
|
||||||
void Init(void* (*getProc)(const char*), nxtProcTable* procs, nxtDevice* device) {
|
void Init(void* (*getProc)(const char*), nxtProcTable* procs, dawnDevice* device) {
|
||||||
*device = nullptr;
|
*device = nullptr;
|
||||||
|
|
||||||
gladLoadGLLoader(reinterpret_cast<GLADloadproc>(getProc));
|
gladLoadGLLoader(reinterpret_cast<GLADloadproc>(getProc));
|
||||||
|
|
||||||
*procs = GetValidatingProcs();
|
*procs = GetValidatingProcs();
|
||||||
*device = reinterpret_cast<nxtDevice>(new Device);
|
*device = reinterpret_cast<dawnDevice>(new Device);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
|
|
@ -150,11 +150,11 @@ namespace backend { namespace vulkan {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::OnMapReadCommandSerialFinished(uint32_t mapSerial, const void* data) {
|
void Buffer::OnMapReadCommandSerialFinished(uint32_t mapSerial, const void* data) {
|
||||||
CallMapReadCallback(mapSerial, NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::OnMapWriteCommandSerialFinished(uint32_t mapSerial, void* data) {
|
void Buffer::OnMapWriteCommandSerialFinished(uint32_t mapSerial, void* data) {
|
||||||
CallMapWriteCallback(mapSerial, NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkBuffer Buffer::GetHandle() const {
|
VkBuffer Buffer::GetHandle() const {
|
||||||
|
|
|
@ -56,31 +56,31 @@ namespace backend { namespace vulkan {
|
||||||
nxtProcTable GetValidatingProcs();
|
nxtProcTable GetValidatingProcs();
|
||||||
|
|
||||||
void Init(nxtProcTable* procs,
|
void Init(nxtProcTable* procs,
|
||||||
nxtDevice* device,
|
dawnDevice* device,
|
||||||
const std::vector<const char*>& requiredInstanceExtensions) {
|
const std::vector<const char*>& requiredInstanceExtensions) {
|
||||||
*procs = GetValidatingProcs();
|
*procs = GetValidatingProcs();
|
||||||
*device = reinterpret_cast<nxtDevice>(new Device(requiredInstanceExtensions));
|
*device = reinterpret_cast<dawnDevice>(new Device(requiredInstanceExtensions));
|
||||||
}
|
}
|
||||||
|
|
||||||
VkInstance GetInstance(nxtDevice device) {
|
VkInstance GetInstance(dawnDevice device) {
|
||||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||||
return backendDevice->GetInstance();
|
return backendDevice->GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
dawnSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, VkSurfaceKHR surface) {
|
dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device, VkSurfaceKHR surface) {
|
||||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||||
|
|
||||||
dawnSwapChainImplementation impl;
|
dawnSwapChainImplementation impl;
|
||||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, surface));
|
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, surface));
|
||||||
impl.textureUsage = NXT_TEXTURE_USAGE_BIT_PRESENT;
|
impl.textureUsage = DAWN_TEXTURE_USAGE_BIT_PRESENT;
|
||||||
|
|
||||||
return impl;
|
return impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
dawnTextureFormat GetNativeSwapChainPreferredFormat(
|
||||||
const dawnSwapChainImplementation* swapChain) {
|
const dawnSwapChainImplementation* swapChain) {
|
||||||
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
||||||
return static_cast<nxtTextureFormat>(impl->GetPreferredFormat());
|
return static_cast<dawnTextureFormat>(impl->GetPreferredFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Device
|
// Device
|
||||||
|
|
|
@ -67,8 +67,8 @@ namespace backend { namespace vulkan {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dawnSwapChainError NativeSwapChainImpl::Configure(nxtTextureFormat format,
|
dawnSwapChainError NativeSwapChainImpl::Configure(dawnTextureFormat format,
|
||||||
nxtTextureUsageBit usage,
|
dawnTextureUsageBit usage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
ASSERT(mInfo.capabilities.minImageExtent.width <= width);
|
ASSERT(mInfo.capabilities.minImageExtent.width <= width);
|
||||||
|
@ -76,7 +76,7 @@ namespace backend { namespace vulkan {
|
||||||
ASSERT(mInfo.capabilities.minImageExtent.height <= height);
|
ASSERT(mInfo.capabilities.minImageExtent.height <= height);
|
||||||
ASSERT(mInfo.capabilities.maxImageExtent.height >= height);
|
ASSERT(mInfo.capabilities.maxImageExtent.height >= height);
|
||||||
|
|
||||||
ASSERT(format == static_cast<nxtTextureFormat>(GetPreferredFormat()));
|
ASSERT(format == static_cast<dawnTextureFormat>(GetPreferredFormat()));
|
||||||
// TODO(cwallez@chromium.org): need to check usage works too
|
// TODO(cwallez@chromium.org): need to check usage works too
|
||||||
|
|
||||||
// Create the swapchain with the configuration we chose
|
// Create the swapchain with the configuration we chose
|
||||||
|
|
|
@ -32,8 +32,8 @@ namespace backend { namespace vulkan {
|
||||||
~NativeSwapChainImpl();
|
~NativeSwapChainImpl();
|
||||||
|
|
||||||
void Init(dawnWSIContextVulkan* context);
|
void Init(dawnWSIContextVulkan* context);
|
||||||
dawnSwapChainError Configure(nxtTextureFormat format,
|
dawnSwapChainError Configure(dawnTextureFormat format,
|
||||||
nxtTextureUsageBit,
|
dawnTextureUsageBit,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
|
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace backend { namespace vulkan {
|
||||||
dawnWSIContextVulkan wsiContext = {};
|
dawnWSIContextVulkan wsiContext = {};
|
||||||
im.Init(im.userData, &wsiContext);
|
im.Init(im.userData, &wsiContext);
|
||||||
|
|
||||||
ASSERT(im.textureUsage != NXT_TEXTURE_USAGE_BIT_NONE);
|
ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_BIT_NONE);
|
||||||
mTextureUsage = static_cast<dawn::TextureUsageBit>(im.textureUsage);
|
mTextureUsage = static_cast<dawn::TextureUsageBit>(im.textureUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ dawnSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
|
||||||
reinterpret_cast<T*>(userData)->Init(ctx);
|
reinterpret_cast<T*>(userData)->Init(ctx);
|
||||||
};
|
};
|
||||||
impl.Destroy = [](void* userData) { delete reinterpret_cast<T*>(userData); };
|
impl.Destroy = [](void* userData) { delete reinterpret_cast<T*>(userData); };
|
||||||
impl.Configure = [](void* userData, nxtTextureFormat format, nxtTextureUsageBit allowedUsage,
|
impl.Configure = [](void* userData, dawnTextureFormat format, dawnTextureUsageBit allowedUsage,
|
||||||
uint32_t width, uint32_t height) {
|
uint32_t width, uint32_t height) {
|
||||||
return reinterpret_cast<T*>(userData)->Configure(format, allowedUsage, width, height);
|
return reinterpret_cast<T*>(userData)->Configure(format, allowedUsage, width, height);
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,8 +40,8 @@ typedef struct {
|
||||||
|
|
||||||
/// Configure/reconfigure the swap chain.
|
/// Configure/reconfigure the swap chain.
|
||||||
dawnSwapChainError (*Configure)(void* userData,
|
dawnSwapChainError (*Configure)(void* userData,
|
||||||
nxtTextureFormat format,
|
dawnTextureFormat format,
|
||||||
nxtTextureUsageBit allowedUsage,
|
dawnTextureUsageBit allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
|
|
||||||
|
@ -55,12 +55,12 @@ typedef struct {
|
||||||
void* userData;
|
void* userData;
|
||||||
|
|
||||||
/// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
|
/// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
|
||||||
nxtTextureUsageBit textureUsage;
|
dawnTextureUsageBit textureUsage;
|
||||||
} dawnSwapChainImplementation;
|
} dawnSwapChainImplementation;
|
||||||
|
|
||||||
#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
|
#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
nxtDevice device = nullptr;
|
dawnDevice device = nullptr;
|
||||||
} dawnWSIContextD3D12;
|
} dawnWSIContextD3D12;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace {
|
||||||
|
|
||||||
// End2end tests should test valid commands produce the expected result so no error
|
// End2end tests should test valid commands produce the expected result so no error
|
||||||
// should happen. Failure cases should be tested in the validation tests.
|
// should happen. Failure cases should be tested in the validation tests.
|
||||||
void DeviceErrorCauseTestFailure(const char* message, nxtCallbackUserdata) {
|
void DeviceErrorCauseTestFailure(const char* message, dawnCallbackUserdata) {
|
||||||
FAIL() << "Device level failure: " << message;
|
FAIL() << "Device level failure: " << message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,12 +136,12 @@ void NXTTest::SetUp() {
|
||||||
|
|
||||||
mBinding->SetWindow(testWindow);
|
mBinding->SetWindow(testWindow);
|
||||||
|
|
||||||
nxtDevice backendDevice;
|
dawnDevice backendDevice;
|
||||||
nxtProcTable backendProcs;
|
nxtProcTable backendProcs;
|
||||||
mBinding->GetProcAndDevice(&backendProcs, &backendDevice);
|
mBinding->GetProcAndDevice(&backendProcs, &backendDevice);
|
||||||
|
|
||||||
// Choose whether to use the backend procs and devices directly, or set up the wire.
|
// Choose whether to use the backend procs and devices directly, or set up the wire.
|
||||||
nxtDevice cDevice = nullptr;
|
dawnDevice cDevice = nullptr;
|
||||||
nxtProcTable procs;
|
nxtProcTable procs;
|
||||||
|
|
||||||
if (gTestUsesWire) {
|
if (gTestUsesWire) {
|
||||||
|
@ -151,7 +151,7 @@ void NXTTest::SetUp() {
|
||||||
mWireServer = dawn::wire::NewServerCommandHandler(backendDevice, backendProcs, mS2cBuf);
|
mWireServer = dawn::wire::NewServerCommandHandler(backendDevice, backendProcs, mS2cBuf);
|
||||||
mC2sBuf->SetHandler(mWireServer);
|
mC2sBuf->SetHandler(mWireServer);
|
||||||
|
|
||||||
nxtDevice clientDevice;
|
dawnDevice clientDevice;
|
||||||
nxtProcTable clientProcs;
|
nxtProcTable clientProcs;
|
||||||
mWireClient = dawn::wire::NewClientDevice(&clientProcs, &clientDevice, mC2sBuf);
|
mWireClient = dawn::wire::NewClientDevice(&clientProcs, &clientDevice, mC2sBuf);
|
||||||
mS2cBuf->SetHandler(mWireClient);
|
mS2cBuf->SetHandler(mWireClient);
|
||||||
|
@ -320,10 +320,10 @@ void NXTTest::MapSlotsSynchronously() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void NXTTest::SlotMapReadCallback(nxtBufferMapAsyncStatus status,
|
void NXTTest::SlotMapReadCallback(dawnBufferMapAsyncStatus status,
|
||||||
const void* data,
|
const void* data,
|
||||||
nxtCallbackUserdata userdata_) {
|
dawnCallbackUserdata userdata_) {
|
||||||
DAWN_ASSERT(status == NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS);
|
DAWN_ASSERT(status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS);
|
||||||
|
|
||||||
auto userdata = reinterpret_cast<MapReadUserdata*>(static_cast<uintptr_t>(userdata_));
|
auto userdata = reinterpret_cast<MapReadUserdata*>(static_cast<uintptr_t>(userdata_));
|
||||||
userdata->test->mReadbackSlots[userdata->slot].mappedData = data;
|
userdata->test->mReadbackSlots[userdata->slot].mappedData = data;
|
||||||
|
|
|
@ -128,9 +128,9 @@ class NXTTest : public ::testing::TestWithParam<BackendType> {
|
||||||
|
|
||||||
// Maps all the buffers and fill ReadbackSlot::mappedData
|
// Maps all the buffers and fill ReadbackSlot::mappedData
|
||||||
void MapSlotsSynchronously();
|
void MapSlotsSynchronously();
|
||||||
static void SlotMapReadCallback(nxtBufferMapAsyncStatus status,
|
static void SlotMapReadCallback(dawnBufferMapAsyncStatus status,
|
||||||
const void* data,
|
const void* data,
|
||||||
nxtCallbackUserdata userdata);
|
dawnCallbackUserdata userdata);
|
||||||
size_t mNumPendingMapOperations = 0;
|
size_t mNumPendingMapOperations = 0;
|
||||||
|
|
||||||
// Reserve space where the data for an expectation can be copied
|
// Reserve space where the data for an expectation can be copied
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
class BufferMapReadTests : public NXTTest {
|
class BufferMapReadTests : public NXTTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static void MapReadCallback(nxtBufferMapAsyncStatus status, const void* data, nxtCallbackUserdata userdata) {
|
static void MapReadCallback(dawnBufferMapAsyncStatus status, const void* data, dawnCallbackUserdata userdata) {
|
||||||
ASSERT_EQ(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
ASSERT_EQ(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
||||||
ASSERT_NE(nullptr, data);
|
ASSERT_NE(nullptr, data);
|
||||||
|
|
||||||
auto test = reinterpret_cast<BufferMapReadTests*>(static_cast<uintptr_t>(userdata));
|
auto test = reinterpret_cast<BufferMapReadTests*>(static_cast<uintptr_t>(userdata));
|
||||||
|
@ -115,8 +115,8 @@ NXT_INSTANTIATE_TEST(BufferMapReadTests, D3D12Backend, MetalBackend, OpenGLBacke
|
||||||
class BufferMapWriteTests : public NXTTest {
|
class BufferMapWriteTests : public NXTTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static void MapWriteCallback(nxtBufferMapAsyncStatus status, void* data, nxtCallbackUserdata userdata) {
|
static void MapWriteCallback(dawnBufferMapAsyncStatus status, void* data, dawnCallbackUserdata userdata) {
|
||||||
ASSERT_EQ(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
ASSERT_EQ(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
||||||
ASSERT_NE(nullptr, data);
|
ASSERT_NE(nullptr, data);
|
||||||
|
|
||||||
auto test = reinterpret_cast<BufferMapWriteTests*>(static_cast<uintptr_t>(userdata));
|
auto test = reinterpret_cast<BufferMapWriteTests*>(static_cast<uintptr_t>(userdata));
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,22 +20,22 @@ using namespace testing;
|
||||||
|
|
||||||
class MockBufferMapReadCallback {
|
class MockBufferMapReadCallback {
|
||||||
public:
|
public:
|
||||||
MOCK_METHOD3(Call, void(nxtBufferMapAsyncStatus status, const uint32_t* ptr, nxtCallbackUserdata userdata));
|
MOCK_METHOD3(Call, void(dawnBufferMapAsyncStatus status, const uint32_t* ptr, dawnCallbackUserdata userdata));
|
||||||
};
|
};
|
||||||
|
|
||||||
static MockBufferMapReadCallback* mockBufferMapReadCallback = nullptr;
|
static MockBufferMapReadCallback* mockBufferMapReadCallback = nullptr;
|
||||||
static void ToMockBufferMapReadCallback(nxtBufferMapAsyncStatus status, const void* ptr, nxtCallbackUserdata userdata) {
|
static void ToMockBufferMapReadCallback(dawnBufferMapAsyncStatus status, const void* ptr, dawnCallbackUserdata userdata) {
|
||||||
// Assume the data is uint32_t to make writing matchers easier
|
// Assume the data is uint32_t to make writing matchers easier
|
||||||
mockBufferMapReadCallback->Call(status, reinterpret_cast<const uint32_t*>(ptr), userdata);
|
mockBufferMapReadCallback->Call(status, reinterpret_cast<const uint32_t*>(ptr), userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockBufferMapWriteCallback {
|
class MockBufferMapWriteCallback {
|
||||||
public:
|
public:
|
||||||
MOCK_METHOD3(Call, void(nxtBufferMapAsyncStatus status, uint32_t* ptr, nxtCallbackUserdata userdata));
|
MOCK_METHOD3(Call, void(dawnBufferMapAsyncStatus status, uint32_t* ptr, dawnCallbackUserdata userdata));
|
||||||
};
|
};
|
||||||
|
|
||||||
static MockBufferMapWriteCallback* mockBufferMapWriteCallback = nullptr;
|
static MockBufferMapWriteCallback* mockBufferMapWriteCallback = nullptr;
|
||||||
static void ToMockBufferMapWriteCallback(nxtBufferMapAsyncStatus status, void* ptr, nxtCallbackUserdata userdata) {
|
static void ToMockBufferMapWriteCallback(dawnBufferMapAsyncStatus status, void* ptr, dawnCallbackUserdata userdata) {
|
||||||
// Assume the data is uint32_t to make writing matchers easier
|
// Assume the data is uint32_t to make writing matchers easier
|
||||||
mockBufferMapWriteCallback->Call(status, reinterpret_cast<uint32_t*>(ptr), userdata);
|
mockBufferMapWriteCallback->Call(status, reinterpret_cast<uint32_t*>(ptr), userdata);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ TEST_F(BufferValidationTest, MapReadSuccess) {
|
||||||
dawn::CallbackUserdata userdata = 40598;
|
dawn::CallbackUserdata userdata = 40598;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ TEST_F(BufferValidationTest, MapWriteSuccess) {
|
||||||
dawn::CallbackUserdata userdata = 40598;
|
dawn::CallbackUserdata userdata = 40598;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ TEST_F(BufferValidationTest, MapReadOutOfRange) {
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40599;
|
dawn::CallbackUserdata userdata = 40599;
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 5, ToMockBufferMapReadCallback, userdata));
|
ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 5, ToMockBufferMapReadCallback, userdata));
|
||||||
|
@ -208,7 +208,7 @@ TEST_F(BufferValidationTest, MapWriteOutOfRange) {
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40599;
|
dawn::CallbackUserdata userdata = 40599;
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 5, ToMockBufferMapWriteCallback, userdata));
|
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 5, ToMockBufferMapWriteCallback, userdata));
|
||||||
|
@ -222,7 +222,7 @@ TEST_F(BufferValidationTest, MapReadWrongUsage) {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40600;
|
dawn::CallbackUserdata userdata = 40600;
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata));
|
ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata));
|
||||||
|
@ -236,7 +236,7 @@ TEST_F(BufferValidationTest, MapWriteWrongUsage) {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40600;
|
dawn::CallbackUserdata userdata = 40600;
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata));
|
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata));
|
||||||
|
@ -248,11 +248,11 @@ TEST_F(BufferValidationTest, MapReadAlreadyMapped) {
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata1 = 40601;
|
dawn::CallbackUserdata userdata1 = 40601;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata1);
|
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata1);
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata1))
|
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata1))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata2 = 40602;
|
dawn::CallbackUserdata userdata2 = 40602;
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata2))
|
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata2))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata2));
|
ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata2));
|
||||||
|
|
||||||
|
@ -265,11 +265,11 @@ TEST_F(BufferValidationTest, MapWriteAlreadyMapped) {
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata1 = 40601;
|
dawn::CallbackUserdata userdata1 = 40601;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata1);
|
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata1);
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata1))
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata1))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata2 = 40602;
|
dawn::CallbackUserdata userdata2 = 40602;
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata2))
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata2))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata2));
|
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata2));
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ TEST_F(BufferValidationTest, MapReadUnmapBeforeResult) {
|
||||||
dawn::CallbackUserdata userdata = 40603;
|
dawn::CallbackUserdata userdata = 40603;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ TEST_F(BufferValidationTest, MapWriteUnmapBeforeResult) {
|
||||||
dawn::CallbackUserdata userdata = 40603;
|
dawn::CallbackUserdata userdata = 40603;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ TEST_F(BufferValidationTest, DISABLED_MapReadDestroyBeforeResult) {
|
||||||
dawn::CallbackUserdata userdata = 40604;
|
dawn::CallbackUserdata userdata = 40604;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ TEST_F(BufferValidationTest, DISABLED_MapWriteDestroyBeforeResult) {
|
||||||
dawn::CallbackUserdata userdata = 40604;
|
dawn::CallbackUserdata userdata = 40604;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ TEST_F(BufferValidationTest, MapReadUnmapBeforeResultThenMapAgain) {
|
||||||
dawn::CallbackUserdata userdata = 40605;
|
dawn::CallbackUserdata userdata = 40605;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ TEST_F(BufferValidationTest, MapReadUnmapBeforeResultThenMapAgain) {
|
||||||
|
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -377,7 +377,7 @@ TEST_F(BufferValidationTest, MapWriteUnmapBeforeResultThenMapAgain) {
|
||||||
dawn::CallbackUserdata userdata = 40605;
|
dawn::CallbackUserdata userdata = 40605;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ TEST_F(BufferValidationTest, MapWriteUnmapBeforeResultThenMapAgain) {
|
||||||
|
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ TEST_F(BufferValidationTest, UnmapInsideMapReadCallback) {
|
||||||
dawn::CallbackUserdata userdata = 40678;
|
dawn::CallbackUserdata userdata = 40678;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
}));
|
}));
|
||||||
|
@ -412,7 +412,7 @@ TEST_F(BufferValidationTest, UnmapInsideMapWriteCallback) {
|
||||||
dawn::CallbackUserdata userdata = 40678;
|
dawn::CallbackUserdata userdata = 40678;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
}));
|
}));
|
||||||
|
@ -427,7 +427,7 @@ TEST_F(BufferValidationTest, DestroyInsideMapReadCallback) {
|
||||||
dawn::CallbackUserdata userdata = 40679;
|
dawn::CallbackUserdata userdata = 40679;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
buf = dawn::Buffer();
|
buf = dawn::Buffer();
|
||||||
}));
|
}));
|
||||||
|
@ -442,7 +442,7 @@ TEST_F(BufferValidationTest, DestroyInsideMapWriteCallback) {
|
||||||
dawn::CallbackUserdata userdata = 40679;
|
dawn::CallbackUserdata userdata = 40679;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
buf = dawn::Buffer();
|
buf = dawn::Buffer();
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -18,19 +18,19 @@
|
||||||
|
|
||||||
namespace backend {
|
namespace backend {
|
||||||
namespace null {
|
namespace null {
|
||||||
void Init(nxtProcTable* procs, nxtDevice* device);
|
void Init(nxtProcTable* procs, dawnDevice* device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ValidationTest::ValidationTest() {
|
ValidationTest::ValidationTest() {
|
||||||
nxtProcTable procs;
|
nxtProcTable procs;
|
||||||
nxtDevice cDevice;
|
dawnDevice cDevice;
|
||||||
backend::null::Init(&procs, &cDevice);
|
backend::null::Init(&procs, &cDevice);
|
||||||
|
|
||||||
nxtSetProcs(&procs);
|
nxtSetProcs(&procs);
|
||||||
device = dawn::Device::Acquire(cDevice);
|
device = dawn::Device::Acquire(cDevice);
|
||||||
|
|
||||||
device.SetErrorCallback(ValidationTest::OnDeviceError, static_cast<nxtCallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
|
device.SetErrorCallback(ValidationTest::OnDeviceError, static_cast<dawnCallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ValidationTest::~ValidationTest() {
|
ValidationTest::~ValidationTest() {
|
||||||
|
@ -51,9 +51,9 @@ void ValidationTest::TearDown() {
|
||||||
|
|
||||||
ASSERT_TRUE(expectation.gotStatus) << "Didn't get a status for " << name;
|
ASSERT_TRUE(expectation.gotStatus) << "Didn't get a status for " << name;
|
||||||
|
|
||||||
ASSERT_NE(NXT_BUILDER_ERROR_STATUS_UNKNOWN, expectation.status) << "Got unknown status for " << name;
|
ASSERT_NE(DAWN_BUILDER_ERROR_STATUS_UNKNOWN, expectation.status) << "Got unknown status for " << name;
|
||||||
|
|
||||||
bool wasSuccess = expectation.status == NXT_BUILDER_ERROR_STATUS_SUCCESS;
|
bool wasSuccess = expectation.status == DAWN_BUILDER_ERROR_STATUS_SUCCESS;
|
||||||
ASSERT_EQ(expectation.expectSuccess, wasSuccess)
|
ASSERT_EQ(expectation.expectSuccess, wasSuccess)
|
||||||
<< "Got wrong status value for " << name
|
<< "Got wrong status value for " << name
|
||||||
<< ", status was " << expectation.status << " with \"" << expectation.statusMessage << "\"";
|
<< ", status was " << expectation.status << " with \"" << expectation.statusMessage << "\"";
|
||||||
|
@ -85,7 +85,7 @@ dawn::RenderPassDescriptor ValidationTest::CreateSimpleRenderPass() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValidationTest::OnDeviceError(const char* message, nxtCallbackUserdata userdata) {
|
void ValidationTest::OnDeviceError(const char* message, dawnCallbackUserdata userdata) {
|
||||||
// Skip this one specific error that is raised when a builder is used after it got an error
|
// Skip this one specific error that is raised when a builder is used after it got an error
|
||||||
// this is important because we don't want to wrap all creation tests in ASSERT_DEVICE_ERROR.
|
// this is important because we don't want to wrap all creation tests in ASSERT_DEVICE_ERROR.
|
||||||
// Yes the error message is misleading.
|
// Yes the error message is misleading.
|
||||||
|
@ -99,7 +99,7 @@ void ValidationTest::OnDeviceError(const char* message, nxtCallbackUserdata user
|
||||||
self->mError = true;
|
self->mError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValidationTest::OnBuilderErrorStatus(nxtBuilderErrorStatus 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));
|
auto* self = reinterpret_cast<ValidationTest*>(static_cast<uintptr_t>(userdata1));
|
||||||
size_t index = static_cast<size_t>(userdata2);
|
size_t index = static_cast<size_t>(userdata2);
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ class ValidationTest : public testing::Test {
|
||||||
dawn::Device device;
|
dawn::Device device;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void OnDeviceError(const char* message, nxtCallbackUserdata userdata);
|
static void OnDeviceError(const char* message, dawnCallbackUserdata userdata);
|
||||||
bool mExpectError = false;
|
bool mExpectError = false;
|
||||||
bool mError = false;
|
bool mError = false;
|
||||||
|
|
||||||
|
@ -75,14 +75,14 @@ class ValidationTest : public testing::Test {
|
||||||
|
|
||||||
bool gotStatus = false;
|
bool gotStatus = false;
|
||||||
std::string statusMessage;
|
std::string statusMessage;
|
||||||
nxtBuilderErrorStatus status;
|
dawnBuilderErrorStatus status;
|
||||||
};
|
};
|
||||||
std::vector<BuilderStatusExpectations> mExpectations;
|
std::vector<BuilderStatusExpectations> mExpectations;
|
||||||
|
|
||||||
template<typename Builder>
|
template<typename Builder>
|
||||||
Builder AddExpectation(Builder& builder, std::string debugName, bool expectSuccess);
|
Builder AddExpectation(Builder& builder, std::string debugName, bool expectSuccess);
|
||||||
|
|
||||||
static void OnBuilderErrorStatus(nxtBuilderErrorStatus 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
|
// Template implementation details
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
typedef struct nxtProcTable_s nxtProcTable;
|
typedef struct nxtProcTable_s nxtProcTable;
|
||||||
typedef struct nxtDeviceImpl* nxtDevice;
|
typedef struct dawnDeviceImpl* dawnDevice;
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ namespace utils {
|
||||||
virtual ~BackendBinding() = default;
|
virtual ~BackendBinding() = default;
|
||||||
|
|
||||||
virtual void SetupGLFWWindowHints() = 0;
|
virtual void SetupGLFWWindowHints() = 0;
|
||||||
virtual void GetProcAndDevice(nxtProcTable* procs, nxtDevice* device) = 0;
|
virtual void GetProcAndDevice(nxtProcTable* procs, dawnDevice* device) = 0;
|
||||||
virtual uint64_t GetSwapChainImplementation() = 0;
|
virtual uint64_t GetSwapChainImplementation() = 0;
|
||||||
virtual nxtTextureFormat GetPreferredSwapChainTextureFormat() = 0;
|
virtual dawnTextureFormat GetPreferredSwapChainTextureFormat() = 0;
|
||||||
|
|
||||||
void SetWindow(GLFWwindow* window);
|
void SetWindow(GLFWwindow* window);
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,10 @@
|
||||||
#include "GLFW/glfw3native.h"
|
#include "GLFW/glfw3native.h"
|
||||||
|
|
||||||
namespace backend { namespace d3d12 {
|
namespace backend { namespace d3d12 {
|
||||||
void Init(nxtProcTable* procs, nxtDevice* device);
|
void Init(nxtProcTable* procs, dawnDevice* device);
|
||||||
|
|
||||||
dawnSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, HWND window);
|
dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device, HWND window);
|
||||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
dawnTextureFormat GetNativeSwapChainPreferredFormat(
|
||||||
const dawnSwapChainImplementation* swapChain);
|
const dawnSwapChainImplementation* swapChain);
|
||||||
}} // namespace backend::d3d12
|
}} // namespace backend::d3d12
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ namespace utils {
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetProcAndDevice(nxtProcTable* procs, nxtDevice* device) override {
|
void GetProcAndDevice(nxtProcTable* procs, dawnDevice* device) override {
|
||||||
backend::d3d12::Init(procs, device);
|
backend::d3d12::Init(procs, device);
|
||||||
mBackendDevice = *device;
|
mBackendDevice = *device;
|
||||||
}
|
}
|
||||||
|
@ -51,13 +51,13 @@ namespace utils {
|
||||||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtTextureFormat GetPreferredSwapChainTextureFormat() override {
|
dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||||
ASSERT(mSwapchainImpl.userData != nullptr);
|
ASSERT(mSwapchainImpl.userData != nullptr);
|
||||||
return backend::d3d12::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
|
return backend::d3d12::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nxtDevice mBackendDevice = nullptr;
|
dawnDevice mBackendDevice = nullptr;
|
||||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@
|
||||||
#import <QuartzCore/CAMetalLayer.h>
|
#import <QuartzCore/CAMetalLayer.h>
|
||||||
|
|
||||||
namespace backend { namespace metal {
|
namespace backend { namespace metal {
|
||||||
void Init(id<MTLDevice> metalDevice, nxtProcTable* procs, nxtDevice* device);
|
void Init(id<MTLDevice> metalDevice, nxtProcTable* procs, dawnDevice* device);
|
||||||
void SetNextDrawable(nxtDevice device, id<CAMetalDrawable> drawable);
|
void SetNextDrawable(dawnDevice device, id<CAMetalDrawable> drawable);
|
||||||
void Present(nxtDevice device);
|
void Present(dawnDevice device);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
@ -49,11 +49,11 @@ namespace utils {
|
||||||
mCommandQueue = [mMtlDevice newCommandQueue];
|
mCommandQueue = [mMtlDevice newCommandQueue];
|
||||||
}
|
}
|
||||||
|
|
||||||
dawnSwapChainError Configure(nxtTextureFormat format,
|
dawnSwapChainError Configure(dawnTextureFormat format,
|
||||||
nxtTextureUsageBit,
|
dawnTextureUsageBit,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
if (format != NXT_TEXTURE_FORMAT_B8_G8_R8_A8_UNORM) {
|
if (format != DAWN_TEXTURE_FORMAT_B8_G8_R8_A8_UNORM) {
|
||||||
return "unsupported format";
|
return "unsupported format";
|
||||||
}
|
}
|
||||||
ASSERT(width > 0);
|
ASSERT(width > 0);
|
||||||
|
@ -114,7 +114,7 @@ namespace utils {
|
||||||
void SetupGLFWWindowHints() override {
|
void SetupGLFWWindowHints() override {
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
}
|
}
|
||||||
void GetProcAndDevice(nxtProcTable* procs, nxtDevice* device) override {
|
void GetProcAndDevice(nxtProcTable* procs, dawnDevice* device) override {
|
||||||
mMetalDevice = MTLCreateSystemDefaultDevice();
|
mMetalDevice = MTLCreateSystemDefaultDevice();
|
||||||
|
|
||||||
backend::metal::Init(mMetalDevice, procs, device);
|
backend::metal::Init(mMetalDevice, procs, device);
|
||||||
|
@ -129,13 +129,13 @@ namespace utils {
|
||||||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtTextureFormat GetPreferredSwapChainTextureFormat() override {
|
dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||||
return NXT_TEXTURE_FORMAT_B8_G8_R8_A8_UNORM;
|
return DAWN_TEXTURE_FORMAT_B8_G8_R8_A8_UNORM;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
id<MTLDevice> mMetalDevice = nil;
|
id<MTLDevice> mMetalDevice = nil;
|
||||||
nxtDevice mBackendDevice = nullptr;
|
dawnDevice mBackendDevice = nullptr;
|
||||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "utils/BackendBinding.h"
|
#include "utils/BackendBinding.h"
|
||||||
|
|
||||||
namespace backend { namespace null {
|
namespace backend { namespace null {
|
||||||
void Init(nxtProcTable* procs, nxtDevice* device);
|
void Init(nxtProcTable* procs, dawnDevice* device);
|
||||||
}} // namespace backend::null
|
}} // namespace backend::null
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
@ -24,14 +24,14 @@ namespace utils {
|
||||||
public:
|
public:
|
||||||
void SetupGLFWWindowHints() override {
|
void SetupGLFWWindowHints() override {
|
||||||
}
|
}
|
||||||
void GetProcAndDevice(nxtProcTable* procs, nxtDevice* device) override {
|
void GetProcAndDevice(nxtProcTable* procs, dawnDevice* device) override {
|
||||||
backend::null::Init(procs, device);
|
backend::null::Init(procs, device);
|
||||||
}
|
}
|
||||||
uint64_t GetSwapChainImplementation() override {
|
uint64_t GetSwapChainImplementation() override {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
nxtTextureFormat GetPreferredSwapChainTextureFormat() override {
|
dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||||
return NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
|
return DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "GLFW/glfw3.h"
|
#include "GLFW/glfw3.h"
|
||||||
|
|
||||||
namespace backend { namespace opengl {
|
namespace backend { namespace opengl {
|
||||||
void Init(void* (*getProc)(const char*), nxtProcTable* procs, nxtDevice* device);
|
void Init(void* (*getProc)(const char*), nxtProcTable* procs, dawnDevice* device);
|
||||||
}} // namespace backend::opengl
|
}} // namespace backend::opengl
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
@ -53,11 +53,11 @@ namespace utils {
|
||||||
mBackTexture, 0);
|
mBackTexture, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
dawnSwapChainError Configure(nxtTextureFormat format,
|
dawnSwapChainError Configure(dawnTextureFormat format,
|
||||||
nxtTextureUsageBit,
|
dawnTextureUsageBit,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
if (format != NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM) {
|
if (format != DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM) {
|
||||||
return "unsupported format";
|
return "unsupported format";
|
||||||
}
|
}
|
||||||
ASSERT(width > 0);
|
ASSERT(width > 0);
|
||||||
|
@ -111,7 +111,7 @@ namespace utils {
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
void GetProcAndDevice(nxtProcTable* procs, nxtDevice* device) override {
|
void GetProcAndDevice(nxtProcTable* procs, dawnDevice* device) override {
|
||||||
glfwMakeContextCurrent(mWindow);
|
glfwMakeContextCurrent(mWindow);
|
||||||
backend::opengl::Init(reinterpret_cast<void* (*)(const char*)>(glfwGetProcAddress),
|
backend::opengl::Init(reinterpret_cast<void* (*)(const char*)>(glfwGetProcAddress),
|
||||||
procs, device);
|
procs, device);
|
||||||
|
@ -126,12 +126,12 @@ namespace utils {
|
||||||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtTextureFormat GetPreferredSwapChainTextureFormat() override {
|
dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||||
return NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
|
return DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nxtDevice mBackendDevice = nullptr;
|
dawnDevice mBackendDevice = nullptr;
|
||||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,13 @@
|
||||||
|
|
||||||
namespace backend { namespace vulkan {
|
namespace backend { namespace vulkan {
|
||||||
void Init(nxtProcTable* procs,
|
void Init(nxtProcTable* procs,
|
||||||
nxtDevice* device,
|
dawnDevice* device,
|
||||||
const std::vector<const char*>& requiredInstanceExtensions);
|
const std::vector<const char*>& requiredInstanceExtensions);
|
||||||
|
|
||||||
VkInstance GetInstance(nxtDevice device);
|
VkInstance GetInstance(dawnDevice device);
|
||||||
|
|
||||||
dawnSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, VkSurfaceKHR surface);
|
dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device, VkSurfaceKHR surface);
|
||||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
dawnTextureFormat GetNativeSwapChainPreferredFormat(
|
||||||
const dawnSwapChainImplementation* swapChain);
|
const dawnSwapChainImplementation* swapChain);
|
||||||
}} // namespace backend::vulkan
|
}} // namespace backend::vulkan
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ namespace utils {
|
||||||
void Init(dawnWSIContextVulkan*) {
|
void Init(dawnWSIContextVulkan*) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawnSwapChainError Configure(nxtTextureFormat, nxtTextureUsageBit, uint32_t, uint32_t) {
|
dawnSwapChainError Configure(dawnTextureFormat, dawnTextureUsageBit, uint32_t, uint32_t) {
|
||||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ namespace utils {
|
||||||
void SetupGLFWWindowHints() override {
|
void SetupGLFWWindowHints() override {
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
}
|
}
|
||||||
void GetProcAndDevice(nxtProcTable* procs, nxtDevice* device) override {
|
void GetProcAndDevice(nxtProcTable* procs, dawnDevice* device) override {
|
||||||
uint32_t extensionCount = 0;
|
uint32_t extensionCount = 0;
|
||||||
const char** glfwInstanceExtensions =
|
const char** glfwInstanceExtensions =
|
||||||
glfwGetRequiredInstanceExtensions(&extensionCount);
|
glfwGetRequiredInstanceExtensions(&extensionCount);
|
||||||
|
@ -89,13 +89,13 @@ namespace utils {
|
||||||
}
|
}
|
||||||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
nxtTextureFormat GetPreferredSwapChainTextureFormat() override {
|
dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||||
ASSERT(mSwapchainImpl.userData != nullptr);
|
ASSERT(mSwapchainImpl.userData != nullptr);
|
||||||
return backend::vulkan::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
|
return backend::vulkan::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nxtDevice mDevice;
|
dawnDevice mDevice;
|
||||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,9 @@ namespace dawn { namespace wire {
|
||||||
};
|
};
|
||||||
|
|
||||||
CommandHandler* NewClientDevice(nxtProcTable* procs,
|
CommandHandler* NewClientDevice(nxtProcTable* procs,
|
||||||
nxtDevice* device,
|
dawnDevice* device,
|
||||||
CommandSerializer* serializer);
|
CommandSerializer* serializer);
|
||||||
CommandHandler* NewServerCommandHandler(nxtDevice device,
|
CommandHandler* NewServerCommandHandler(dawnDevice device,
|
||||||
const nxtProcTable& procs,
|
const nxtProcTable& procs,
|
||||||
CommandSerializer* serializer);
|
CommandSerializer* serializer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue