You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ID3D12GraphicsCommandList1::ClearRenderTargetView - array params could possibly be projected better #790
I'm not sure what the best rust projection would be here - and I don't think that win32metadata has everything needed yet, but I figured we should figure out what can be possible in rust first.
Ideally, I'd be able to specify the color inline. Maybe that's possible? This is what I came up with:
let clear_color:[f32;4] = [0.0,0.2,0.4,1.0];
command_list.ClearRenderTargetView(rtv_handle,&clear_color[0],0, std::ptr::null());
It's a bit clunky having to take a reference to the first element of the array.
For pRects, I notice that the rust binding isn't make any use of the relationship between prects and numrects. Maybe there's not anything it could do with it, but I thought I'd mention it while I was here.
For pRects, I notice that the rust binding isn't make any use of the relationship between prects and numrects. Maybe there's not anything it could do with it, but I thought I'd mention it while I was here.
Ideally, that annotation would let you pass a rust slice to the prects parameter.
Something like:
let clear_color:[f32;4] = [0.0,0.2,0.4,1.0];let rects:[RECT; _] = [RECT{/*...*/},RECT{/*...*/}];// or Vec<RECT> and vec![...]
command_list.ClearRenderTargetView(rtv_handle,&clear_color,&rects[..]);
I reckon colorrgba could be projected as a simple static-sized array pointer: colorrgba: *const [f32; 4]? That way you can pass &clear_color from the let clear_color: [f32; 4] example above or &[0.0, 0.2, 0.4, 1.0] directly in-line.
Pointers to static-sized arrays - unlike slices - are (expectably so) not fat pointers:
Activity
samlh commentedon May 11, 2021
Ideally, that annotation would let you pass a rust slice to the prects parameter.
Something like:
kennykerr commentedon May 11, 2021
Yes, I still have a ways to go to make the most of the array metadata.
MarijnS95 commentedon May 11, 2021
I reckon
colorrgbacould be projected as a simple static-sized array pointer:colorrgba: *const [f32; 4]? That way you can pass&clear_colorfrom thelet clear_color: [f32; 4]example above or&[0.0, 0.2, 0.4, 1.0]directly in-line.Pointers to static-sized arrays - unlike slices - are (expectably so) not fat pointers:
EDIT: Suggested in the DX12 review to use
clear_color.as_ptr()instead of&clear_color[0]👍damyanp commentedon Jun 16, 2021
Similar issue for ExecuteCommandLists:
(mentioning it here so that it shows up in searchs)
kennykerr commentedon Feb 23, 2022
Sorry for the delay, #1562 adds support for Win32 array parameters and fixes this issue.