@@ -3,6 +3,21 @@ use anyhow::{Context, Result, bail};
33use ash:: vk;
44use std:: ffi:: { CStr , CString } ;
55
6+ /// Configuration for the Ash backend
7+ #[ derive( Clone ) ]
8+ pub struct AshConfig {
9+ /// Maximum number of descriptor sets
10+ pub max_descriptor_sets : u32 ,
11+ }
12+
13+ impl Default for AshConfig {
14+ fn default ( ) -> Self {
15+ Self {
16+ max_descriptor_sets : 16 ,
17+ }
18+ }
19+ }
20+
621pub struct AshBackend {
722 instance : ash:: Instance ,
823 device : ash:: Device ,
@@ -90,8 +105,8 @@ impl AshBackend {
90105 }
91106}
92107
93- impl ComputeBackend for AshBackend {
94- fn init ( ) -> Result < Self > {
108+ impl AshBackend {
109+ pub fn new ( config : AshConfig ) -> Result < Self > {
95110 unsafe {
96111 let entry = ash:: Entry :: load ( ) . context ( "Failed to load Vulkan entry" ) ?;
97112
@@ -174,7 +189,7 @@ impl ComputeBackend for AshBackend {
174189
175190 let descriptor_pool_create_info = vk:: DescriptorPoolCreateInfo :: default ( )
176191 . pool_sizes ( & descriptor_pool_sizes)
177- . max_sets ( 16 ) ;
192+ . max_sets ( config . max_descriptor_sets ) ;
178193
179194 let descriptor_pool = device
180195 . create_descriptor_pool ( & descriptor_pool_create_info, None )
@@ -191,7 +206,15 @@ impl ComputeBackend for AshBackend {
191206 } )
192207 }
193208 }
209+ }
210+
211+ impl Default for AshBackend {
212+ fn default ( ) -> Self {
213+ Self :: new ( AshConfig :: default ( ) ) . expect ( "Failed to create AshBackend with default config" )
214+ }
215+ }
194216
217+ impl ComputeBackend for AshBackend {
195218 fn run_compute (
196219 & self ,
197220 spirv_bytes : & [ u8 ] ,
0 commit comments