gerardorosiles / slimdx

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

SetResourceArray causes AccessViolationException on arrays with length greater than 1 #848

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
v2.0.50727
2.0.12.43

Using SetResourceArray to set an array of Texture2D seems to fail 
if the array length is greater than 1.  The error is AccessViolationException.

-------------------------------------------------------------------------------
EXAMPLE

using SlimDX;
using SlimDX.Direct3D10;
using SlimDX.DXGI;
using SlimDX.D3DCompiler;

// LOAD THE TEXTURES
Texture2D texture2D1 = Texture2D.FromFile("texture1.png");
Texture2D texture2D2 = Texture2D.FromFile("texture2.png");

// CREATE THE ARRAY
ShaderResourceView[] v = new ShaderResourceView[2];
v[0] = new ShaderResourceView(device,texture2D1);
v[1] = new ShaderResourceView(device,texture2D2);

// THE FOLLOWING TWO LINES FAIL
// effectTextureVariable.AsResource().SetResourceArray(propertyTextureView);
// effectTextureVariable.AsResource().SetResourceArray(propertyTextureView,0,2);

// THE FOLLOWING LINE SUCCEEDS (Setting just one item in the array)
effectTextureVariable.AsResource().SetResourceArray(propertyTextureView,0,1);

-------------------------------------------------------------------------------
// SHADER INPUT

Texture2DArray<float4>      textureArray;

Thanks for your help.
-dana

Original issue reported on code.google.com by danaball...@gmail.com on 15 Nov 2011 at 5:07

GoogleCodeExporter commented 9 years ago
EXAMPLE ABOVE - DID NOT EDIT EXAMPLE CORRECTLY - FOLLOWING CODE SHOWS FAILURE

using SlimDX;
using SlimDX.Direct3D10;
using SlimDX.DXGI;
using SlimDX.D3DCompiler;

// LOAD THE TEXTURES
Texture2D texture2D1 = Texture2D.FromFile("texture1.png");
Texture2D texture2D2 = Texture2D.FromFile("texture2.png");

// CREATE THE ARRAY
ShaderResourceView[] v = new ShaderResourceView[2];
v[0] = new ShaderResourceView(device,texture2D1);
v[1] = new ShaderResourceView(device,texture2D2);

// THE FOLLOWING TWO LINES FAIL
// effectTextureVariable.AsResource().SetResourceArray(v);
// effectTextureVariable.AsResource().SetResourceArray(v,0,2);

// THE FOLLOWING LINE SUCCEEDS (Setting just one item in the array)
effectTextureVariable.AsResource().SetResourceArray(v,0,1);

-------------------------------------------------------------------------------
// SHADER INPUT

Texture2DArray<float4>      textureArray;

Thanks for your help.
-dana

Original comment by danaball...@gmail.com on 15 Nov 2011 at 5:09

GoogleCodeExporter commented 9 years ago
Texture2DArray is a single texture that has an array inside of it. The 
SetResourceArray function is called for actual arrays, like this:

// hlsl
Texture2D textureArray[2];

Direct3D will crash if you try to set an array on a non-array type. There's not 
much we can do about that.

Original comment by Mike.Popoloski on 15 Nov 2011 at 6:55