-
Notifications
You must be signed in to change notification settings - Fork 81
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
this is a set of modifications to modernize parts of the code #1515
Conversation
using static constexpr seems to incrase compile time but atleast under my tests also provides some marginal speedups |
Co-authored-by: Michael Hansen <[email protected]>
Co-authored-by: Michael Hansen <[email protected]>
return {p0.fY * p1.fZ - p0.fZ * p1.fY, | ||
p0.fZ * p1.fX - p0.fX * p1.fZ, | ||
p0.fX * p1.fY - p0.fY * p1.fX | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably remain an hsVector3
for type safety and clarity. I don't think there's any performance impact here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair enough i just found it as duplicating the type since the function already returns it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always better to use the defined constructor for an object instead of pushing in memory directly. Even if it's a bit duplicative with the type name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dgelessus - I see your emoji. I'm poking at this and I see C++ is policing the number of elements in the struct. However - this struct does have a defined constructor and it does seem weird to go around it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I wanted to explain later and forgot, sorry. As I understand it, the brace syntax in this case will use the constructor defined in the class, despite the brace syntax. According to cppreference, the C-style field by field initialization is called aggregate initialization, which never applies to classes with user-defined constructors. Instead, the brace syntax does list initialization here, which in this case calls the normal constructor, exactly like the previous code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dgelessus Thanks! I'll review the docs.
| D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0); | ||
|
||
static D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, | ||
static constexpr D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if the identity matrix should be constexpr. Something being both static and constexpr may already be a bit of a paradox. But the identity matrix is loaded as a buffer from a pointer, which means it can't actually be constexpr easily by a compiler. And it might be more optimal just to have one copy of the buffer in memory anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static constexpr
is perfectly valid. Sometimes you have things that can be used at both compile-time and runtime. In this case, we aren't doing any compile-time matrix math, so it probably makes more sense to just leave this one alone. I doubt that the generated machine code is any different since we're just going to be pushing a pointer onto the stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can revert this if desired
You may revert or remove 843c93b |
843c93b
to
628841a
Compare
dropped the commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR covers an odd set of topics. I think we would prefer to see changesets grouped by topic where possible.
@@ -55,7 +55,7 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |||
#if HS_BUILD_FOR_WIN32 | |||
# include "hsWindows.h" | |||
# include <io.h> | |||
# define isatty _isatty | |||
# define ttycheck(fileinfo) (GetFileType(fileinfo) == FILE_TYPE_CHAR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We prefer to use standards compliant mechanisms. AFAIK, isatty
is part of the POSIX standard. The Windows SDK just emits an erroneous deprecation warning with isatty
and wants _isatty
(which is just the Microsoft way of making life more difficult for cross-platform development). Is there a particular bug that is fixed by using (GetFileType(fileinfo) == FILE_TYPE_CHAR)
instead of _isatty
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it does if the user attempts compile and run the game using msys2 or cygwin the value of _isatty can be invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, you should probably fix the preprocessor checks to detect that situation to use isatty
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldnt HS_BUILD_FOR_WIN32 handle that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HS_BUILD_FOR_WIN32
will be defined for MSVC, clang-cl, and mingw
In this case, you'll need an extra check for mingw to avoid aliasing isatty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still seems to be using non-standards complaint naming, unfortunately. We prefer the POSIX standard isatty
.
Co-authored-by: Adam Johnson <[email protected]>
Co-authored-by: Adam Johnson <[email protected]>
Due to the changes to pfDXPipeline, this will be deferred until after #1326 is merged. |
fine by me I just hope the mac port lands successfully |
feel free to poke around here. this draft is more an experiment then an actual draft atm.