Make the SwapChain interface match webgpu.h

This changes the methods of Dawn's SwapChain to match webgpu.h, namely
Present() now doesn't take arguments, and GetNextTexture() is replaced
with GetCurrentTextureView().

BUG=dawn:269

Change-Id: Ia0debefb170caf799c3310b1dad5535c4c5f59ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13441
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez
2019-11-12 18:30:11 +00:00
committed by Commit Bot service account
parent 700cfe7664
commit 604072bc2e
8 changed files with 53 additions and 47 deletions

View File

@@ -143,7 +143,7 @@ void init() {
}
void frame() {
wgpu::Texture backbuffer = swapchain.GetNextTexture();
wgpu::TextureView backbufferView = swapchain.GetCurrentTextureView();
static int f = 0;
f++;
@@ -152,7 +152,7 @@ void frame() {
}
ubo.SetSubData(0, kNumTriangles * sizeof(ShaderData), shaderData.data());
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()});
utils::ComboRenderPassDescriptor renderPass({backbufferView});
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
@@ -169,7 +169,7 @@ void frame() {
wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands);
swapchain.Present(backbuffer);
swapchain.Present();
DoFlush();
fprintf(stderr, "frame %i\n", f);
}

View File

@@ -125,8 +125,7 @@ void init() {
}
void frame() {
WGPUTexture backbuffer = wgpuSwapChainGetNextTexture(swapchain);
WGPUTextureView backbufferView = wgpuTextureCreateView(backbuffer, nullptr);
WGPUTextureView backbufferView = wgpuSwapChainGetCurrentTextureView(swapchain);
WGPURenderPassDescriptor renderpassInfo;
renderpassInfo.nextInChain = nullptr;
renderpassInfo.label = nullptr;
@@ -157,7 +156,7 @@ void frame() {
wgpuQueueSubmit(queue, 1, &commands);
wgpuCommandBufferRelease(commands);
wgpuSwapChainPresent(swapchain, backbuffer);
wgpuSwapChainPresent(swapchain);
wgpuTextureViewRelease(backbufferView);
DoFlush();

View File

@@ -261,7 +261,7 @@ void initSim() {
}
}
wgpu::CommandBuffer createCommandBuffer(const wgpu::Texture backbuffer, size_t i) {
wgpu::CommandBuffer createCommandBuffer(const wgpu::TextureView backbufferView, size_t i) {
auto& bufferDst = particleBuffers[(i + 1) % 2];
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@@ -274,7 +274,7 @@ wgpu::CommandBuffer createCommandBuffer(const wgpu::Texture backbuffer, size_t i
}
{
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()}, depthStencilView);
utils::ComboRenderPassDescriptor renderPass({backbufferView}, depthStencilView);
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(renderPipeline);
pass.SetVertexBuffer(0, bufferDst);
@@ -300,11 +300,11 @@ void init() {
}
void frame() {
wgpu::Texture backbuffer = swapchain.GetNextTexture();
wgpu::TextureView backbufferView = swapchain.GetCurrentTextureView();
wgpu::CommandBuffer commandBuffer = createCommandBuffer(backbuffer, pingpong);
wgpu::CommandBuffer commandBuffer = createCommandBuffer(backbufferView, pingpong);
queue.Submit(1, &commandBuffer);
swapchain.Present(backbuffer);
swapchain.Present();
DoFlush();
pingpong = (pingpong + 1) % 2;

View File

@@ -153,8 +153,8 @@ void frame() {
s.b += 0.02f;
if (s.b >= 1.0f) {s.b = 0.0f;}
wgpu::Texture backbuffer = swapchain.GetNextTexture();
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()}, depthStencilView);
wgpu::TextureView backbufferView = swapchain.GetCurrentTextureView();
utils::ComboRenderPassDescriptor renderPass({backbufferView}, depthStencilView);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{
@@ -169,7 +169,7 @@ void frame() {
wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands);
swapchain.Present(backbuffer);
swapchain.Present();
DoFlush();
}

View File

@@ -264,8 +264,8 @@ void frame() {
cameraBuffer.SetSubData(0, sizeof(CameraData), &cameraData);
wgpu::Texture backbuffer = swapchain.GetNextTexture();
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()}, depthStencilView);
wgpu::TextureView backbufferView = swapchain.GetCurrentTextureView();
utils::ComboRenderPassDescriptor renderPass({backbufferView}, depthStencilView);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{
@@ -292,7 +292,7 @@ void frame() {
wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands);
swapchain.Present(backbuffer);
swapchain.Present();
DoFlush();
}