edgar-mtz-e / slimdx

Automatically exported from code.google.com/p/slimdx
0 stars 0 forks source link

Direct3D9::Device - Unable to set boolean shader constants #418

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
An exception is thrown whenever I attempt to set a boolean vertex or pixel 
shader constant using either:

Result Device::SetVertexShaderConstant( int startRegister, array<bool>^ 
data, int offset, int count )

or

Result Device::SetPixelShaderConstant( int startRegister, array<bool>^ 
data, int offset, int count )

I've attached the patch I made to direct3d9/Device.cpp, which just changes 
(in the above two functions):

        data->CopyTo( boolData, data->Length );

to

        for(int i = 0; i < data->Length; ++i)
        {
            boolData[i] = data[i] ? TRUE : FALSE;
        }

Original issue reported on code.google.com by corng...@gmail.com on 27 Jan 2009 at 4:08

GoogleCodeExporter commented 9 years ago
I don't think the patch file attached properly, here is the content:

995c995,1000
<       data->CopyTo( boolData, data->Length );
---
> 
>       for(int i = 0; i < data->Length; ++i)
>       {
>           boolData[i] = data[i] ? TRUE : FALSE;
>       }
> 
1034c1039,1044
<       data->CopyTo( boolData, data->Length );
---
> 
>       for(int i = 0; i < data->Length; ++i)
>       {
>           boolData[i] = data[i] ? TRUE : FALSE;
>       }
> 

Original comment by corng...@gmail.com on 27 Jan 2009 at 4:10

Attachments:

GoogleCodeExporter commented 9 years ago
Will fix, but I want to take some time to figure out why the existing code 
doesn't 
work.

Original comment by promit....@gmail.com on 30 Jan 2009 at 3:30

GoogleCodeExporter commented 9 years ago
CopyTo takes an offset, not a length for it's second argument.

I was also worried about using CopyTo from CLR bool to BOOL, but after looking 
at 
the docs, it seems like it might be ok to do that (as long as the types can be 
cast):

http://msdn.microsoft.com/en-us/library/06x742cw.aspx

Original comment by corng...@gmail.com on 21 Feb 2009 at 12:46

GoogleCodeExporter commented 9 years ago
Fixed.

Original comment by Mike.Popoloski on 27 Feb 2009 at 11:05