mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
Merge #109
109: V0.2 windows fix r=travis a=kvark Co-authored-by: Joshua Groves <josh@joshgroves.com> Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
This commit is contained in:
commit
5be4295a3e
37
.travis.yml
37
.travis.yml
@ -1,7 +1,35 @@
|
||||
language: rust
|
||||
rust:
|
||||
- stable
|
||||
- nightly
|
||||
|
||||
matrix:
|
||||
include:
|
||||
# Linux 64bit
|
||||
- os: linux
|
||||
rust: stable
|
||||
compiler: gcc
|
||||
- os: linux
|
||||
rust: nightly
|
||||
compiler: gcc
|
||||
# Windows 64bit
|
||||
- os: windows
|
||||
rust: stable
|
||||
|
||||
# macOS 64bit
|
||||
- env: MACOSX_DEPLOYMENT_TARGET=10.9
|
||||
os: osx
|
||||
rust: stable
|
||||
osx_image: xcode9
|
||||
compiler: clang
|
||||
#- env: MACOSX_DEPLOYMENT_TARGET=10.9
|
||||
# os: osx
|
||||
# rust: nightly
|
||||
# osx_image: xcode9
|
||||
# compiler: clang
|
||||
|
||||
# iPhoneOS 64bit
|
||||
#- env: TARGET=aarch64-apple-ios
|
||||
# os: osx
|
||||
# osx_image: xcode9
|
||||
# rust: nightly
|
||||
|
||||
branches:
|
||||
except:
|
||||
@ -11,7 +39,8 @@ before_install:
|
||||
# Do not run bors builds against the nightly compiler.
|
||||
# We want to find out about nightly bugs, so they're done in master, but we don't block on them.
|
||||
- if [[ $TRAVIS_RUST_VERSION == "nightly" && $TRAVIS_BRANCH == "staging" ]]; then exit; fi
|
||||
- if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install make; fi
|
||||
|
||||
script:
|
||||
- cargo test
|
||||
- cargo check --manifest-path wgpu-native/Cargo.toml
|
||||
#- if [[ $TRAVIS_OS_NAME == "osx" ]]; then (brew update && brew upgrade cmake && brew install glfw3 && cd wgpu-native && cargo build --features=local,gfx-backend-metal && cd ../examples/hello_triangle_c && mkdir build && cd build && cmake .. && make); fi
|
||||
|
@ -1,5 +1,9 @@
|
||||
# Change Log
|
||||
|
||||
## v0.2.2 (19-03-2019)
|
||||
- fixed vertex format mapping
|
||||
- fixed building with "empty" backend on Windows
|
||||
|
||||
## v0.2 (06-03-2019)
|
||||
- Platforms: iOS/Metal, D3D11
|
||||
- Crates:
|
||||
|
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -321,7 +321,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wgpu 0.2.0",
|
||||
"wgpu-native 0.2.1",
|
||||
"wgpu-native 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1387,7 +1387,7 @@ name = "wgpu"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wgpu-native 0.2.1",
|
||||
"wgpu-native 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1399,7 +1399,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-native"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
dependencies = [
|
||||
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1425,7 +1425,7 @@ dependencies = [
|
||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wgpu-native 0.2.1",
|
||||
"wgpu-native 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -10,18 +10,16 @@ if(MSVC)
|
||||
target_compile_options(${TARGET_NAME} PRIVATE /W4)
|
||||
add_compile_definitions(WGPU_TARGET=WGPU_TARGET_WINDOWS)
|
||||
set(GLFW_LIBRARY glfw3)
|
||||
elif(APPLE)
|
||||
target_compile_options(${TARGET_NAME} PRIVATE -x objective-c)
|
||||
add_compile_definitions(WGPU_TARGET=WGPU_TARGET_MACOS)
|
||||
set(OS_LIBRARIES "-framework Cocoa" "-framework CoreVideo" "-framework IOKit" "-framework QuartzCore")
|
||||
else(MSVC)
|
||||
target_compile_options(${TARGET_NAME} PRIVATE -Wall -Wextra -pedantic)
|
||||
add_compile_definitions(WGPU_TARGET=WGPU_TARGET_LINUX)
|
||||
set(GLFW_LIBRARY glfw)
|
||||
endif(MSVC)
|
||||
|
||||
if(APPLE)
|
||||
add_compile_definitions(WGPU_TARGET=WGPU_TARGET_MACOS)
|
||||
set(OS_LIBRARIES "-framework Cocoa" "-framework CoreVideo" "-framework IOKit" "-framework QuartzCore")
|
||||
target_compile_options(${TARGET_NAME} PRIVATE -x objective-c)
|
||||
endif(APPLE)
|
||||
|
||||
find_package(glfw3)
|
||||
|
||||
find_library(WGPU_LIBRARY wgpu_native
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include <stdio.h>
|
||||
#include "./../../wgpu-bindings/wgpu.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define WGPU_TARGET_MACOS 1
|
||||
#define WGPU_TARGET_LINUX 2
|
||||
#define WGPU_TARGET_WINDOWS 3
|
||||
|
||||
#if WGPU_TARGET == WGPU_TARGET_MACOS
|
||||
#include <QuartzCore/CAMetalLayer.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <QuartzCore/CAMetalLayer.h>
|
||||
#endif
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
@ -21,199 +21,176 @@
|
||||
#endif
|
||||
#include <GLFW/glfw3native.h>
|
||||
|
||||
#define STAGES_LENGTH (2)
|
||||
#define BLEND_STATES_LENGTH (1)
|
||||
#define ATTACHMENTS_LENGTH (1)
|
||||
#define RENDER_PASS_ATTACHMENTS_LENGTH (1)
|
||||
#define BIND_GROUP_LAYOUTS_LENGTH (1)
|
||||
|
||||
WGPUByteArray read_file(const char *name)
|
||||
{
|
||||
FILE *file = fopen(name, "rb");
|
||||
fseek(file, 0, SEEK_END);
|
||||
long length = ftell(file);
|
||||
unsigned char *bytes = malloc(length);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
fread(bytes, 1, length, file);
|
||||
fclose(file);
|
||||
WGPUByteArray ret = {
|
||||
.bytes = bytes,
|
||||
.length = length,
|
||||
};
|
||||
return ret;
|
||||
WGPUByteArray read_file(const char *name) {
|
||||
FILE *file = fopen(name, "rb");
|
||||
fseek(file, 0, SEEK_END);
|
||||
long length = ftell(file);
|
||||
unsigned char *bytes = malloc(length);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
fread(bytes, 1, length, file);
|
||||
fclose(file);
|
||||
return (WGPUByteArray){
|
||||
.bytes = bytes,
|
||||
.length = length,
|
||||
};
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
WGPUInstanceId instance = wgpu_create_instance();
|
||||
WGPUAdapterDescriptor adapter_desc = {
|
||||
.power_preference = WGPUPowerPreference_LowPower,
|
||||
};
|
||||
WGPUAdapterId adapter = wgpu_instance_get_adapter(instance, &adapter_desc);
|
||||
WGPUDeviceDescriptor device_desc = {
|
||||
.extensions = {
|
||||
.anisotropic_filtering = false,
|
||||
},
|
||||
};
|
||||
WGPUDeviceId device = wgpu_adapter_create_device(adapter, &device_desc);
|
||||
int main() {
|
||||
WGPUInstanceId instance = wgpu_create_instance();
|
||||
|
||||
WGPUShaderModuleDescriptor vertex_shader_desc = {
|
||||
.code = read_file("./../../data/hello_triangle.vert.spv"),
|
||||
};
|
||||
WGPUShaderModuleId vertex_shader = wgpu_device_create_shader_module(device, &vertex_shader_desc);
|
||||
WGPUPipelineStageDescriptor vertex_stage = {
|
||||
.module = vertex_shader,
|
||||
.stage = WGPUShaderStage_Vertex,
|
||||
.entry_point = "main",
|
||||
};
|
||||
WGPUAdapterId adapter = wgpu_instance_get_adapter(
|
||||
instance, &(WGPUAdapterDescriptor){
|
||||
.power_preference = WGPUPowerPreference_LowPower,
|
||||
});
|
||||
|
||||
WGPUShaderModuleDescriptor fragment_shader_desc = {
|
||||
.code = read_file("./../../data/hello_triangle.frag.spv"),
|
||||
};
|
||||
WGPUShaderModuleId fragment_shader = wgpu_device_create_shader_module(device, &fragment_shader_desc);
|
||||
WGPUPipelineStageDescriptor fragment_stage = {
|
||||
.module = fragment_shader,
|
||||
.stage = WGPUShaderStage_Fragment,
|
||||
.entry_point = "main",
|
||||
};
|
||||
WGPUDeviceId device = wgpu_adapter_create_device(
|
||||
adapter, &(WGPUDeviceDescriptor){
|
||||
.extensions =
|
||||
{
|
||||
.anisotropic_filtering = false,
|
||||
},
|
||||
});
|
||||
|
||||
WGPUPipelineStageDescriptor stages[STAGES_LENGTH] = {vertex_stage, fragment_stage};
|
||||
WGPUShaderModuleId vertex_shader = wgpu_device_create_shader_module(
|
||||
device, &(WGPUShaderModuleDescriptor){
|
||||
.code = read_file("./../../data/hello_triangle.vert.spv"),
|
||||
});
|
||||
|
||||
WGPUBindGroupLayoutDescriptor bind_group_layout_desc = {
|
||||
.bindings = NULL,
|
||||
.bindings_length = 0,
|
||||
};
|
||||
WGPUBindGroupLayoutId bind_group_layout = wgpu_device_create_bind_group_layout(device, &bind_group_layout_desc);
|
||||
WGPUShaderModuleId fragment_shader = wgpu_device_create_shader_module(
|
||||
device, &(WGPUShaderModuleDescriptor){
|
||||
.code = read_file("./../../data/hello_triangle.frag.spv"),
|
||||
});
|
||||
|
||||
WGPUBindGroupLayoutId bind_group_layouts[BIND_GROUP_LAYOUTS_LENGTH] = { bind_group_layout };
|
||||
WGPUBindGroupLayoutId bind_group_layout =
|
||||
wgpu_device_create_bind_group_layout(device,
|
||||
&(WGPUBindGroupLayoutDescriptor){
|
||||
.bindings = NULL,
|
||||
.bindings_length = 0,
|
||||
});
|
||||
WGPUBindGroupLayoutId bind_group_layouts[BIND_GROUP_LAYOUTS_LENGTH] = {
|
||||
bind_group_layout};
|
||||
|
||||
WGPUPipelineLayoutDescriptor pipeline_layout_desc = {
|
||||
.bind_group_layouts = bind_group_layouts,
|
||||
.bind_group_layouts_length = BIND_GROUP_LAYOUTS_LENGTH,
|
||||
};
|
||||
WGPUPipelineLayoutId pipeline_layout = wgpu_device_create_pipeline_layout(device, &pipeline_layout_desc);
|
||||
WGPUPipelineLayoutId pipeline_layout = wgpu_device_create_pipeline_layout(
|
||||
device, &(WGPUPipelineLayoutDescriptor){
|
||||
.bind_group_layouts = bind_group_layouts,
|
||||
.bind_group_layouts_length = BIND_GROUP_LAYOUTS_LENGTH,
|
||||
});
|
||||
|
||||
WGPUBlendDescriptor blend_alpha = {
|
||||
.src_factor = WGPUBlendFactor_One,
|
||||
.dst_factor = WGPUBlendFactor_Zero,
|
||||
.operation = WGPUBlendOperation_Add,
|
||||
};
|
||||
WGPUBlendDescriptor blend_color = {
|
||||
.src_factor = WGPUBlendFactor_One,
|
||||
.dst_factor = WGPUBlendFactor_Zero,
|
||||
.operation = WGPUBlendOperation_Add,
|
||||
};
|
||||
WGPUBlendStateDescriptor blend_state_0_desc = {
|
||||
.blend_enabled = false,
|
||||
.alpha = blend_alpha,
|
||||
.color = blend_color,
|
||||
.write_mask = WGPUColorWriteFlags_ALL,
|
||||
};
|
||||
WGPUBlendStateId blend_state_0 = wgpu_device_create_blend_state(device, &blend_state_0_desc);
|
||||
WGPUBlendStateId blend_state[BLEND_STATES_LENGTH] = {blend_state_0};
|
||||
WGPURenderPipelineId render_pipeline = wgpu_device_create_render_pipeline(
|
||||
device, &(WGPURenderPipelineDescriptor){
|
||||
.layout = pipeline_layout,
|
||||
.vertex_stage =
|
||||
(WGPUPipelineStageDescriptor){
|
||||
.module = vertex_shader,
|
||||
.entry_point = "main",
|
||||
},
|
||||
.fragment_stage =
|
||||
(WGPUPipelineStageDescriptor){
|
||||
.module = fragment_shader,
|
||||
.entry_point = "main",
|
||||
},
|
||||
.rasterization_state =
|
||||
(WGPURasterizationStateDescriptor){
|
||||
.front_face = WGPUFrontFace_Ccw,
|
||||
.cull_mode = WGPUCullMode_None,
|
||||
.depth_bias = 0,
|
||||
.depth_bias_slope_scale = 0.0,
|
||||
.depth_bias_clamp = 0.0,
|
||||
},
|
||||
.primitive_topology = WGPUPrimitiveTopology_TriangleList,
|
||||
.color_states =
|
||||
&(WGPUColorStateDescriptor){
|
||||
.format = WGPUTextureFormat_Bgra8Unorm,
|
||||
.alpha =
|
||||
(WGPUBlendDescriptor){
|
||||
.src_factor = WGPUBlendFactor_One,
|
||||
.dst_factor = WGPUBlendFactor_Zero,
|
||||
.operation = WGPUBlendOperation_Add,
|
||||
},
|
||||
.color =
|
||||
(WGPUBlendDescriptor){
|
||||
.src_factor = WGPUBlendFactor_One,
|
||||
.dst_factor = WGPUBlendFactor_Zero,
|
||||
.operation = WGPUBlendOperation_Add,
|
||||
},
|
||||
.write_mask = WGPUColorWriteFlags_ALL,
|
||||
},
|
||||
.color_states_length = 1,
|
||||
.depth_stencil_state = NULL,
|
||||
.vertex_buffer_state =
|
||||
(WGPUVertexBufferStateDescriptor){
|
||||
.index_format = WGPUIndexFormat_Uint16,
|
||||
.vertex_buffers = NULL,
|
||||
.vertex_buffers_count = 0,
|
||||
},
|
||||
.sample_count = 1,
|
||||
});
|
||||
|
||||
WGPUStencilStateFaceDescriptor stencil_state_front = {
|
||||
.compare = WGPUCompareFunction_Never,
|
||||
.stencil_fail_op = WGPUStencilOperation_Keep,
|
||||
.depth_fail_op = WGPUStencilOperation_Keep,
|
||||
.pass_op = WGPUStencilOperation_Keep,
|
||||
};
|
||||
WGPUStencilStateFaceDescriptor stencil_state_back = {
|
||||
.compare = WGPUCompareFunction_Never,
|
||||
.stencil_fail_op = WGPUStencilOperation_Keep,
|
||||
.depth_fail_op = WGPUStencilOperation_Keep,
|
||||
.pass_op = WGPUStencilOperation_Keep,
|
||||
};
|
||||
WGPUDepthStencilStateDescriptor depth_stencil_state_desc = {
|
||||
.depth_write_enabled = false,
|
||||
.depth_compare = WGPUCompareFunction_Never,
|
||||
.front = stencil_state_front,
|
||||
.back = stencil_state_back,
|
||||
.stencil_read_mask = 0,
|
||||
.stencil_write_mask = 0,
|
||||
};
|
||||
WGPUDepthStencilStateId depth_stencil_state = wgpu_device_create_depth_stencil_state(device, &depth_stencil_state_desc);
|
||||
if (!glfwInit()) {
|
||||
printf("Cannot initialize glfw");
|
||||
return 1;
|
||||
}
|
||||
|
||||
WGPUAttachment attachments[ATTACHMENTS_LENGTH] = {
|
||||
{
|
||||
.format = WGPUTextureFormat_Bgra8Unorm,
|
||||
.samples = 1,
|
||||
},
|
||||
};
|
||||
WGPUAttachmentsState attachment_state = {
|
||||
.color_attachments = attachments,
|
||||
.color_attachments_length = ATTACHMENTS_LENGTH,
|
||||
.depth_stencil_attachment = NULL,
|
||||
};
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
GLFWwindow *window = glfwCreateWindow(640, 480, "wgpu with glfw", NULL, NULL);
|
||||
|
||||
WGPURenderPipelineDescriptor render_pipeline_desc = {
|
||||
.layout = pipeline_layout,
|
||||
.stages = stages,
|
||||
.stages_length = STAGES_LENGTH,
|
||||
.primitive_topology = WGPUPrimitiveTopology_TriangleList,
|
||||
.attachments_state = attachment_state,
|
||||
.blend_states = blend_state,
|
||||
.blend_states_length = BLEND_STATES_LENGTH,
|
||||
.depth_stencil_state = depth_stencil_state,
|
||||
};
|
||||
if (!window) {
|
||||
printf("Cannot create window");
|
||||
return 1;
|
||||
}
|
||||
|
||||
WGPURenderPipelineId render_pipeline = wgpu_device_create_render_pipeline(device, &render_pipeline_desc);
|
||||
|
||||
if (!glfwInit())
|
||||
{
|
||||
printf("Cannot initialize glfw");
|
||||
return 1;
|
||||
}
|
||||
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
GLFWwindow *window = glfwCreateWindow(640, 480, "wgpu with glfw", NULL, NULL);
|
||||
|
||||
if (!window)
|
||||
{
|
||||
printf("Cannot create window");
|
||||
return 1;
|
||||
}
|
||||
|
||||
WGPUSurfaceId surface = NULL;
|
||||
WGPUSurfaceId surface = {};
|
||||
|
||||
#if WGPU_TARGET == WGPU_TARGET_MACOS
|
||||
{
|
||||
id metal_layer = NULL;
|
||||
NSWindow *ns_window = glfwGetCocoaWindow(window);
|
||||
CALayer *layer = ns_window.contentView.layer;
|
||||
[ns_window.contentView setWantsLayer:YES];
|
||||
metal_layer = [CAMetalLayer layer];
|
||||
[ns_window.contentView setLayer:metal_layer];
|
||||
surface = wgpu_instance_create_surface_from_macos_layer(instance, metal_layer);
|
||||
}
|
||||
{
|
||||
id metal_layer = NULL;
|
||||
NSWindow *ns_window = glfwGetCocoaWindow(window);
|
||||
CALayer *layer = ns_window.contentView.layer;
|
||||
[ns_window.contentView setWantsLayer:YES];
|
||||
metal_layer = [CAMetalLayer layer];
|
||||
[ns_window.contentView setLayer:metal_layer];
|
||||
surface =
|
||||
wgpu_instance_create_surface_from_macos_layer(instance, metal_layer);
|
||||
}
|
||||
#elif WGPU_TARGET == WGPU_TARGET_LINUX
|
||||
{
|
||||
Display* x11_display = glfwGetX11Display();
|
||||
Window x11_window = glfwGetX11Window(window);
|
||||
surface = wgpu_instance_create_surface_from_xlib(instance, (const void**)x11_display, x11_window);
|
||||
}
|
||||
{
|
||||
Display *x11_display = glfwGetX11Display();
|
||||
Window x11_window = glfwGetX11Window(window);
|
||||
surface = wgpu_instance_create_surface_from_xlib(
|
||||
instance, (const void **)x11_display, x11_window);
|
||||
}
|
||||
#elif WGPU_TARGET == WGPU_TARGET_WINDOWS
|
||||
{
|
||||
HWND hwnd = glfwGetWin32Window(window);
|
||||
HINSTANCE hinstance = GetModuleHandle(NULL);
|
||||
surface = wgpu_instance_create_surface_from_windows_hwnd(instance, hinstance, hwnd);
|
||||
}
|
||||
{
|
||||
HWND hwnd = glfwGetWin32Window(window);
|
||||
HINSTANCE hinstance = GetModuleHandle(NULL);
|
||||
surface = wgpu_instance_create_surface_from_windows_hwnd(instance,
|
||||
hinstance, hwnd);
|
||||
}
|
||||
#endif
|
||||
|
||||
WGPUSwapChainDescriptor swap_chain_desc = {
|
||||
.usage = WGPUTextureUsageFlags_OUTPUT_ATTACHMENT | WGPUTextureUsageFlags_PRESENT,
|
||||
.format = WGPUTextureFormat_Bgra8Unorm,
|
||||
.width = 640,
|
||||
.height = 480,
|
||||
};
|
||||
WGPUSwapChainId swap_chain = wgpu_device_create_swap_chain(device, surface, &swap_chain_desc);
|
||||
WGPUSwapChainId swap_chain = wgpu_device_create_swap_chain(
|
||||
device, surface,
|
||||
&(WGPUSwapChainDescriptor){
|
||||
.usage = WGPUTextureUsageFlags_OUTPUT_ATTACHMENT,
|
||||
.format = WGPUTextureFormat_Bgra8Unorm,
|
||||
.width = 640,
|
||||
.height = 480,
|
||||
});
|
||||
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
WGPUSwapChainOutput next_texture = wgpu_swap_chain_get_next_texture(swap_chain);
|
||||
WGPUCommandBufferDescriptor cmd_buf_desc = { .todo = 0 };
|
||||
WGPUCommandBufferId cmd_buf = wgpu_device_create_command_buffer(device, &cmd_buf_desc);
|
||||
WGPURenderPassColorAttachmentDescriptor_TextureViewId color_attachments[ATTACHMENTS_LENGTH] = {
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
WGPUSwapChainOutput next_texture =
|
||||
wgpu_swap_chain_get_next_texture(swap_chain);
|
||||
|
||||
WGPUCommandEncoderId cmd_encoder = wgpu_device_create_command_encoder(
|
||||
device, &(WGPUCommandEncoderDescriptor){.todo = 0});
|
||||
|
||||
WGPURenderPassColorAttachmentDescriptor_TextureViewId
|
||||
color_attachments[ATTACHMENTS_LENGTH] = {
|
||||
{
|
||||
.attachment = next_texture.view_id,
|
||||
.load_op = WGPULoadOp_Clear,
|
||||
@ -221,24 +198,27 @@ int main()
|
||||
.clear_color = WGPUColor_GREEN,
|
||||
},
|
||||
};
|
||||
WGPURenderPassDescriptor rpass_desc = {
|
||||
|
||||
WGPURenderPassId rpass = wgpu_command_encoder_begin_render_pass(
|
||||
cmd_encoder,
|
||||
(WGPURenderPassDescriptor){
|
||||
.color_attachments = color_attachments,
|
||||
.color_attachments_length = RENDER_PASS_ATTACHMENTS_LENGTH,
|
||||
.depth_stencil_attachment = NULL,
|
||||
};
|
||||
WGPURenderPassId rpass = wgpu_command_buffer_begin_render_pass(cmd_buf, rpass_desc);
|
||||
wgpu_render_pass_set_pipeline(rpass, render_pipeline);
|
||||
wgpu_render_pass_draw(rpass, 3, 1, 0, 0);
|
||||
wgpu_render_pass_end_pass(rpass);
|
||||
WGPUQueueId queue = wgpu_device_get_queue(device);
|
||||
wgpu_queue_submit(queue, &cmd_buf, 1);
|
||||
wgpu_swap_chain_present(swap_chain);
|
||||
});
|
||||
|
||||
glfwPollEvents();
|
||||
}
|
||||
wgpu_render_pass_set_pipeline(rpass, render_pipeline);
|
||||
wgpu_render_pass_draw(rpass, 3, 1, 0, 0);
|
||||
WGPUQueueId queue = wgpu_device_get_queue(device);
|
||||
WGPUCommandBufferId cmd_buf = wgpu_render_pass_end_pass(rpass);
|
||||
wgpu_queue_submit(queue, &cmd_buf, 1);
|
||||
wgpu_swap_chain_present(swap_chain);
|
||||
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
return 0;
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -240,7 +240,14 @@ typedef enum {
|
||||
|
||||
typedef struct WGPUBufferMapAsyncStatus WGPUBufferMapAsyncStatus;
|
||||
|
||||
typedef struct WGPUId WGPUId;
|
||||
typedef uint32_t WGPUIndex;
|
||||
|
||||
typedef uint32_t WGPUEpoch;
|
||||
|
||||
typedef struct {
|
||||
WGPUIndex _0;
|
||||
WGPUEpoch _1;
|
||||
} WGPUId;
|
||||
|
||||
typedef WGPUId WGPUDeviceId;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wgpu-native"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
authors = [
|
||||
"Dzmitry Malyshau <kvark@mozilla.com>",
|
||||
"Joshua Groves <josh@joshgroves.com>",
|
||||
|
@ -18,6 +18,8 @@ use std::sync::Arc;
|
||||
|
||||
pub(crate) type Index = u32;
|
||||
pub(crate) type Epoch = u32;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Id(Index, Epoch);
|
||||
|
@ -109,7 +109,11 @@ pub fn instance_create_surface_from_windows_hwnd(
|
||||
hinstance: *mut std::ffi::c_void,
|
||||
hwnd: *mut std::ffi::c_void,
|
||||
) -> SurfaceHandle {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[cfg(not(any(
|
||||
feature = "gfx-backend-dx11",
|
||||
feature = "gfx-backend-dx12",
|
||||
all(target_os = "windows", feature = "gfx-backend-vulkan"),
|
||||
)))]
|
||||
let raw = unimplemented!();
|
||||
|
||||
#[cfg(any(feature = "gfx-backend-dx11", feature = "gfx-backend-dx12"))]
|
||||
@ -118,7 +122,7 @@ pub fn instance_create_surface_from_windows_hwnd(
|
||||
#[cfg(all(target_os = "windows", feature = "gfx-backend-vulkan"))]
|
||||
let raw = HUB.instances.read()[instance_id].create_surface_from_hwnd(hinstance, hwnd);
|
||||
|
||||
#[cfg_attr(not(target_os = "windows"), allow(unreachable_code))]
|
||||
#[allow(unreachable_code)]
|
||||
SurfaceHandle::new(raw)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user