mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
Merge #14
14: Begin and finish command buffers r=grovesNL a=kvark Co-authored-by: Dzmitry Malyshau <kvark@mozilla.com>
This commit is contained in:
commit
3c905fd706
@ -1,6 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include "./../../wgpu-bindings/wgpu.h"
|
||||
|
||||
#define STAGES_LENGTH (2)
|
||||
#define BLEND_STATE_LENGTH (1)
|
||||
#define FORMATS_LENGTH (1)
|
||||
|
||||
WGPUByteArray read_file(const char *name)
|
||||
{
|
||||
FILE *file = fopen(name, "rb");
|
||||
@ -63,7 +67,6 @@ int main()
|
||||
.entry_point = "main",
|
||||
};
|
||||
|
||||
const unsigned int STAGES_LENGTH = 2;
|
||||
WGPUPipelineStageDescriptor stages[STAGES_LENGTH] = { vertex_stage, fragment_stage };
|
||||
|
||||
WGPUBlendDescriptor blend_alpha = {
|
||||
@ -83,7 +86,6 @@ int main()
|
||||
.write_mask = 0,
|
||||
};
|
||||
WGPUBlendStateId blend_state_0 = wgpu_device_create_blend_state(device, blend_state_0_desc);
|
||||
const unsigned int BLEND_STATE_LENGTH = 1;
|
||||
WGPUBlendStateId blend_state[BLEND_STATE_LENGTH] = { blend_state_0 };
|
||||
|
||||
WGPUStencilStateFaceDescriptor stencil_state_front = {
|
||||
@ -108,7 +110,6 @@ int main()
|
||||
};
|
||||
WGPUDepthStencilStateId depth_stencil_state = wgpu_device_create_depth_stencil_state(device, depth_stencil_state_desc);
|
||||
|
||||
const unsigned int FORMATS_LENGTH = 1;
|
||||
WGPUTextureFormat formats[FORMATS_LENGTH] = { WGPUTextureFormat_R8g8b8a8Unorm };
|
||||
WGPUAttachmentStateDescriptor attachment_state_desc = {
|
||||
.formats = formats,
|
||||
@ -132,7 +133,7 @@ int main()
|
||||
WGPUCommandBufferDescriptor cmd_buf_desc = { };
|
||||
WGPUCommandBufferId cmd_buf = wgpu_device_create_command_buffer(device, cmd_buf_desc);
|
||||
WGPUQueueId queue = wgpu_device_get_queue(device);
|
||||
/*wgpu_queue_submit(queue, &cmd_buf, 1);*/
|
||||
wgpu_queue_submit(queue, &cmd_buf, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define WGPU_REMOTE 1
|
||||
#ifdef WGPU_REMOTE
|
||||
typedef uint32_t WGPUId;
|
||||
#else
|
||||
typedef void *WGPUId;
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define WGPUColorWriteFlags_ALL 15
|
||||
|
||||
#define WGPUColorWriteFlags_ALPHA 8
|
||||
|
@ -1,3 +1,4 @@
|
||||
use hal::command::RawCommandBuffer;
|
||||
use hal::queue::RawCommandQueue;
|
||||
use hal::{self, Device as _Device};
|
||||
use {back, binding_model, command, conv, memory, pipeline};
|
||||
@ -130,7 +131,11 @@ pub extern "C" fn wgpu_device_create_command_buffer(
|
||||
) -> CommandBufferId {
|
||||
let mut device_guard = registry::DEVICE_REGISTRY.lock();
|
||||
let device = device_guard.get_mut(device_id);
|
||||
let cmd_buf = device.com_allocator.allocate(&device.device);
|
||||
let mut cmd_buf = device.com_allocator.allocate(&device.device);
|
||||
cmd_buf.raw.begin(
|
||||
hal::command::CommandBufferFlags::ONE_TIME_SUBMIT,
|
||||
hal::command::CommandBufferInheritanceInfo::default(),
|
||||
);
|
||||
registry::COMMAND_BUFFER_REGISTRY.lock().register(cmd_buf)
|
||||
}
|
||||
|
||||
@ -152,7 +157,8 @@ pub extern "C" fn wgpu_queue_submit(
|
||||
//TODO: submit at once, requires `get_all()`
|
||||
let mut command_buffer_guard = registry::COMMAND_BUFFER_REGISTRY.lock();
|
||||
for &cmb_id in command_buffer_ids {
|
||||
let cmd_buf = command_buffer_guard.take(cmb_id);
|
||||
let mut cmd_buf = command_buffer_guard.take(cmb_id);
|
||||
cmd_buf.raw.finish();
|
||||
{
|
||||
let submission = hal::queue::RawSubmission {
|
||||
cmd_buffers: iter::once(&cmd_buf.raw),
|
||||
@ -220,10 +226,6 @@ pub extern "C" fn wgpu_device_create_render_pipeline(
|
||||
let mut vertex = None;
|
||||
let mut fragment = None;
|
||||
for pipeline_stage in pipeline_stages.iter() {
|
||||
let entry_name = unsafe { ffi::CStr::from_ptr(pipeline_stage.entry_point) }
|
||||
.to_str()
|
||||
.to_owned()
|
||||
.unwrap();
|
||||
let entry = hal::pso::EntryPoint::<back::Backend> {
|
||||
entry: unsafe { ffi::CStr::from_ptr(pipeline_stage.entry_point) }
|
||||
.to_str()
|
||||
|
Loading…
Reference in New Issue
Block a user