Closed GoogleCodeExporter closed 9 years ago
You set the viewports, therefore you know how many you set. The native API
requires
you to pass the count as well:
http://msdn.microsoft.com/en-us/library/bb173610(VS.85).aspx
We abstract this away by using the count of the array you provide to the managed
wrapper. Offhand, I don't know if the native API can be used with a null second
parameter to retrieve the count, which would be required for doing this via an
out
parameter. However, it's not documented behavior so I'm wary on relying on it,
even
if it works.
I will look into it; but from a design perspective this would also need to
maintain
parity with the other getter methods that return arrays in the same interface,
and
that may not be viable.
Original comment by josh.petrie
on 6 Jul 2009 at 2:45
hmm...
1) we can't know the active viewports count every time.
I am developing a 3d library on slimdx. the application developer who use my
library may set the viewports and my library
doesn't track many direct3d methods. My library don't care viewports.
But In some point, a method in my library, stores the active viewports + set a
viewport for its use + does its work + restores
the stored viewports. This method doesn't know the active viewports count while
storing them.
2) as you know from the directx documantation :
NumViewports
[in, out] Number of viewports in pViewports.
I don't know the purpose of [in] but I think the purpose of [out] is to get the
active viewports count from the DX. it is absolutely will give the count and
slimdx can init the array which is defined as "out" parameter in GetViewports
method.
what do you think mate ? please share it.
Original comment by OnurER@gmail.com
on 6 Jul 2009 at 4:23
[deleted comment]
Calling RSGetViewports with zero as the initial count does cause it to fill the
count out with some value that is
probably the bound viewport count. However that behavior is not documented, and
until it is (or we know it will
be) we can't support it. Promit's looking into whether or not it is safe
behavior.
Original comment by josh.petrie
on 7 Jul 2009 at 3:02
you know, microsoft (or many API developer) generally implements Get and Set
methods with a pointer and a count parameters pair since there is no
real array in C++. a Get method DOES HAVE to give the count while giving the
Array pointer. Otherwise it would be useless :)
The error in the documentation is the [in] modifier of Count parameter of
GetViewports. There is no need and no scenario to pass a array count to
a get method. its purpose is to only [out] :)
Dear friend, I don't want to argue. just sharing my ideas :) hope you like it.
see you
Original comment by OnurER@gmail.com
on 7 Jul 2009 at 5:50
I verified that passing NULL for the second parameter is acceptable. Go forth!
Original comment by promit....@gmail.com
on 7 Jul 2009 at 2:54
I believe that native directx function (GetViewports) would ignore the current
value of second parameter when we
pass as not-null value and would override the old value with the new pointer
that is allocated by it self. This
results in a memory leak of memory array that is passed to GetViewports. I
don't think GetViewports would
deallocate or would use it to fill in, when we pass a not-null value.
The only use of second parameter must be [out] and always be passed [in] as
null.
does Verified mean that you will fix it ? hehe I am happy to convince you :)
Original comment by OnurER@gmail.com
on 7 Jul 2009 at 5:38
No, that's not how the API works at all. Read the documentation carefully; it
expects a preallocated array as input. If it worked the way you just said, it
would
take a D3D10_VIEWPORT**.
I believe jpetrie has a fix that will allow you to find out how many viewports
are
set.
Original comment by promit....@gmail.com
on 7 Jul 2009 at 5:48
It means he checked with people via his MVP status to confirm the counting
behavior
is intended -- without that kind of confirmation we can't implement things
based on
*undocumented* behavior.
RSGetViewports() does not allocate -- it writes into (count) elements of the
provided
viewport array. The array can only be null if the first parameter points to an
integer that is zero, in which case the function will write nothing to the
output
array and write the viewport count to the first parameter. Otherwise the
function
writes (count) elements to the viewport array and writes the viewport count to
the
first parameter.
An overload such as you are proprosing requires us to make an extra allocation,
so we
won't replace the existing GetOutputs() method, but rather add an additional
method
that uses an out parameter.
Original comment by josh.petrie
on 7 Jul 2009 at 5:50
This issue was closed by r1177.
Original comment by josh.petrie
on 8 Jul 2009 at 1:02
Thank you :)
Original comment by OnurER@gmail.com
on 8 Jul 2009 at 5:42
Original issue reported on code.google.com by
OnurER@gmail.com
on 5 Jul 2009 at 8:45