Make dawn_native public headers and dawn_wsi use webgpu.h
BUG=dawn:22 Change-Id: I112d71323c9305fa0997d251556fe0a41dafed29 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12701 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
1fdcb16b69
commit
9f90c8d3ca
|
@ -73,18 +73,18 @@ namespace dawn_native {
|
|||
{% endfor %}
|
||||
|
||||
struct ProcEntry {
|
||||
DawnProc proc;
|
||||
WGPUProc proc;
|
||||
const char* name;
|
||||
};
|
||||
static const ProcEntry sProcMap[] = {
|
||||
{% for (type, method) in methods_sorted_by_name %}
|
||||
{ reinterpret_cast<DawnProc>(Native{{as_MethodSuffix(type.name, method.name)}}), "{{as_cMethod(type.name, method.name)}}" },
|
||||
{ reinterpret_cast<WGPUProc>(Native{{as_MethodSuffix(type.name, method.name)}}), "{{as_cMethod(type.name, method.name)}}" },
|
||||
{% endfor %}
|
||||
};
|
||||
static constexpr size_t sProcMapSize = sizeof(sProcMap) / sizeof(sProcMap[0]);
|
||||
}
|
||||
|
||||
DawnProc NativeGetProcAddress(DawnDevice, const char* procName) {
|
||||
WGPUProc NativeGetProcAddress(WGPUDevice, const char* procName) {
|
||||
if (procName == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
if (strcmp(procName, "wgpuGetProcAddress") == 0) {
|
||||
return reinterpret_cast<DawnProc>(NativeGetProcAddress);
|
||||
return reinterpret_cast<WGPUProc>(NativeGetProcAddress);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
|
@ -26,7 +26,7 @@ DawnSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
|
|||
reinterpret_cast<T*>(userData)->Init(ctx);
|
||||
};
|
||||
impl.Destroy = [](void* userData) { delete reinterpret_cast<T*>(userData); };
|
||||
impl.Configure = [](void* userData, DawnTextureFormat format, DawnTextureUsage allowedUsage,
|
||||
impl.Configure = [](void* userData, WGPUTextureFormat format, WGPUTextureUsage allowedUsage,
|
||||
uint32_t width, uint32_t height) {
|
||||
return static_cast<T*>(userData)->Configure(format, allowedUsage, width, height);
|
||||
};
|
||||
|
|
|
@ -124,8 +124,8 @@ namespace dawn_native {
|
|||
BufferBase::~BufferBase() {
|
||||
if (mState == BufferState::Mapped) {
|
||||
ASSERT(!IsError());
|
||||
CallMapReadCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u);
|
||||
CallMapWriteCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u);
|
||||
CallMapReadCallback(mMapSerial, WGPUBufferMapAsyncStatus_Unknown, nullptr, 0u);
|
||||
CallMapWriteCallback(mMapSerial, WGPUBufferMapAsyncStatus_Unknown, nullptr, 0u);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ namespace dawn_native {
|
|||
|
||||
void BufferBase::MapReadAsync(WGPUBufferMapReadCallback callback, void* userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateMap(wgpu::BufferUsage::MapRead))) {
|
||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||
callback(WGPUBufferMapAsyncStatus_Error, nullptr, 0, userdata);
|
||||
return;
|
||||
}
|
||||
ASSERT(!IsError());
|
||||
|
@ -267,7 +267,7 @@ namespace dawn_native {
|
|||
|
||||
void BufferBase::MapWriteAsync(WGPUBufferMapWriteCallback callback, void* userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateMap(wgpu::BufferUsage::MapWrite))) {
|
||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||
callback(WGPUBufferMapAsyncStatus_Error, nullptr, 0, userdata);
|
||||
return;
|
||||
}
|
||||
ASSERT(!IsError());
|
||||
|
@ -333,8 +333,8 @@ namespace dawn_native {
|
|||
// completed before the Unmap.
|
||||
// Callbacks are not fired if there is no callback registered, so this is correct for
|
||||
// CreateBufferMapped.
|
||||
CallMapReadCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u);
|
||||
CallMapWriteCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u);
|
||||
CallMapReadCallback(mMapSerial, WGPUBufferMapAsyncStatus_Unknown, nullptr, 0u);
|
||||
CallMapWriteCallback(mMapSerial, WGPUBufferMapAsyncStatus_Unknown, nullptr, 0u);
|
||||
UnmapImpl();
|
||||
}
|
||||
mState = BufferState::Unmapped;
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace dawn_native {
|
|||
return GetProcsAutogen();
|
||||
}
|
||||
|
||||
std::vector<const char*> GetTogglesUsed(DawnDevice device) {
|
||||
std::vector<const char*> GetTogglesUsed(WGPUDevice device) {
|
||||
const dawn_native::DeviceBase* deviceBase =
|
||||
reinterpret_cast<const dawn_native::DeviceBase*>(device);
|
||||
return deviceBase->GetTogglesUsed();
|
||||
|
@ -65,8 +65,8 @@ namespace dawn_native {
|
|||
return mImpl != nullptr;
|
||||
}
|
||||
|
||||
DawnDevice Adapter::CreateDevice(const DeviceDescriptor* deviceDescriptor) {
|
||||
return reinterpret_cast<DawnDevice>(mImpl->CreateDevice(deviceDescriptor));
|
||||
WGPUDevice Adapter::CreateDevice(const DeviceDescriptor* deviceDescriptor) {
|
||||
return reinterpret_cast<WGPUDevice>(mImpl->CreateDevice(deviceDescriptor));
|
||||
}
|
||||
|
||||
// AdapterDiscoverOptionsBase
|
||||
|
@ -129,7 +129,7 @@ namespace dawn_native {
|
|||
return mImpl->GetPlatform();
|
||||
}
|
||||
|
||||
size_t GetLazyClearCountForTesting(DawnDevice device) {
|
||||
size_t GetLazyClearCountForTesting(WGPUDevice device) {
|
||||
dawn_native::DeviceBase* deviceBase = reinterpret_cast<dawn_native::DeviceBase*>(device);
|
||||
return deviceBase->GetLazyClearCountForTesting();
|
||||
}
|
||||
|
|
|
@ -380,7 +380,7 @@ namespace dawn_native {
|
|||
|
||||
return result;
|
||||
}
|
||||
DawnCreateBufferMappedResult DeviceBase::CreateBufferMapped(
|
||||
WGPUCreateBufferMappedResult DeviceBase::CreateBufferMapped(
|
||||
const BufferDescriptor* descriptor) {
|
||||
BufferBase* buffer = nullptr;
|
||||
uint8_t* data = nullptr;
|
||||
|
@ -405,8 +405,8 @@ namespace dawn_native {
|
|||
memset(data, 0, size);
|
||||
}
|
||||
|
||||
DawnCreateBufferMappedResult result = {};
|
||||
result.buffer = reinterpret_cast<DawnBuffer>(buffer);
|
||||
WGPUCreateBufferMappedResult result = {};
|
||||
result.buffer = reinterpret_cast<WGPUBuffer>(buffer);
|
||||
result.data = data;
|
||||
result.dataLength = size;
|
||||
|
||||
|
@ -415,11 +415,11 @@ namespace dawn_native {
|
|||
void DeviceBase::CreateBufferMappedAsync(const BufferDescriptor* descriptor,
|
||||
wgpu::BufferCreateMappedCallback callback,
|
||||
void* userdata) {
|
||||
DawnCreateBufferMappedResult result = CreateBufferMapped(descriptor);
|
||||
WGPUCreateBufferMappedResult result = CreateBufferMapped(descriptor);
|
||||
|
||||
DawnBufferMapAsyncStatus status = DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS;
|
||||
WGPUBufferMapAsyncStatus status = WGPUBufferMapAsyncStatus_Success;
|
||||
if (result.data == nullptr || result.dataLength != descriptor->size) {
|
||||
status = DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR;
|
||||
status = WGPUBufferMapAsyncStatus_Error;
|
||||
}
|
||||
|
||||
DeferredCreateBufferMappedAsync deferred_info;
|
||||
|
|
|
@ -141,7 +141,7 @@ namespace dawn_native {
|
|||
BindGroupBase* CreateBindGroup(const BindGroupDescriptor* descriptor);
|
||||
BindGroupLayoutBase* CreateBindGroupLayout(const BindGroupLayoutDescriptor* descriptor);
|
||||
BufferBase* CreateBuffer(const BufferDescriptor* descriptor);
|
||||
DawnCreateBufferMappedResult CreateBufferMapped(const BufferDescriptor* descriptor);
|
||||
WGPUCreateBufferMappedResult CreateBufferMapped(const BufferDescriptor* descriptor);
|
||||
void CreateBufferMappedAsync(const BufferDescriptor* descriptor,
|
||||
wgpu::BufferCreateMappedCallback callback,
|
||||
void* userdata);
|
||||
|
@ -262,8 +262,8 @@ namespace dawn_native {
|
|||
|
||||
struct DeferredCreateBufferMappedAsync {
|
||||
wgpu::BufferCreateMappedCallback callback;
|
||||
DawnBufferMapAsyncStatus status;
|
||||
DawnCreateBufferMappedResult result;
|
||||
WGPUBufferMapAsyncStatus status;
|
||||
WGPUCreateBufferMappedResult result;
|
||||
void* userdata;
|
||||
};
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace dawn_native {
|
|||
FenceBase::~FenceBase() {
|
||||
for (auto& request : mRequests.IterateAll()) {
|
||||
ASSERT(!IsError());
|
||||
request.completionCallback(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, request.userdata);
|
||||
request.completionCallback(WGPUFenceCompletionStatus_Unknown, request.userdata);
|
||||
}
|
||||
mRequests.Clear();
|
||||
}
|
||||
|
@ -67,13 +67,13 @@ namespace dawn_native {
|
|||
wgpu::FenceOnCompletionCallback callback,
|
||||
void* userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateOnCompletion(value))) {
|
||||
callback(DAWN_FENCE_COMPLETION_STATUS_ERROR, userdata);
|
||||
callback(WGPUFenceCompletionStatus_Error, userdata);
|
||||
return;
|
||||
}
|
||||
ASSERT(!IsError());
|
||||
|
||||
if (value <= mCompletedValue) {
|
||||
callback(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata);
|
||||
callback(WGPUFenceCompletionStatus_Success, userdata);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ namespace dawn_native {
|
|||
mCompletedValue = completedValue;
|
||||
|
||||
for (auto& request : mRequests.IterateUpTo(mCompletedValue)) {
|
||||
request.completionCallback(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, request.userdata);
|
||||
request.completionCallback(WGPUFenceCompletionStatus_Success, request.userdata);
|
||||
}
|
||||
mRequests.ClearUpTo(mCompletedValue);
|
||||
}
|
||||
|
|
|
@ -95,8 +95,8 @@ namespace dawn_native {
|
|||
mAllowedUsage = allowedUsage;
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mImplementation.Configure(mImplementation.userData, static_cast<DawnTextureFormat>(format),
|
||||
static_cast<DawnTextureUsage>(allowedUsage), width, height);
|
||||
mImplementation.Configure(mImplementation.userData, static_cast<WGPUTextureFormat>(format),
|
||||
static_cast<WGPUTextureUsage>(allowedUsage), width, height);
|
||||
}
|
||||
|
||||
TextureBase* SwapChainBase::GetNextTexture() {
|
||||
|
|
|
@ -218,9 +218,9 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
void Buffer::OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite) {
|
||||
if (isWrite) {
|
||||
CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||
CallMapWriteCallback(mapSerial, WGPUBufferMapAsyncStatus_Success, data, GetSize());
|
||||
} else {
|
||||
CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||
CallMapReadCallback(mapSerial, WGPUBufferMapAsyncStatus_Success, data, GetSize());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,30 +24,30 @@
|
|||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
ComPtr<ID3D12Device> GetD3D12Device(DawnDevice device) {
|
||||
ComPtr<ID3D12Device> GetD3D12Device(WGPUDevice device) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
|
||||
return backendDevice->GetD3D12Device();
|
||||
}
|
||||
|
||||
DawnSwapChainImplementation CreateNativeSwapChainImpl(DawnDevice device, HWND window) {
|
||||
DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device, HWND window) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
|
||||
DawnSwapChainImplementation impl;
|
||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, window));
|
||||
impl.textureUsage = DAWN_TEXTURE_USAGE_PRESENT;
|
||||
impl.textureUsage = WGPUTextureUsage_Present;
|
||||
|
||||
return impl;
|
||||
}
|
||||
|
||||
DawnTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
WGPUTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
const DawnSwapChainImplementation* swapChain) {
|
||||
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
||||
return static_cast<DawnTextureFormat>(impl->GetPreferredFormat());
|
||||
return static_cast<WGPUTextureFormat>(impl->GetPreferredFormat());
|
||||
}
|
||||
|
||||
DawnTexture WrapSharedHandle(DawnDevice device,
|
||||
const DawnTextureDescriptor* descriptor,
|
||||
WGPUTexture WrapSharedHandle(WGPUDevice device,
|
||||
const WGPUTextureDescriptor* descriptor,
|
||||
HANDLE sharedHandle,
|
||||
uint64_t acquireMutexKey) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
|
@ -55,6 +55,6 @@ namespace dawn_native { namespace d3d12 {
|
|||
reinterpret_cast<const TextureDescriptor*>(descriptor);
|
||||
TextureBase* texture =
|
||||
backendDevice->WrapSharedHandle(backendDescriptor, sharedHandle, acquireMutexKey);
|
||||
return reinterpret_cast<DawnTexture>(texture);
|
||||
return reinterpret_cast<WGPUTexture>(texture);
|
||||
}
|
||||
}} // namespace dawn_native::d3d12
|
||||
|
|
|
@ -21,15 +21,15 @@
|
|||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
namespace {
|
||||
DXGI_USAGE D3D12SwapChainBufferUsage(DawnTextureUsage allowedUsages) {
|
||||
DXGI_USAGE D3D12SwapChainBufferUsage(WGPUTextureUsage allowedUsages) {
|
||||
DXGI_USAGE usage = DXGI_CPU_ACCESS_NONE;
|
||||
if (allowedUsages & DAWN_TEXTURE_USAGE_SAMPLED) {
|
||||
if (allowedUsages & WGPUTextureUsage_Sampled) {
|
||||
usage |= DXGI_USAGE_SHADER_INPUT;
|
||||
}
|
||||
if (allowedUsages & DAWN_TEXTURE_USAGE_STORAGE) {
|
||||
if (allowedUsages & WGPUTextureUsage_Storage) {
|
||||
usage |= DXGI_USAGE_UNORDERED_ACCESS;
|
||||
}
|
||||
if (allowedUsages & DAWN_TEXTURE_USAGE_OUTPUT_ATTACHMENT) {
|
||||
if (allowedUsages & WGPUTextureUsage_OutputAttachment) {
|
||||
usage |= DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
}
|
||||
return usage;
|
||||
|
@ -48,13 +48,13 @@ namespace dawn_native { namespace d3d12 {
|
|||
void NativeSwapChainImpl::Init(DawnWSIContextD3D12* /*context*/) {
|
||||
}
|
||||
|
||||
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
||||
DawnTextureUsage usage,
|
||||
DawnSwapChainError NativeSwapChainImpl::Configure(WGPUTextureFormat format,
|
||||
WGPUTextureUsage usage,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
ASSERT(width > 0);
|
||||
ASSERT(height > 0);
|
||||
ASSERT(format == static_cast<DawnTextureFormat>(GetPreferredFormat()));
|
||||
ASSERT(format == static_cast<WGPUTextureFormat>(GetPreferredFormat()));
|
||||
|
||||
ComPtr<IDXGIFactory4> factory = mDevice->GetFactory();
|
||||
ComPtr<ID3D12CommandQueue> queue = mDevice->GetCommandQueue();
|
||||
|
|
|
@ -34,8 +34,8 @@ namespace dawn_native { namespace d3d12 {
|
|||
~NativeSwapChainImpl();
|
||||
|
||||
void Init(DawnWSIContextD3D12* context);
|
||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||
DawnTextureUsage,
|
||||
DawnSwapChainError Configure(WGPUTextureFormat format,
|
||||
WGPUTextureUsage,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||
|
|
|
@ -25,10 +25,10 @@ namespace dawn_native { namespace d3d12 {
|
|||
: SwapChainBase(device, descriptor) {
|
||||
const auto& im = GetImplementation();
|
||||
DawnWSIContextD3D12 wsiContext = {};
|
||||
wsiContext.device = reinterpret_cast<DawnDevice>(GetDevice());
|
||||
wsiContext.device = reinterpret_cast<WGPUDevice>(GetDevice());
|
||||
im.Init(im.userData, &wsiContext);
|
||||
|
||||
ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_NONE);
|
||||
ASSERT(im.textureUsage != WGPUTextureUsage_None);
|
||||
mTextureUsage = static_cast<wgpu::TextureUsage>(im.textureUsage);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,9 +53,9 @@ namespace dawn_native { namespace metal {
|
|||
void Buffer::OnMapCommandSerialFinished(uint32_t mapSerial, bool isWrite) {
|
||||
char* data = reinterpret_cast<char*>([mMtlBuffer contents]);
|
||||
if (isWrite) {
|
||||
CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||
CallMapWriteCallback(mapSerial, WGPUBufferMapAsyncStatus_Success, data, GetSize());
|
||||
} else {
|
||||
CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||
CallMapReadCallback(mapSerial, WGPUBufferMapAsyncStatus_Success, data, GetSize());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,23 +22,23 @@
|
|||
|
||||
namespace dawn_native { namespace metal {
|
||||
|
||||
id<MTLDevice> GetMetalDevice(DawnDevice cDevice) {
|
||||
id<MTLDevice> GetMetalDevice(WGPUDevice cDevice) {
|
||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||
return device->GetMTLDevice();
|
||||
}
|
||||
|
||||
DawnTexture WrapIOSurface(DawnDevice cDevice,
|
||||
const DawnTextureDescriptor* cDescriptor,
|
||||
WGPUTexture WrapIOSurface(WGPUDevice cDevice,
|
||||
const WGPUTextureDescriptor* cDescriptor,
|
||||
IOSurfaceRef ioSurface,
|
||||
uint32_t plane) {
|
||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||
const TextureDescriptor* descriptor =
|
||||
reinterpret_cast<const TextureDescriptor*>(cDescriptor);
|
||||
TextureBase* texture = device->CreateTextureWrappingIOSurface(descriptor, ioSurface, plane);
|
||||
return reinterpret_cast<DawnTexture>(texture);
|
||||
return reinterpret_cast<WGPUTexture>(texture);
|
||||
}
|
||||
|
||||
void WaitForCommandsToBeScheduled(DawnDevice cDevice) {
|
||||
void WaitForCommandsToBeScheduled(WGPUDevice cDevice) {
|
||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||
device->WaitForCommandsToBeScheduled();
|
||||
}
|
||||
|
|
|
@ -251,9 +251,9 @@ namespace dawn_native { namespace null {
|
|||
|
||||
void Buffer::MapOperationCompleted(uint32_t serial, void* ptr, bool isWrite) {
|
||||
if (isWrite) {
|
||||
CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, ptr, GetSize());
|
||||
CallMapWriteCallback(serial, WGPUBufferMapAsyncStatus_Success, ptr, GetSize());
|
||||
} else {
|
||||
CallMapReadCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, ptr, GetSize());
|
||||
CallMapReadCallback(serial, WGPUBufferMapAsyncStatus_Success, ptr, GetSize());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -348,8 +348,8 @@ namespace dawn_native { namespace null {
|
|||
void NativeSwapChainImpl::Init(WSIContext* context) {
|
||||
}
|
||||
|
||||
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
||||
DawnTextureUsage,
|
||||
DawnSwapChainError NativeSwapChainImpl::Configure(WGPUTextureFormat format,
|
||||
WGPUTextureUsage,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
|
|
|
@ -208,8 +208,8 @@ namespace dawn_native { namespace null {
|
|||
public:
|
||||
using WSIContext = struct {};
|
||||
void Init(WSIContext* context);
|
||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||
DawnTextureUsage,
|
||||
DawnSwapChainError Configure(WGPUTextureFormat format,
|
||||
WGPUTextureUsage,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace dawn_native { namespace null {
|
|||
DawnSwapChainImplementation CreateNativeSwapChainImpl() {
|
||||
DawnSwapChainImplementation impl;
|
||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl());
|
||||
impl.textureUsage = DAWN_TEXTURE_USAGE_PRESENT;
|
||||
impl.textureUsage = WGPUTextureUsage_Present;
|
||||
return impl;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace dawn_native { namespace opengl {
|
|||
// version of OpenGL that would let us map the buffer unsynchronized.
|
||||
gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
||||
void* data = gl.MapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
|
||||
CallMapReadCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||
CallMapReadCallback(serial, WGPUBufferMapAsyncStatus_Success, data, GetSize());
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ namespace dawn_native { namespace opengl {
|
|||
// version of OpenGL that would let us map the buffer unsynchronized.
|
||||
gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
||||
void* data = gl.MapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||
CallMapWriteCallback(serial, WGPUBufferMapAsyncStatus_Success, data, GetSize());
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -42,11 +42,11 @@ namespace dawn_native { namespace opengl {
|
|||
mBackTexture, 0);
|
||||
}
|
||||
|
||||
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
||||
DawnTextureUsage usage,
|
||||
DawnSwapChainError NativeSwapChainImpl::Configure(WGPUTextureFormat format,
|
||||
WGPUTextureUsage usage,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
if (format != DAWN_TEXTURE_FORMAT_RGBA8_UNORM) {
|
||||
if (format != WGPUTextureFormat_RGBA8Unorm) {
|
||||
return "unsupported format";
|
||||
}
|
||||
ASSERT(width > 0);
|
||||
|
|
|
@ -32,8 +32,8 @@ namespace dawn_native { namespace opengl {
|
|||
~NativeSwapChainImpl();
|
||||
|
||||
void Init(DawnWSIContextGL* context);
|
||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||
DawnTextureUsage,
|
||||
DawnSwapChainError Configure(WGPUTextureFormat format,
|
||||
WGPUTextureUsage,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace dawn_native { namespace opengl {
|
|||
: AdapterDiscoveryOptionsBase(BackendType::OpenGL) {
|
||||
}
|
||||
|
||||
DawnSwapChainImplementation CreateNativeSwapChainImpl(DawnDevice device,
|
||||
DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device,
|
||||
PresentCallback present,
|
||||
void* presentUserdata) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
|
@ -35,15 +35,15 @@ namespace dawn_native { namespace opengl {
|
|||
DawnSwapChainImplementation impl;
|
||||
impl = CreateSwapChainImplementation(
|
||||
new NativeSwapChainImpl(backendDevice, present, presentUserdata));
|
||||
impl.textureUsage = DAWN_TEXTURE_USAGE_PRESENT;
|
||||
impl.textureUsage = WGPUTextureUsage_Present;
|
||||
|
||||
return impl;
|
||||
}
|
||||
|
||||
DawnTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
WGPUTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
const DawnSwapChainImplementation* swapChain) {
|
||||
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
||||
return static_cast<DawnTextureFormat>(impl->GetPreferredFormat());
|
||||
return static_cast<WGPUTextureFormat>(impl->GetPreferredFormat());
|
||||
}
|
||||
|
||||
}} // namespace dawn_native::opengl
|
||||
|
|
|
@ -160,11 +160,11 @@ namespace dawn_native { namespace vulkan {
|
|||
}
|
||||
|
||||
void Buffer::OnMapReadCommandSerialFinished(uint32_t mapSerial, const void* data) {
|
||||
CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||
CallMapReadCallback(mapSerial, WGPUBufferMapAsyncStatus_Success, data, GetSize());
|
||||
}
|
||||
|
||||
void Buffer::OnMapWriteCommandSerialFinished(uint32_t mapSerial, void* data) {
|
||||
CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||
CallMapWriteCallback(mapSerial, WGPUBufferMapAsyncStatus_Success, data, GetSize());
|
||||
}
|
||||
|
||||
VkBuffer Buffer::GetHandle() const {
|
||||
|
|
|
@ -94,8 +94,8 @@ namespace dawn_native { namespace vulkan {
|
|||
UpdateSurfaceConfig();
|
||||
}
|
||||
|
||||
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
||||
DawnTextureUsage usage,
|
||||
DawnSwapChainError NativeSwapChainImpl::Configure(WGPUTextureFormat format,
|
||||
WGPUTextureUsage usage,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
UpdateSurfaceConfig();
|
||||
|
@ -105,7 +105,7 @@ namespace dawn_native { namespace vulkan {
|
|||
ASSERT(mInfo.capabilities.minImageExtent.height <= height);
|
||||
ASSERT(mInfo.capabilities.maxImageExtent.height >= height);
|
||||
|
||||
ASSERT(format == static_cast<DawnTextureFormat>(GetPreferredFormat()));
|
||||
ASSERT(format == static_cast<WGPUTextureFormat>(GetPreferredFormat()));
|
||||
// TODO(cwallez@chromium.org): need to check usage works too
|
||||
|
||||
// Create the swapchain with the configuration we chose
|
||||
|
|
|
@ -32,8 +32,8 @@ namespace dawn_native { namespace vulkan {
|
|||
~NativeSwapChainImpl();
|
||||
|
||||
void Init(DawnWSIContextVulkan* context);
|
||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||
DawnTextureUsage,
|
||||
DawnSwapChainError Configure(WGPUTextureFormat format,
|
||||
WGPUTextureUsage,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace dawn_native { namespace vulkan {
|
|||
DawnWSIContextVulkan wsiContext = {};
|
||||
im.Init(im.userData, &wsiContext);
|
||||
|
||||
ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_NONE);
|
||||
ASSERT(im.textureUsage != WGPUTextureUsage_None);
|
||||
mTextureUsage = static_cast<wgpu::TextureUsage>(im.textureUsage);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
namespace dawn_native { namespace vulkan {
|
||||
|
||||
VkInstance GetInstance(DawnDevice device) {
|
||||
VkInstance GetInstance(WGPUDevice device) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
return backendDevice->GetVkInstance();
|
||||
}
|
||||
|
@ -36,35 +36,35 @@ namespace dawn_native { namespace vulkan {
|
|||
// Explicitly export this function because it uses the "native" type for surfaces while the
|
||||
// header as seen in this file uses the wrapped type.
|
||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation
|
||||
CreateNativeSwapChainImpl(DawnDevice device, VkSurfaceKHRNative surfaceNative) {
|
||||
CreateNativeSwapChainImpl(WGPUDevice device, VkSurfaceKHRNative surfaceNative) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
VkSurfaceKHR surface = VkSurfaceKHR::CreateFromHandle(surfaceNative);
|
||||
|
||||
DawnSwapChainImplementation impl;
|
||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, surface));
|
||||
impl.textureUsage = DAWN_TEXTURE_USAGE_PRESENT;
|
||||
impl.textureUsage = WGPUTextureUsage_Present;
|
||||
|
||||
return impl;
|
||||
}
|
||||
|
||||
DawnTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
WGPUTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
const DawnSwapChainImplementation* swapChain) {
|
||||
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
||||
return static_cast<DawnTextureFormat>(impl->GetPreferredFormat());
|
||||
return static_cast<WGPUTextureFormat>(impl->GetPreferredFormat());
|
||||
}
|
||||
|
||||
#ifdef DAWN_PLATFORM_LINUX
|
||||
DawnTexture WrapVulkanImageOpaqueFD(DawnDevice cDevice,
|
||||
WGPUTexture WrapVulkanImageOpaqueFD(WGPUDevice cDevice,
|
||||
const ExternalImageDescriptorOpaqueFD* descriptor) {
|
||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||
|
||||
TextureBase* texture = device->CreateTextureWrappingVulkanImage(
|
||||
descriptor, descriptor->memoryFD, descriptor->waitFDs);
|
||||
|
||||
return reinterpret_cast<DawnTexture>(texture);
|
||||
return reinterpret_cast<WGPUTexture>(texture);
|
||||
}
|
||||
|
||||
int ExportSignalSemaphoreOpaqueFD(DawnDevice cDevice, DawnTexture cTexture) {
|
||||
int ExportSignalSemaphoreOpaqueFD(WGPUDevice cDevice, WGPUTexture cTexture) {
|
||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||
Texture* texture = reinterpret_cast<Texture*>(cTexture);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#ifndef DAWN_DAWN_WSI_H_
|
||||
#define DAWN_DAWN_WSI_H_
|
||||
|
||||
#include <dawn/dawn.h>
|
||||
#include <dawn/webgpu.h>
|
||||
|
||||
// Error message (or nullptr if there was no error)
|
||||
typedef const char* DawnSwapChainError;
|
||||
|
@ -40,8 +40,8 @@ typedef struct {
|
|||
|
||||
/// Configure/reconfigure the swap chain.
|
||||
DawnSwapChainError (*Configure)(void* userData,
|
||||
DawnTextureFormat format,
|
||||
DawnTextureUsage allowedUsage,
|
||||
WGPUTextureFormat format,
|
||||
WGPUTextureUsage allowedUsage,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
|
||||
|
@ -55,12 +55,12 @@ typedef struct {
|
|||
void* userData;
|
||||
|
||||
/// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
|
||||
DawnTextureUsage textureUsage;
|
||||
WGPUTextureUsage textureUsage;
|
||||
} DawnSwapChainImplementation;
|
||||
|
||||
#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
|
||||
typedef struct {
|
||||
DawnDevice device = nullptr;
|
||||
WGPUDevice device = nullptr;
|
||||
} DawnWSIContextD3D12;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -24,15 +24,15 @@
|
|||
struct ID3D12Device;
|
||||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D12Device> GetD3D12Device(DawnDevice device);
|
||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(DawnDevice device,
|
||||
DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D12Device> GetD3D12Device(WGPUDevice device);
|
||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device,
|
||||
HWND window);
|
||||
DAWN_NATIVE_EXPORT DawnTextureFormat
|
||||
DAWN_NATIVE_EXPORT WGPUTextureFormat
|
||||
GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
|
||||
|
||||
// Note: SharedHandle must be a handle to a texture object.
|
||||
DAWN_NATIVE_EXPORT DawnTexture WrapSharedHandle(DawnDevice device,
|
||||
const DawnTextureDescriptor* descriptor,
|
||||
DAWN_NATIVE_EXPORT WGPUTexture WrapSharedHandle(WGPUDevice device,
|
||||
const WGPUTextureDescriptor* descriptor,
|
||||
HANDLE sharedHandle,
|
||||
uint64_t acquireMutexKey);
|
||||
}} // namespace dawn_native::d3d12
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#ifndef DAWNNATIVE_DAWNNATIVE_H_
|
||||
#define DAWNNATIVE_DAWNNATIVE_H_
|
||||
|
||||
#include <dawn/dawn.h>
|
||||
#include <dawn/dawn_proc_table.h>
|
||||
#include <dawn/webgpu.h>
|
||||
#include <dawn_native/dawn_native_export.h>
|
||||
|
||||
#include <string>
|
||||
|
@ -96,7 +96,7 @@ namespace dawn_native {
|
|||
// Create a device on this adapter, note that the interface will change to include at least
|
||||
// a device descriptor and a pointer to backend specific options.
|
||||
// On an error, nullptr is returned.
|
||||
DawnDevice CreateDevice(const DeviceDescriptor* deviceDescriptor = nullptr);
|
||||
WGPUDevice CreateDevice(const DeviceDescriptor* deviceDescriptor = nullptr);
|
||||
|
||||
private:
|
||||
AdapterBase* mImpl = nullptr;
|
||||
|
@ -156,10 +156,10 @@ namespace dawn_native {
|
|||
DAWN_NATIVE_EXPORT DawnProcTable GetProcs();
|
||||
|
||||
// Query the names of all the toggles that are enabled in device
|
||||
DAWN_NATIVE_EXPORT std::vector<const char*> GetTogglesUsed(DawnDevice device);
|
||||
DAWN_NATIVE_EXPORT std::vector<const char*> GetTogglesUsed(WGPUDevice device);
|
||||
|
||||
// Backdoor to get the number of lazy clears for testing
|
||||
DAWN_NATIVE_EXPORT size_t GetLazyClearCountForTesting(DawnDevice device);
|
||||
DAWN_NATIVE_EXPORT size_t GetLazyClearCountForTesting(WGPUDevice device);
|
||||
|
||||
// Backdoor to get the order of the ProcMap for testing
|
||||
DAWN_NATIVE_EXPORT std::vector<const char*> GetProcMapNamesForTesting();
|
||||
|
|
|
@ -33,8 +33,8 @@ typedef __IOSurface* IOSurfaceRef;
|
|||
#endif //__OBJC__
|
||||
|
||||
namespace dawn_native { namespace metal {
|
||||
DAWN_NATIVE_EXPORT DawnTexture WrapIOSurface(DawnDevice device,
|
||||
const DawnTextureDescriptor* descriptor,
|
||||
DAWN_NATIVE_EXPORT WGPUTexture WrapIOSurface(WGPUDevice device,
|
||||
const WGPUTextureDescriptor* descriptor,
|
||||
IOSurfaceRef ioSurface,
|
||||
uint32_t plane);
|
||||
|
||||
|
@ -43,12 +43,12 @@ namespace dawn_native { namespace metal {
|
|||
// does have a global queue of graphics operations, but the command buffers are inserted there
|
||||
// when they are "scheduled". Submitting other operations before the command buffer is
|
||||
// scheduled could lead to races in who gets scheduled first and incorrect rendering.
|
||||
DAWN_NATIVE_EXPORT void WaitForCommandsToBeScheduled(DawnDevice device);
|
||||
DAWN_NATIVE_EXPORT void WaitForCommandsToBeScheduled(WGPUDevice device);
|
||||
}} // namespace dawn_native::metal
|
||||
|
||||
#ifdef __OBJC__
|
||||
namespace dawn_native { namespace metal {
|
||||
DAWN_NATIVE_EXPORT id<MTLDevice> GetMetalDevice(DawnDevice device);
|
||||
DAWN_NATIVE_EXPORT id<MTLDevice> GetMetalDevice(WGPUDevice device);
|
||||
}} // namespace dawn_native::metal
|
||||
#endif // __OBJC__
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ namespace dawn_native { namespace opengl {
|
|||
|
||||
using PresentCallback = void (*)(void*);
|
||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation
|
||||
CreateNativeSwapChainImpl(DawnDevice device, PresentCallback present, void* presentUserdata);
|
||||
DAWN_NATIVE_EXPORT DawnTextureFormat
|
||||
CreateNativeSwapChainImpl(WGPUDevice device, PresentCallback present, void* presentUserdata);
|
||||
DAWN_NATIVE_EXPORT WGPUTextureFormat
|
||||
GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
|
||||
|
||||
}} // namespace dawn_native::opengl
|
||||
|
|
|
@ -26,17 +26,17 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
// Common properties of external images
|
||||
struct ExternalImageDescriptor {
|
||||
const DawnTextureDescriptor* cTextureDescriptor; // Must match image creation params
|
||||
const WGPUTextureDescriptor* cTextureDescriptor; // Must match image creation params
|
||||
bool isCleared; // Sets whether the texture will be cleared before use
|
||||
VkDeviceSize allocationSize; // Must match VkMemoryAllocateInfo from image creation
|
||||
uint32_t memoryTypeIndex; // Must match VkMemoryAllocateInfo from image creation
|
||||
};
|
||||
|
||||
DAWN_NATIVE_EXPORT VkInstance GetInstance(DawnDevice device);
|
||||
DAWN_NATIVE_EXPORT VkInstance GetInstance(WGPUDevice device);
|
||||
|
||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(DawnDevice device,
|
||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device,
|
||||
VkSurfaceKHR surface);
|
||||
DAWN_NATIVE_EXPORT DawnTextureFormat
|
||||
DAWN_NATIVE_EXPORT WGPUTextureFormat
|
||||
GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
|
||||
|
||||
// Can't use DAWN_PLATFORM_LINUX since header included in both dawn and chrome
|
||||
|
@ -52,14 +52,14 @@ namespace dawn_native { namespace vulkan {
|
|||
// |descriptor->waitFDs| before the texture can be used. Finally, a signal semaphore
|
||||
// can be exported, transferring control back to the caller.
|
||||
// On failure, returns a nullptr
|
||||
DAWN_NATIVE_EXPORT DawnTexture
|
||||
WrapVulkanImageOpaqueFD(DawnDevice cDevice,
|
||||
DAWN_NATIVE_EXPORT WGPUTexture
|
||||
WrapVulkanImageOpaqueFD(WGPUDevice cDevice,
|
||||
const ExternalImageDescriptorOpaqueFD* descriptor);
|
||||
|
||||
// Exports a signal semaphore from a wrapped texture. This must be called on wrapped
|
||||
// textures before they are destroyed. On failure, returns -1
|
||||
DAWN_NATIVE_EXPORT int ExportSignalSemaphoreOpaqueFD(DawnDevice cDevice,
|
||||
DawnTexture cTexture);
|
||||
DAWN_NATIVE_EXPORT int ExportSignalSemaphoreOpaqueFD(WGPUDevice cDevice,
|
||||
WGPUTexture cTexture);
|
||||
#endif // __linux__
|
||||
}} // namespace dawn_native::vulkan
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ TEST_F(ExtensionTests, AdapterWithRequiredExtensionDisabled) {
|
|||
dawn_native::DeviceDescriptor deviceDescriptor;
|
||||
const char* extensionName = ExtensionEnumToName(notSupportedExtension);
|
||||
deviceDescriptor.requiredExtensions = std::vector<const char*>(1, extensionName);
|
||||
DawnDevice deviceWithExtension = adapterWithoutExtension.CreateDevice(&deviceDescriptor);
|
||||
WGPUDevice deviceWithExtension = adapterWithoutExtension.CreateDevice(&deviceDescriptor);
|
||||
ASSERT_EQ(nullptr, deviceWithExtension);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue