Comments (9)
You are right about alignas, true. And since we only need a single bit the assert could even be >= 2
- which makes it even less likely it's ever an issue.
I'd say opt for nothing and maybe just include this assumption in a comment above the code doing the bit shifting witchcraft.
from d3d8to9.
The bottom 16 bits are reserved for the FVF codes that can be passed into the SetVertexShader method. That's why I use the highest bit.
from d3d8to9.
I see... what about using the top bit AND shr'ing the pointer by 1 (thus assuming at-least-2-byte alignment on pointer which can be assumed safely) then? Maybe large addresses could be supported this way.
from d3d8to9.
"shr'ing"? Shifting?
from d3d8to9.
SHifting to Right, yes. Since the addresses are at least 4 byte aligned bottom bit can safely be discarded, so the top bit can be reused for tagging.
from d3d8to9.
Yes, sounds reasonable. To be 100% safe vertex_shader_info
could be declared like this: struct alignas(4) vertex_shader_info { ... };
or struct __declspec(align(4)) vertex_shader_info { ... };
for compatibility with older compilers.
from d3d8to9.
malloc (which new should use internally) is guaranteed to be aligned to 8 bytes on x86 platforms (and 16 bytes on x64). Moreover, malloc/new do not respect __declspec(align) and probably alignas too, so you'd need to use _aligned_malloc for that.
I'd leave it as is and assume 8b alignment is real. After all, only one byte is needed so for it to break you would need to get a pointer which isn't even an even number!
EDIT: If in doubt, maybe put assert((mem & 1) == 0)
?
from d3d8to9.
Well, alignas
technically does work with new
unless the type is over-aligned, which since we are on x86 won't happen as allocations align to 8 bytes (alignof(std::max_align_t)
), as you mentioned.
But yeah, could also do static_assert(alignof(std::max_align_t) >= 4, "Well, shit")
or nothing at all. Nothing at all is probably enough here.
from d3d8to9.
See #8
from d3d8to9.
Related Issues (20)
- Mafia The City Lost Heaven HOT 2
- [Crash] Pro Evolution Soccer 3 HOT 2
- Max Payne - WS Fix not working HOT 3
- .
- Consider collaborating with the d8vk project? HOT 1
- Consider recommending D3DX from NuGet instead of an old DirectX SDK HOT 3
- Ballistics (2001) - Junk polygons in menus
- C:\Microsoft\Cpp\Default\props not found HOT 1
- Rome Total War - Campaign Map Texture Issue HOT 6
- D3D8.1 Pixel and Vertex Shader Lifetimes Seem To Be Incorrect HOT 1
- Problems with character models. Pangya
- Latest update crashes Silent Hill 2 in SetVertexShader() HOT 4
- v1.11.1 - Max Payne - Loading Screen Errors / Missing Sounds
- Fellowship of the Ring black screen on startup/uncapped frame rate HOT 1
- uhh
- NVCP multi sampling anti-aliasing doesn't work. I tried everything. Metin2 is the game. HOT 1
- [Suggestion] The Bard's Tale (2005) - Solve the slowness of some parts... HOT 1
- Fixing 3dwinxp screensaver working experience
- Generals Zero Hour - Many Issues and 1 Bug HOT 1
- Failed to Load d3dx9_43.dll HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3d8to9.