• Create Account

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1Telanor  Members

1486
Like
0Likes
Like

Posted 15 May 2012 - 02:17 AM

In c++ you can do the following to get the dimensions of a ShaderResourceView:

void foo(ID3D11ShaderResourceView* texture)
{
ID3D11Resource* resource;
ID3D11Texture2DPtr texResource;
D3D11_TEXTURE2D_DESC desc;
texture->GetResource(&resource);
texResource.Attach(reinterpret_cast<ID3D11Texture2D*>(resource));
texResource->GetDesc(&desc);
perBatch.TextureSize = XMFLOAT2(static_cast<float>(desc.Width), static_cast<float>(desc.Height));
}


I'm trying to accomplish the same thing in SlimDX but I can't seem to figure out how. The logical way seems to be texture.Resource.Description.Width but the Direct3D11.Resource class doesn't have a Description property. Anyone know how to do this in SlimDX?

### #2Washu  Senior Moderators

7714
Like
0Likes
Like

Posted 15 May 2012 - 02:23 AM

The descriptions are strongly typed. As such you will find them under the derived type from Resource... i.e. Texture2D.Description

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX

### #3Telanor  Members

1486
Like
0Likes
Like

Posted 15 May 2012 - 02:38 AM

So I do something like this?

var resource = (Texture2D)texture.Resource;
perBatch.TextureSize = new Vector2(resource.Description.Width, resource.Description.Height);


### #4Washu  Senior Moderators

7714
Like
0Likes
Like

Posted 15 May 2012 - 02:00 PM

I don't think that will work (it might, but doubtful)...

var resource = new Texture2D.FromPointer(texture.Resource.ComPointer);

should work, just remember to dispose of it when done, probably. depending on if you hold a handle to the texture in the resource view or not. (If you do, don't dispose, if you don't, do dispose).

Edited by Washu, 15 May 2012 - 02:05 PM.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX

### #5Mike.Popoloski  Members

3249
Like
0Likes
Like

Posted 15 May 2012 - 02:30 PM

Casting will work just fine. There's no need to use the FromPointer method, which is intended only for interop with external libraries.
Mike Popoloski | Journal | SlimDX

### #6Telanor  Members

1486
Like
0Likes
Like

Posted 15 May 2012 - 03:30 PM

Alright, thanks. I'd test it but I'm still in the process of converting from XNA to slimdx so I can't yet.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.