gpu: example: store gpu.Surface
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
9916ec043b
commit
9956ff1864
1 changed files with 3 additions and 4 deletions
|
|
@ -38,12 +38,11 @@ pub fn main() !void {
|
||||||
.presentMode = c.WGPUPresentMode_Fifo,
|
.presentMode = c.WGPUPresentMode_Fifo,
|
||||||
.implementation = 0,
|
.implementation = 0,
|
||||||
};
|
};
|
||||||
const surface = sample_utils.createSurfaceForWindow(
|
window_data.surface = sample_utils.createSurfaceForWindow(
|
||||||
&setup.native_instance,
|
&setup.native_instance,
|
||||||
setup.window,
|
setup.window,
|
||||||
comptime sample_utils.detectGLFWOptions(),
|
comptime sample_utils.detectGLFWOptions(),
|
||||||
);
|
);
|
||||||
window_data.surface = @ptrCast(c.WGPUSurface, surface.ptr);
|
|
||||||
} else {
|
} else {
|
||||||
const binding = c.machUtilsCreateBinding(setup.backend_type, @ptrCast(*c.GLFWwindow, setup.window.handle), setup.device);
|
const binding = c.machUtilsCreateBinding(setup.backend_type, @ptrCast(*c.GLFWwindow, setup.window.handle), setup.device);
|
||||||
if (binding == null) {
|
if (binding == null) {
|
||||||
|
|
@ -170,7 +169,7 @@ pub fn main() !void {
|
||||||
}
|
}
|
||||||
|
|
||||||
const WindowData = struct {
|
const WindowData = struct {
|
||||||
surface: ?c.WGPUSurface,
|
surface: ?gpu.Surface,
|
||||||
swap_chain: ?c.WGPUSwapChain,
|
swap_chain: ?c.WGPUSwapChain,
|
||||||
swap_chain_format: c.WGPUTextureFormat,
|
swap_chain_format: c.WGPUTextureFormat,
|
||||||
current_desc: c.WGPUSwapChainDescriptor,
|
current_desc: c.WGPUSwapChainDescriptor,
|
||||||
|
|
@ -194,7 +193,7 @@ fn frame(params: FrameParams) !void {
|
||||||
if (pl.swap_chain == null or !isDescriptorEqual(pl.current_desc, pl.target_desc)) {
|
if (pl.swap_chain == null or !isDescriptorEqual(pl.current_desc, pl.target_desc)) {
|
||||||
const use_legacy_api = pl.surface == null;
|
const use_legacy_api = pl.surface == null;
|
||||||
if (!use_legacy_api) {
|
if (!use_legacy_api) {
|
||||||
pl.swap_chain = c.wgpuDeviceCreateSwapChain(params.device, pl.surface.?, &pl.target_desc);
|
pl.swap_chain = c.wgpuDeviceCreateSwapChain(params.device, @ptrCast(c.WGPUSurface, pl.surface.?.ptr), &pl.target_desc);
|
||||||
} else {
|
} else {
|
||||||
c.wgpuSwapChainConfigure(
|
c.wgpuSwapChainConfigure(
|
||||||
pl.swap_chain.?,
|
pl.swap_chain.?,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue