aboutsummaryrefslogtreecommitdiffstats
path: root/components/webgpu/lib.rs
diff options
context:
space:
mode:
authorbors-servo <servo-ops@mozilla.com>2020-06-01 20:53:20 -0400
committerGitHub <noreply@github.com>2020-06-01 20:53:20 -0400
commit2b24cfed10e01d91dd44a1015cc553a0fc09bbab (patch)
tree558306e4c353131ae6129b357b29cffc9e75c1f6 /components/webgpu/lib.rs
parentc30fcd94e69fde76bc0315eae5652a93dbd9f1ec (diff)
parentaf95d922315974dcfae5659b503a672b19026fdb (diff)
downloadservo-2b24cfed10e01d91dd44a1015cc553a0fc09bbab.tar.gz
servo-2b24cfed10e01d91dd44a1015cc553a0fc09bbab.zip
Auto merge of #26742 - kunalmohan:gpu-texture, r=kvark
Implement GPUTexture and GPUTextureView <!-- Please describe your changes on the following line: --> This also include changes to CodegenRust.py to allow enum values starting with digits. r?@kvark --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/webgpu/lib.rs')
-rw-r--r--components/webgpu/lib.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/components/webgpu/lib.rs b/components/webgpu/lib.rs
index c385a20c2de..884bf0ddfa5 100644
--- a/components/webgpu/lib.rs
+++ b/components/webgpu/lib.rs
@@ -127,7 +127,18 @@ pub enum WebGPURequest {
program_id: id::ShaderModuleId,
program: Vec<u32>,
},
+ CreateTexture {
+ device_id: id::DeviceId,
+ texture_id: id::TextureId,
+ descriptor: wgt::TextureDescriptor<String>,
+ },
+ CreateTextureView {
+ texture_id: id::TextureId,
+ texture_view_id: id::TextureViewId,
+ descriptor: wgt::TextureViewDescriptor<String>,
+ },
DestroyBuffer(id::BufferId),
+ DestroyTexture(id::TextureId),
Exit(IpcSender<()>),
RequestAdapter {
sender: IpcSender<WebGPUResponseResult>,
@@ -457,10 +468,37 @@ impl WGPU {
let _ = gfx_select!(program_id =>
global.device_create_shader_module(device_id, &descriptor, program_id));
},
+ WebGPURequest::CreateTexture {
+ device_id,
+ texture_id,
+ descriptor,
+ } => {
+ let global = &self.global;
+ let st = CString::new(descriptor.label.as_bytes()).unwrap();
+ let _ = gfx_select!(texture_id =>
+ global.device_create_texture(device_id, &descriptor.map_label(|_| st.as_ptr()), texture_id));
+ },
+ WebGPURequest::CreateTextureView {
+ texture_id,
+ texture_view_id,
+ descriptor,
+ } => {
+ let global = &self.global;
+ let st = CString::new(descriptor.label.as_bytes()).unwrap();
+ let _ = gfx_select!(texture_view_id => global.texture_create_view(
+ texture_id,
+ Some(&descriptor.map_label(|_| st.as_ptr())),
+ texture_view_id
+ ));
+ },
WebGPURequest::DestroyBuffer(buffer) => {
let global = &self.global;
gfx_select!(buffer => global.buffer_destroy(buffer));
},
+ WebGPURequest::DestroyTexture(texture) => {
+ let global = &self.global;
+ gfx_select!(texture => global.texture_destroy(texture));
+ },
WebGPURequest::Exit(sender) => {
if let Err(e) = self.script_sender.send(WebGPUMsg::Exit) {
warn!("Failed to send WebGPUMsg::Exit to script ({})", e);
@@ -605,3 +643,5 @@ webgpu_resource!(WebGPUQueue, id::QueueId);
webgpu_resource!(WebGPURenderPipeline, id::RenderPipelineId);
webgpu_resource!(WebGPUSampler, id::SamplerId);
webgpu_resource!(WebGPUShaderModule, id::ShaderModuleId);
+webgpu_resource!(WebGPUTexture, id::TextureId);
+webgpu_resource!(WebGPUTextureView, id::TextureViewId);