Skip to content

Commit 0fca9fa

Browse files
committed
update rpp
1 parent b3fcb8d commit 0fca9fa

File tree

9 files changed

+34
-32
lines changed

9 files changed

+34
-32
lines changed

rvk/acceleration.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ Opt<TLAS::Staged> TLAS::make(Arc<Device_Memory, Alloc> memory, Buffer instances,
6767
Opt<Buffer> structure_buf =
6868
memory->make(build_sizes.accelerationStructureSize,
6969
VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR);
70-
if(!structure_buf) return {};
70+
if(!structure_buf.ok()) return {};
7171

7272
Opt<Buffer> scratch =
7373
memory->make(build_sizes.buildScratchSize, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT |
7474
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
75-
if(!scratch) return {};
75+
if(!scratch.ok()) return {};
7676

7777
return Opt<Staged>{Staged{move(*structure_buf), move(*scratch), move(instances), n_instances,
7878
build_sizes.accelerationStructureSize, move(memory)}};
@@ -188,7 +188,7 @@ Opt<BLAS::Staged> BLAS::make(Arc<Device_Memory, Alloc> memory, Buffer data,
188188
for(auto& offset : offsets) {
189189
geom.geometry.triangles.vertexData.deviceAddress = base_data + offset.vertex;
190190
geom.geometry.triangles.indexData.deviceAddress = base_data + offset.index;
191-
if(offset.transform) {
191+
if(offset.transform.ok()) {
192192
geom.geometry.triangles.transformData.deviceAddress = base_data + *offset.transform;
193193
} else {
194194
geom.geometry.triangles.transformData.deviceAddress = 0;
@@ -220,12 +220,12 @@ Opt<BLAS::Staged> BLAS::make(Arc<Device_Memory, Alloc> memory, Buffer data,
220220
Opt<Buffer> structure_buf =
221221
memory->make(build_sizes.accelerationStructureSize,
222222
VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR);
223-
if(!structure_buf) return {};
223+
if(!structure_buf.ok()) return {};
224224

225225
Opt<Buffer> scratch =
226226
memory->make(build_sizes.buildScratchSize, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT |
227227
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
228-
if(!scratch) return {};
228+
if(!scratch.ok()) return {};
229229

230230
return Opt{Staged{move(*structure_buf), move(*scratch), move(data),
231231
build_sizes.accelerationStructureSize, move(offsets), move(memory)}};
@@ -272,7 +272,7 @@ BLAS BLAS::build(Commands& cmds, Staged buffers) {
272272
for(auto& offset : buffers.offsets) {
273273
geom.geometry.triangles.vertexData.deviceAddress = base_data + offset.vertex;
274274
geom.geometry.triangles.indexData.deviceAddress = base_data + offset.index;
275-
if(offset.transform) {
275+
if(offset.transform.ok()) {
276276
geom.geometry.triangles.transformData.deviceAddress = base_data + *offset.transform;
277277
}
278278
geom.geometry.triangles.maxVertex = static_cast<u32>(offset.n_vertices);

rvk/commands.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ Command_Pool_Manager<F>::~Command_Pool_Manager() {
228228
template<Queue_Family F>
229229
void Command_Pool_Manager<F>::begin_thread() {
230230

231-
assert(!this_thread.pool);
231+
assert(!this_thread.pool.ok());
232232

233233
Thread::Id id = Thread::this_id();
234234
Thread::Lock lock(mutex);
@@ -267,9 +267,9 @@ void Command_Pool_Manager<F>::begin_thread() {
267267
template<Queue_Family F>
268268
void Command_Pool_Manager<F>::end_thread() {
269269

270-
if(!this_thread.pool) return;
270+
if(!this_thread.pool.ok()) return;
271271

272-
assert(this_thread.pool_manager == Ref{*this});
272+
assert(&*this_thread.pool_manager == this);
273273

274274
Thread::Id id = Thread::this_id();
275275
Thread::Lock lock(mutex);
@@ -285,7 +285,7 @@ void Command_Pool_Manager<F>::end_thread() {
285285

286286
template<Queue_Family F>
287287
Commands Command_Pool_Manager<F>::make() {
288-
if(!this_thread.pool) begin_thread();
288+
if(!this_thread.pool.ok()) begin_thread();
289289
return this_thread.pool->make();
290290
}
291291

rvk/commands.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ struct Command_Pool_Manager {
160160

161161
struct This_Thread {
162162
~This_Thread() {
163-
if(pool_manager) pool_manager->end_thread();
163+
if(pool_manager.ok()) pool_manager->end_thread();
164164
}
165165
Arc<Command_Pool, Alloc> pool;
166166
Ref<Command_Pool_Manager> pool_manager;

rvk/device.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,13 @@ Device::Device(Arc<Physical_Device, Alloc> P, VkSurfaceKHR surface, bool ray_tra
353353
}
354354

355355
{ // Find queue families
356-
if(auto idx = physical_device->queue_index(Queue_Family::graphics)) {
356+
if(auto idx = physical_device->queue_index(Queue_Family::graphics); idx.ok()) {
357357
graphics_family_index = *idx;
358358
} else {
359359
die("[rvk] No graphics queue family found.");
360360
}
361361

362-
if(auto idx = physical_device->present_queue_index(surface)) {
362+
if(auto idx = physical_device->present_queue_index(surface); idx.ok()) {
363363
present_family_index = *idx;
364364
} else {
365365
die("[rvk] No present queue family found.");
@@ -508,8 +508,9 @@ Device::Device(Arc<Physical_Device, Alloc> P, VkSurfaceKHR surface, bool ray_tra
508508
// Find heaps
509509

510510
{
511-
if(auto idx = physical_device->heap_index(RPP_UINT32_MAX,
512-
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) {
511+
if(auto idx =
512+
physical_device->heap_index(RPP_UINT32_MAX, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
513+
idx.ok()) {
513514
device_memory_index = *idx;
514515
} else {
515516
die("[rvk] No device local heap found.");
@@ -518,7 +519,8 @@ Device::Device(Arc<Physical_Device, Alloc> P, VkSurfaceKHR surface, bool ray_tra
518519
if(auto idx = physical_device->heap_index(RPP_UINT32_MAX,
519520
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
520521
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
521-
VK_MEMORY_PROPERTY_HOST_CACHED_BIT)) {
522+
VK_MEMORY_PROPERTY_HOST_CACHED_BIT);
523+
idx.ok()) {
522524
host_memory_index = *idx;
523525
} else {
524526
die("[rvk] No host visible heap found.");

rvk/instance.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,13 @@ Arc<Physical_Device, Alloc> Instance::physical_device(VkSurfaceKHR surface, bool
260260
}
261261

262262
auto graphics_queue = device->queue_index(Queue_Family::graphics);
263-
if(!graphics_queue) {
263+
if(!graphics_queue.ok()) {
264264
info("[rvk] Device has no graphics queue family!");
265265
continue;
266266
}
267267

268268
auto present_queue = device->present_queue_index(surface);
269-
if(!present_queue) {
269+
if(!present_queue.ok()) {
270270
info("[rvk] Device has no compatible present queue family!");
271271
continue;
272272
}
@@ -316,14 +316,14 @@ Arc<Physical_Device, Alloc> Instance::physical_device(VkSurfaceKHR surface, bool
316316
}
317317
}
318318

319-
if(!discrete_idx) {
319+
if(!discrete_idx.ok()) {
320320
info("[rvk] No discrete GPU found, selecting first compatible device.");
321321
} else {
322322
info("[rvk] Found discrete GPU: %.",
323323
compatible_devices[*discrete_idx]->properties().name());
324324
}
325325

326-
u32 idx = discrete_idx ? *discrete_idx : 0;
326+
u32 idx = discrete_idx.ok() ? *discrete_idx : 0;
327327
info("[rvk] Selected device: %.", compatible_devices[idx]->properties().name());
328328

329329
return move(compatible_devices.front());

rvk/memory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Opt<Image> Device_Memory::make(VkExtent3D extent, VkFormat format, VkImageUsageF
107107
memory_requirements.memoryRequirements.size,
108108
Math::max(memory_requirements.memoryRequirements.alignment, buffer_image_granularity));
109109

110-
if(!address) {
110+
if(!address.ok()) {
111111
vkDestroyImage(*device, image, null);
112112
return {};
113113
}
@@ -148,7 +148,7 @@ Opt<Buffer> Device_Memory::make(u64 size, VkBufferUsageFlags usage) {
148148
auto address =
149149
allocator.allocate(memory_requirements.size,
150150
Math::max(memory_requirements.alignment, buffer_image_granularity));
151-
if(!address) {
151+
if(!address.ok()) {
152152
vkDestroyBuffer(*device, buffer, null);
153153
return {};
154154
}

rvk/rvk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ Arc<Device, Alloc> get_device() {
456456
} // namespace impl
457457

458458
bool startup(Config config) {
459-
if(impl::singleton) {
459+
if(impl::singleton.ok()) {
460460
die("[rvk] Already started up!");
461461
}
462462
Profile::Time_Point start = Profile::timestamp();

rvk/shader_loader.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
namespace rvk {
77

88
impl::Shader& Shader_Loader::get(Token token) {
9-
assert(device);
9+
assert(device.ok());
1010
return shaders.get(token).first;
1111
}
1212

1313
Shader_Loader::Token Shader_Loader::compile(String_View path) {
14-
assert(device);
14+
assert(device.ok());
1515

16-
if(Opt<Vec<u8, Files::Alloc>> data = Files::read(path)) {
16+
if(auto data = Files::read(path); data.ok()) {
1717

1818
Shader shader{device.dup(), data->slice()};
1919
Files::Write_Watcher watcher{path};
@@ -32,9 +32,9 @@ Shader_Loader::Token Shader_Loader::compile(String_View path) {
3232

3333
Async::Task<Shader_Loader::Token> Shader_Loader::compile_async(Async::Pool<>& pool,
3434
String_View path) {
35-
assert(device);
35+
assert(device.ok());
3636

37-
if(Opt<Vec<u8, Files::Alloc>> data = co_await Async::read(pool, path)) {
37+
if(auto data = co_await Async::read(pool, path); data.ok()) {
3838

3939
// Will compile on another thread
4040
Shader shader{device.dup(), data->slice()};
@@ -53,7 +53,7 @@ Async::Task<Shader_Loader::Token> Shader_Loader::compile_async(Async::Pool<>& po
5353
}
5454

5555
void Shader_Loader::try_reload() {
56-
assert(device);
56+
assert(device.ok());
5757

5858
Thread::Lock lock{mutex};
5959

@@ -67,7 +67,7 @@ void Shader_Loader::try_reload() {
6767
data = shader.second.read();
6868
shader.first = Shader{device.dup(), data->slice()};
6969
callbacks_to_run.insert(reloads.get(token), {});
70-
} while(!data);
70+
} while(!data.ok());
7171
}
7272
}
7373

@@ -80,7 +80,7 @@ void Shader_Loader::try_reload() {
8080

8181
void Shader_Loader::on_reload(Slice<Shader_Loader::Token> tokens,
8282
FunctionN<16, void(Shader_Loader&)> callback) {
83-
assert(device);
83+
assert(device.ok());
8484

8585
Thread::Lock lock{mutex};
8686

0 commit comments

Comments
 (0)