-
Notifications
You must be signed in to change notification settings - Fork 55
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
Implemented Math functions, automated headless graphics device testing, numerous bug fixes and improvements #77
Conversation
…dd_full_mathf_support
…ogic to skip tests automatically into attribute system on tests. This will cause tests that require certain backends to be simply skipped (with a reason) on systems that don't support that backend, instead of showing as passed.
…y reduces duplicate code, and will make move to full stack testing easier. (Not yet compiling)
…y to vastly enhance output in case of errors, making it easier to trace issues. Tests which require various tool sets are now auto-skipped.
…ader generation, remove duplicate code, and improve signatures.
…culates alignments and sizes in one pass and it adds alignment info objects as it goes, preventing duplicate analysis. It remains thread safe and should be considerably faster and safer. It also correctly skips static fields now, and the code is no longer duplicated.
… legitimate members.
…upplied. Doesn't yet correctly rewrite method body.
…ould probably not support it at all in shader code. To that end I've added a check that will auto-detect the majority of non-blittable types and error cleanly.
…tests work on Vulkan, but none of the other backends which throw strange errors.
… all backends. Added deep check on structs to make it much easier to see which fields have failed comparison checks (also prevents failures due to float.NaN).
…iple times to find statistical failure rate. (Note only GLS330 is implemented, so shader will not yet build on other backends).
By the way, the test output tends to be a bit noisy with messages about skipped tests. Is there a way that we can force the "skip" messages to get combined? On macOS, 80+ tests are skipped, so the output is really noisy, but all of the messages say the same thing. I'm not sure if we can do anything within Xunit's constraints. |
These are two methods that take a second parameter, and from the original code you linked the cast is only applied to this second parameter. The metal specification says these method can take multiple input types, so I guess the issue was an ambiguity was created if the second parameter was not obviously a The existing code checks if the first param is a float and then ensures the second parameter is unambiguously a float. It also checks if the typeName is To add complexity, in the built in methods, we have one You can see the changes in 6be9b0e, however, I can't test as I don't have access to Metal. |
The Attribute approach had the big advantage of skipping entire theories with a single message rather than skipping each test of the theory. That massively reduced skip messages. To be honest, I always use a GUI test runner so I never noticed any particular verbosity. I could go back and retry the attribute code to see if the CI server check (see 3324131) is sufficient to prevent the CI server from crashing now? |
The latest version is getting close on macOS. There's still a few problems:
|
Pretty sure that is ultimately the only real solution, as it will be necessary if you ever hope to consistently resolve OpenGLES' strict type checking. Further, there's an endless set of edge cases, any type that can be implicitly cast to a float will compile in the C#, but would fail a bulk type check. Looking to see what the method accepts is a far more robust solution.
The
As far as I can see you can only extract the |
I've shown this is action in a930183. |
The Toolchain constructor already creates a GraphicsDevice instance to ensure the call will actually work (on this line), so I figured the check could just be done there. Checking inside of the method is also fine, but I thought this fit well into the "capability flags" concept. I don't have a strong opinion one way or the other)
There's no reason to use headless GraphicsDevice instances except it avoids allocating the resources for an OS window. There's no difference from a regular device except a headless GraphicsDevice has no window, and it therefore has no MainSwapchain. You can use compute shaders in any GraphicsDevice. |
I fixed the two-stage compilation problem in Metal, and pushed the commit here: fa445d4 Please feel free to cherry-pick that commit into your branch.
I agree. There's a few different cases that need to be handled, though, so it wasn't as simple as I was hoping. For method invocations, it seems straightforward -- we can get all of the parameter types from |
I considered that but decided against for the following reasons:
Ultimately, I concluded that conflating the Graphics Device features with the ToolChain features is probably not a good idea. It is possible, should it prove necessary, to add skipping attributes in future that support checking for both types of features. I'm also a little surprised you chose a class of bools rather than a Flag enum, unless you plan for some features to be more descriptive in future? All that uncertainty made me nervous about just dumping it in there.
Sorry, I was probably very unclear, my point was to question whether it was reasonable to say "because you don't support compute shaders you can't create headless graphics devices"? I didn't think that a was a valid stance to take? I was also under the impression you can use headless graphics devices for more than running compute shaders, like I thought you could still run a vertex/fragment shader and render to a texture, which could be useful for testing such shaders, even potentially in a CI environment? |
Done, though I've propogated the transpiled source into the second step so that it is returned in the output CompileResult and not lost during Lib creation. That way it remains consistent with the other tool chains.
As this would be a fairly major piece of work, is it worth concluding this pull-request and doing that as a seperate piece of work, only this pull-request already introduces a lot of changes to a lot of files? As not all of the new CPU-friendly methods are fully working yet it isn't really making the situation worse? To be honest, the current tree walks need reviewing as there's quite a bit of duplication and there are quite a few cases where concepts should be handled in a more encapsulated way (consider #62, #71, etc.) Ideally, I'm keen to consider #78 again, so I can improve the CPU-GPU tests to being automatic and change them to compare across multiple GPUs as well as the CPU in one go, this will make achieving consistency more realistic. I understand pulling that from this branch, but most of the methods that are being moved aren't in the existing master branch anyway, and, although a breaking change, it is easy for downstream authors to refactor by including the new class where necessary. |
That's fine, we just need to fix the current behavior on Metal, since it's not handling |
If you could that would be helpful, as I'm not sure how best to fix it temporarily? The new I don't understand how the bug didn't exist for the original I'm happy to cherrypick a commit again? Obviously, I don't see the failure without metal. |
I pushed another commit to my branch which gets me to green on macOS. If you cherry-pick that, I'll go ahead and run all my tests again and merge when green. I ended up just always emitting the float fixup if it's a non-Vector overload (since that was easy to check). Hacky, but quick. |
To be fair, that's probably the safest bet for now! I've cherry-picked it. |
@thargy Everything looks good to me now. Would you have any problem if I squashed this when merging? There's quite a few "WIP" and intermediate state commits that I'd like to squash out, if you're not opposed. |
@mellinoe knock yourself out! I should have done that already, I had a few commits when moving from work to home and vice versa. |
@thargy Thanks for all the time and effort you dedicated to this. The improvements are well worth it! |
@mellinoe thanks for the merge! Next step is to improve the consistency between the various backends and the cpu implementations. |
Fixes #69, #70, #71, and adds support for
System.MathF
#65 (except some overloads ofRound
andIEEERemainder
) however, testing not currently possible asMathF
is not included in the current build framework. Added same methods to ShaderBuiltins making them readily available in all projects, and these are tested (except on Metal which I don't have access to).Added support for true end->end testing, including compiling and running compute shaders using Veldrid. This can be seen in action in
ShaderBuiltinsTests.cs
, which is currently disabled due to inconsistencies on some backends, to re-enable set theSkipReason
variable tonull
at the top of the file, for full breakdown of CPU/GPU failures by method.Added new
FactAttributes
to auto-ignore tests that are not supported on the current build environment.Enhanced
TypeSizeCache
now auto-detects non-blittable structs, is faster, and removes several infinite-recursion traps.Began support for constructors & instance methods (#72) by allowing constructor bodies to be passed around as well as method bodies.
TODO: mod/fmod need researching more (see comments). Trig functions, particularly hyperbolic ones and inverse one, are woefully inconsistent between GPU/CPU due, in large part, to rounding issues.
Although, I've currently turned off the end->end tests, that is to allow the code to be tested on Metal backends, etc., before forcing onto the CI server. I believe this is now of sufficient quality to merge in as it is largely correct and ready for review, and adds a lot of enhancements. It was necessary to bundle quite a lot together to get end->end working and further fixes/enhancements shouldbe more granular.