Skip to content

Commit 6f1882d

Browse files
committed
Start simplifying gfx resource requests
1 parent 527b2ba commit 6f1882d

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

toybox-gfx/src/resource_manager/image/create_image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl CreateImageRequest {
4141
levels: 1,
4242
samples: 1,
4343
},
44-
44+
4545
resize_policy: ImageResizePolicy::Fixed,
4646
clear_policy: ImageClearPolicy::Never,
4747
label: label.into(),

toybox-gfx/src/resource_manager/image/load_image.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,17 @@ impl ResourceRequest for LoadImageArrayRequest {
4747
fn register(self, rm: &mut ResourceManager) -> ImageHandle {
4848
rm.load_image_array_requests.request_handle(&mut rm.images, self)
4949
}
50+
}
51+
52+
53+
impl ResourceManager {
54+
pub fn load_image(&mut self, path: impl Into<PathBuf>) -> ImageHandle {
55+
self.request(LoadImageRequest::from(path))
56+
}
57+
58+
pub fn load_image_array<P>(&mut self, label: impl Into<String>, paths: impl IntoIterator<Item=P>) -> ImageHandle
59+
where P: Into<PathBuf>
60+
{
61+
self.request(LoadImageArrayRequest::from(label, paths))
62+
}
5063
}

toybox-gfx/src/resource_manager/shader/compile_shader_request.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,19 @@ impl ResourceRequest for CompileShaderRequest {
4242
fn register(self, rm: &mut ResourceManager) -> ShaderHandle {
4343
rm.compile_shader_requests.request_handle(&mut rm.shaders, self)
4444
}
45+
}
46+
47+
48+
impl ResourceManager {
49+
pub fn compile_vertex_shader(&mut self, label: impl Into<String>, src: impl Into<String>) -> ShaderHandle {
50+
self.request(CompileShaderRequest::vertex(label, src))
51+
}
52+
53+
pub fn compile_fragment_shader(&mut self, label: impl Into<String>, src: impl Into<String>) -> ShaderHandle {
54+
self.request(CompileShaderRequest::fragment(label, src))
55+
}
56+
57+
pub fn compile_compute_shader(&mut self, label: impl Into<String>, src: impl Into<String>) -> ShaderHandle {
58+
self.request(CompileShaderRequest::compute(label, src))
59+
}
4560
}

toybox-gfx/src/resource_manager/shader/load_shader_request.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,18 @@ impl ResourceRequest for LoadShaderRequest {
6565
fn register(self, rm: &mut ResourceManager) -> ShaderHandle {
6666
rm.load_shader_requests.request_handle(&mut rm.shaders, self)
6767
}
68+
}
69+
70+
impl ResourceManager {
71+
pub fn load_vertex_shader(&mut self, path: impl Into<PathBuf>) -> ShaderHandle {
72+
self.request(LoadShaderRequest::vertex(path))
73+
}
74+
75+
pub fn load_fragment_shader(&mut self, path: impl Into<PathBuf>) -> ShaderHandle {
76+
self.request(LoadShaderRequest::fragment(path))
77+
}
78+
79+
pub fn load_compute_shader(&mut self, path: impl Into<PathBuf>) -> ShaderHandle {
80+
self.request(LoadShaderRequest::compute(path))
81+
}
6882
}

0 commit comments

Comments
 (0)