Skip to content

Commit

Permalink
Add a helper to align texture strides
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Sep 24, 2024
1 parent 7339386 commit 9900cae
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "d3d12unit.h"

#include <kope/graphics5/device.h>
#include <kope/util/align.h>

#include <kinc/backend/SystemMicrosoft.h>
#include <kinc/backend/Windows.h>
Expand Down Expand Up @@ -727,3 +728,7 @@ void kope_d3d12_device_create_raytracing_hierarchy(kope_g5_device *device, kope_
as_params.usage_flags = KOPE_G5_BUFFER_USAGE_READ_WRITE | KOPE_G5_BUFFER_USAGE_RAYTRACING_VOLUME;
kope_g5_device_create_buffer(device, &as_params, &hierarchy->d3d12.acceleration_structure);
}

uint32_t kope_d3d12_device_align_texture_row_bytes(kope_g5_device *device, uint32_t row_bytes) {
return (uint32_t)align_pow2((int)row_bytes, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void kope_d3d12_device_create_raytracing_volume(kope_g5_device *device, kope_g5_
void kope_d3d12_device_create_raytracing_hierarchy(kope_g5_device *device, kope_g5_raytracing_volume **volumes, kinc_matrix4x4_t *volume_transforms,
uint32_t volumes_count, kope_g5_raytracing_hierarchy *hierarchy);

uint32_t kope_d3d12_device_align_texture_row_bytes(kope_g5_device *device, uint32_t row_bytes);

#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 5 additions & 1 deletion Sources/kope/graphics5/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ void kope_g5_device_create_raytracing_hierarchy(kope_g5_device *device, kope_g5_

void kope_g5_device_wait_until_idle(kope_g5_device *device) {
KOPE_G5_CALL1(device_wait_until_idle, device);
}
}

uint32_t kope_g5_device_align_texture_row_bytes(kope_g5_device *device, uint32_t row_bytes) {
return KOPE_G5_CALL2(device_align_texture_row_bytes, device, row_bytes);
}
2 changes: 2 additions & 0 deletions Sources/kope/graphics5/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ KOPE_FUNC void kope_g5_device_create_raytracing_volume(kope_g5_device *device, k
KOPE_FUNC void kope_g5_device_create_raytracing_hierarchy(kope_g5_device *device, kope_g5_raytracing_volume **volumes, kinc_matrix4x4_t *volume_transforms,
uint32_t volumes_count, kope_g5_raytracing_hierarchy *hierarchy);

KOPE_FUNC uint32_t kope_g5_device_align_texture_row_bytes(kope_g5_device *device, uint32_t row_bytes);

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 9900cae

Please sign in to comment.