Jump to content
  • Advertisement

waZim

Member
  • Content count

    85
  • Joined

  • Last visited

Community Reputation

100 Neutral

About waZim

  • Rank
    Member
  1. Quote:Original post by RobTheBloke Quote:Original post by waZim // I want to call this _USER_INCLUDE("Something") // Or _USER_INCLUDE(Something) // This should expand into #include "Something.h" // Or should expand into #include "Something.cpp" // Or should expand into #include "Something.inl" // Based on some flag. If you have no directory paths before the filename, and you are using visual C++, you can alias the include like so: *** Source Snippet Removed *** And then to use you need: *** Source Snippet Removed *** I'm not convinced there's much value to this though..... I believe it will create a lot of aliases as well. And its more work then I could do otherwise puting a #if in each header file instead. This include_alias stuff is cool though, I didn't know before. thanks for that.
  2. Quote:Original post by rip-off First of all, use __forceinline with care. It is only to be used on a specific function that *needs* to be inlined, because you have proven using profiling that the compiler's inlining heuristics have failed in a specific case. Forcing inlining will cause your executable to bloat, which puts pressure on the cache and can cause the program to perform slower than expected. Most modern compilers ignore "inline", except to allow you to implement files in headers. Some compilers provide link time code analysis, so the compiler might wait until link time to see which functions make the most sense to inline. This would explain why you didn't see much of a difference in the speed. I am assuming that you compiled the code with the correct RELEASE settings for your comparison? What were you using to compare speed, not FPS I hope? Nice Insight. And ofcourse I did use FPS for comparison on a static scene with the same settings and such. What would you suggest? to do to check if it really matters?
  3. Quote:Original post by Antheus Quote:Original post by waZim Quote:Original post by alvaro You mean this? *** Source Snippet Removed *** Not really. What I would like to do is use something like I said before. // This should expand into #include "Something.h" // Or should expand into #include "Something.cpp" // Or should expand into #include "Something.inl" // Based on some flag. It's not good to be too smart about such things. A typical example of this is heavy class hierarchies for DX/OGL abstractions. Think about it rationally - DX and OGL will never be switched at runtime (or there simply is no need), and on all platforms except Windows, DX cannot be even compiled, perhaps even parsed. Since the above includes .inl and .cpp, it's almost certain it's about a similar problem. In above case, "based on some flag" is best presented to user as:#include "functions.h"No exotic user-defined macros. Regular include, where functions.h is a regular header. Except that header then does the most trivial thing:// header.h #ifdef FOO #include "slow_but_compatible_impl.h" #endif #ifdef BAR #include "fast_but_requires_sse.h" #endif #ifdef BAZ #include "bitchin_fast_when_it_doesnt_crash.h" #endif But that is just intermediate step. Why is the code responsible for completely disjoint functionality? Consider instead the following:/include/foo /src/foo /src/foo/reference /src/foo/simd /src/foo/experimental The /include/foo/functions.h contains one header, no ifdefs there. Which of the src/foo get used is determined by linker alone. When building on a certain platform, we don't want to litter the code with stuff that will not compile or even parse. Nor does one want to annoy preprocessor with a lot of cruft that will never be used. Even more - such organization allows each of src/foo to live in its own project, with its own set of platform-specific tests. They can be distributed and maintained individually, the only connection is the include/foo header. No ifdefs anywhere, since each src/foo is specific, possible to choose from build, and possible to probe much deeper (makefile et al) than what is possible with compiler. Sorry Guys for not making it very clear what I really wanted to do so here it is. I have been developing a game engine. I used the approach of abstracting inline and __forceinlie with a Symbol lets call it _MYINILNE_. On Micorsoft compilers I wanted to used __forceinline and hope for performance improvement. while on others use inline. So I have to create *.h, *.cpp, and *.inl files and include *.inl in hearder files, because I don't want to do definitions in header files. Now I just wanted to try the engine without any "inline" or "__forceinline". I can define my _MYINLINE_ to nothing. so that I can check if it makes any difference. But since I have done it in all source files I can't manually do it. So I needed a macro of some kind, (initially the solution that I thought). So the problem is that. Everything that I declared in my hearders as _MYINLINE_ when are inline or __forceinline then they are good if I have defined them in *.inl files. But if _MYINLINE_ is defined as nothing then They are suppose to be defined in *.cpp file otherwise I will get compiler time errors or multiple defined objects. So I wanted this switching to happen with a flag. BTW: Switching between everything inline/__forceinline and no inlining makes NO DEFFERENCE AT ALL
  4. Quote:Original post by alvaro You mean this? *** Source Snippet Removed *** Not really. What I would like to do is use something like I said before. // I want to call this _USER_INCLUDE("Something") // Or _USER_INCLUDE(Something) // This should expand into #include "Something.h" // Or should expand into #include "Something.cpp" // Or should expand into #include "Something.inl" // Based on some flag. so if "something" is defined include CPP file or include INL file. I would like to use a simple macro not too much code with a bunch of IFs in each source file.
  5. How would you do conditional variable includes?
  6. How can I create a preprocessor directive out of a macro or preprocessor directive. For example // I want to call this _USER_INCLUDE("Something") // Or _USER_INCLUDE(Something) // This should expand into #include "Something.h" Is it even possible?
  7. What will be the value of output. output = (X & Y) | (X & Z) | (Y & Z); can this expression be simplified?
  8. Quote:Original post by Antheus Duff's device. Thanks alot, that was helpfull, Although my point was not what its doing or how it works. I was more concerned about how the first time the loop is entered. calling send(p1,p2,15); will call it like this initially. void send (int *to, int * from, int count) { int n = 1; switch (7) { // Not this part missed //case 0: do { *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *to++ = *from++; case 3: *to++ = *from++; case 2: *to++ = *from++; case 1: *to++ = *from++; } while ( --n > 0 ); } } I was not able to understand how even this loop works since in this case its in-complete. Or lets say "do" is not executed so how does the compiler knows its a loop? only from "while"?
  9. What does the following code do and why would anyone write something like that? void send (int *to, int * from, int count) { int n = (count + 7) / 8; switch ( count % 8) { case 0: do { *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *to++ = *from++; case 3: *to++ = *from++; case 2: *to++ = *from++; case 1: *to++ = *from++; } while ( --n > 0 ); } } I have found this question over internet, calling send(p1,p2,15) will copy 15 ints from p2 to p1, but the first time case 7: triggers, how does this code repeats? case 0: do { ... is never called in this case and even then the loop runs back? the loop is even in-complete. what C++ feature am i missing which explains this?
  10. hi all, I have simple shadow mapping working with 3 passes as i have followed the following tutorial. http://www.paulsprojects.net/tutorials/smt/smt.html I was wondering if i can get rid of the second pass in which you draw the scene with less-bright light and then in the 3rd pass you draw the same scene with bright light on top of that not drawing in those places where you have shadows. i think this can be accomplished with the help of combiners in OpenGL but i don't know how to setup for that and how can i modulate with a black color where i see shadow instead of drawing the dark scene in a seperate pass? any help would be greatly appriciated .. waZim
  11. hi all, I have simple shadow mapping working with 3 passes as i have followed the following tutorial. http://www.paulsprojects.net/tutorials/smt/smt.html I was wondering if i can get rid of the second pass in which you draw the scene with less-bright light and then in the 3rd pass you draw the same scene with bright light on top of that not drawing in those places where you have shadows. i think this can be accomplished with the help of combiners in OpenGL but i don't know how to setup for that and how can i modulate with a black color where i see shadow instead of drawing the dark scene in a seperate pass? any help would be greatly appriciated .. waZim
  12. Quote:Original post by force_of_will Boas ! Hi, thats strange, are you sure your not including the source code in the client app ? Yes i am sure. i even excluded the CPP File from the DLL Project and still my client is able to compile without any errors. not even warnings. This is the code i found on MSDN you can also check it yourself. they are not using dllimport anywhere. http://msdn.microsoft.com/en-us/library/ms235636(VS.80).aspx
  13. i am creating a DLL from the following header and cpp files. i got the following example from MSDN Header file for the DLL // TestingDllFuncs.h namespace MathFuncs { class __declspec(dllexport) MyMathFuncs { public: // Returns a + b double Add(double a, double b); // Returns a - b double Subtract(double a, double b); // Returns a * b double Multiply(double a, double b); }; } source file for the DLL // TestingDllFuncs.cpp #include "TestingDllFuncs.h" #include <stdexcept> using namespace std; namespace MathFuncs { double MyMathFuncs::Add(double a, double b) { return a + b; } double MyMathFuncs::Subtract(double a, double b) { return a - b; } double MyMathFuncs::Multiply(double a, double b) { return a * b; } } client application for the DLL #include <iostream> #include "TestingDllFuncs.h" using namespace std; int main() { MathFuncs::MyMathFuncs temp; double a = 7.4; int b = 99; cout << "a + b = " << temp.Add(a, b) << endl; cout << "a - b = " << temp.Subtract(a, b) << endl; cout << "a * b = " << temp.Multiply(a, b) << endl; return 0; } if you see the above code i am NOT using __decspec(dllimport) anywhere. and i also don't get any compiler errors or warnings. so i don't understand where can you use __decspec(dllimport)?
  14. hi all, I have been able to create a DLL and load and use it as well. All what i have used to export a class into a dll is as follows. class __declspec(dllexport) ClassName {}; and then in the client application i have linked the lib and used the header file. i don't understand where i need to use __declspec(dllimport) what is that for? .. waZim
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!