Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SamplerState caching #412

Open
theranix opened this issue Feb 14, 2023 · 3 comments
Open

SamplerState caching #412

theranix opened this issue Feb 14, 2023 · 3 comments
Labels

Comments

@theranix
Copy link

theranix commented Feb 14, 2023

When there are defined properties (MaxMipLevel, MipMapLevelOfDetailBias etc.) in shader, them also are applied to all other samplers if they haven't defined properties.

Probably the best way is to set default values for such parametres in pipelineCache each time when starting to update sampler

@flibitijibibo
Copy link
Member

This isn't required but if you have a test case that'll speed things up a bit, just so we have a quick comparison to look at with both XNA and FNA.

@theranix
Copy link
Author

theranix commented Feb 15, 2023

My team is about to make some updates for graphicsdevice & effect, including fixes of caching issue.
We faced following thing:

public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
		{
			// D3D11 requires our sampler state to be valid (i.e. not point to any of our new RTs)
			//  before we call SetRenderTargets. At this point FNA3D does not have a current copy
			//  of the managed sampler state, so we need to apply our current state now instead of
			//  before our next Clear or Draw operation.
			ApplySamplers();

Can you please explain how it should work?
Usually we have modifiedSamplers all "false" because of applypass of effect then draw. So in this way nothing will be applied
Only in one case modifiedSamplers can still have true - manual setting GraphicsDevice.TextureCollection etc. but in such case it seems unusual

@flibitijibibo
Copy link
Member

ApplySamplers basically flushes any changes made to the collections - for example, the bool is updated for textures here. Normally we would just flush before drawing, but it turns out D3D11 needed this for render target bindings as well to avoid issues with feedback loops.

For effects, this should be applied here for sampler states and here if textures are set via a parameter rather than directly via TextureCollection.

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

No branches or pull requests

2 participants