diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp index 15fcefeb7..f7bbb1f91 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp @@ -3,6 +3,7 @@ #include "d3d12unit.h" #include +#include #include #include @@ -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); +} diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device_functions.h b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device_functions.h index eb10edd07..ccb5e731f 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device_functions.h +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device_functions.h @@ -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 diff --git a/Sources/kope/graphics5/device.c b/Sources/kope/graphics5/device.c index c4198b9a5..811639ff6 100644 --- a/Sources/kope/graphics5/device.c +++ b/Sources/kope/graphics5/device.c @@ -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); -} \ No newline at end of file +} + +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); +} diff --git a/Sources/kope/graphics5/device.h b/Sources/kope/graphics5/device.h index a6bc6965c..efeb395fa 100644 --- a/Sources/kope/graphics5/device.h +++ b/Sources/kope/graphics5/device.h @@ -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