Last active
September 28, 2022 19:39
-
-
Save lassade/67d21ee9225dd9fd5f9e3da14e6ebb07 to your computer and use it in GitHub Desktop.
Unity SRP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPR isn't a silver bullet for the driver hell, for my experience DX11 works best in all platforms | |
// but Vulkan often has a better performance: | |
// | |
// Intel - DX11 works and runs faster than Vulkan that crashes a lot | |
// AMD - DX11 video enconding doesn't work in some cards, Vulkan has no issues | |
// NVIDEA - I had no problems with DX11 or Vulkan | |
// on a compute shader | |
Buffer<uint2> _SourcePositions; // WORNG! I can swear it was working somehow but it stopped working at some point | |
StructuredBuffer<uint2> _SourcePositions; // RIGHT! | |
// lets suppose that the buffer was delcared like so: | |
Buffer<uint> _SourcePositions; | |
// the same buffer on the C# side can be declared like so: | |
_sourcePositionsBuffer = new ComputeBuffer(SAMPLES, sizeof(uint) * 2); // WORNG! works on vulkan but doesn't work on dx11! | |
_sourcePositionsBuffer = new ComputeBuffer(SAMPLES * 2, sizeof(uint)); // RIGHT! | |
// using command buffers: | |
descriptor.msaaSamples = 2; // greater than 1 | |
descriptor.bindMS = false; | |
cmd.GetTemporaryRT(_targetId, descriptor, FilterMode.Point); | |
// WORNG! on dx11 doesn't bind the texture, my guess is that is binding the temp textureMS but I'm not sure | |
cmd.SetComputeTextureParam(_computeShader, 0, _sourceId, _targetId); | |
// you can use to Shader.GetGlobalTexture to get a texture created using command buffers | |
cmd.GetTemporaryRT("_MyTexture", descriptor, FilterMode.Point); | |
var texture = Shader.GetGlobalTexture("_MyTexture") | |
if (texture) | |
{ | |
// just keep in mind that the texture won't be available in the first 2 frames | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment