Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

[ToolKit.Graphics] Multisampled BackBuffer's TextureView size are wrong #425

Closed
AvengerDr opened this issue Jun 28, 2014 · 4 comments
Closed
Labels

Comments

@AvengerDr
Copy link
Contributor

Hi all,
today I was experimenting with a multisampling. I found out that the TextureView object in its Tag property has the wrong width and height. If AutoViewport is set to true, when you set the RenderTarget in the beginning it will create a viewport of size 1,1 (or whatever value is in memory).

The problem lies in the TextureView's Initialization method. On the line:
Size = new Size2(Math.Max(1, Texture.Width >> mipLevel), Math.Max(1, Texture.Height >> mipLevel));

On a multisampled texture the "mipLevel" value is not 0 but some random number, thus the resulting TextureView object does not have the correct size. These wrong mipLevel values seem to come directly from the RenderTargetView object in rtv = new TextureView(this, new RenderTargetView(Device, Resource, rtvDescription)); in RenderTarget2D.GetRenderTargetView
after the creation of that DX object, those values are all wrong.

The problem does not seem to occur on a MultiSampleCount of 1,0.

@jwollen
Copy link
Contributor

jwollen commented Jun 29, 2014

This seems to be due to the resource description not being zeroed, when read back from the API.
I added a fix in pull request #423 as this is relevant there, too.
If you like, check out my branch and see if this resolves the issue.

@ArtiomCiumac
Copy link
Contributor

The pull request has been merged. @AvengerDr, can you please confirm if it resolves this issue?

@AvengerDr
Copy link
Contributor Author

@ArtiomCiumac @jwollen Yes it does work fine now, thanks! Though I'm wondering whether there's something wrong in the DirectX object since the number assigned to MipLevel looks like uninitialized memory.

@jwollen
Copy link
Contributor

jwollen commented Jun 30, 2014

It is uninitialized. It's part of a union of structs and the valid data depends on the type of texture, so some memory might remain unused. For texture arrays it contains FirstArraySlice and ArraySize. For textures supporting mipmapping there's also MipLevel, etc. Multisampled textures can't have mipmaps, so they don't have that field.

The code reads the MipLevel as if the texture were 1D, since that field is in the same memory location for other textures as well. Except when it's not there at all, which caused this bug :)
For more information see MSDN.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants