Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

189 Neutral

About amtri

  • Rank

Personal Information

  • Interests
  1. Joe, You say If I understand you correctly, what you are describing is the equivalent of a "mutex" per pixel. What you are suggesting is the equivalent of "lock", sort everything for the pixel, then "unlock". The methods I've seen with atomic variables are such that, while the call is being made, that atomic variable is replaced with a new value. But when the call returns any other thread can start modifying the variable - or, in other words, the variable is locked during the call and unlocked the moment the call returns. So by the time I start my sort the variable is no longer locked. Is there a shader call I can make to a variable to lock it and another one to unlock it? Also, on a side note: the linked list approach suffices for me provided I have enough memory. Rather than doing 2 passes I do just one and, if the memory is full, I drop everything else and set a flag that the memory was exhausted. Users then have the option to increase the memory and redraw the scene. Most of the time they will only have to do this once. Then they can draw, rotate, etc. the image without worrying. Yes; when the scene changes, say, with a rotation, everything changes, but I've noticed that if one allocates, say, 20-30% more than the initially required value, they rarely run out of memory later. My issue here is when I cannot allocate the needed memory. In that case, I want to make sure I allow a fixed number of fragments per pixel so that every pixel has a "decent" image. But that requires an insertion sort - hence, the problem I'm running into. If there's a way to lock a per-pixel variable, do the insertion sort, then unlock the per-pixel variable, then I'm all set. If you know how to do this please let me know. Thanks.
  2. I should have mentioned: I'm looking for a single-pass algorithm, if at all possible. I can accomplish the single pass with the linked list approach, but would like to have an optional K-storage-per-pixel approach, also in a single pass. Just haven't been able to figure out how I can do this.
  3. Joe, Order-independent transparency is what I'm after (as you may have guessed by the link you pointed me to). I have coded the linked-list approach. But this has a downside that I may be left with pixels with many fragments and others with few - or none - because I may have run out of memory. So the idea is to use K entries per pixels - as described in the paper. What is not clear to me in this approach is how to use the atomics in this case. For the linked list, the atomic is in the tail value for each pixel and the global counter in my linked list. So let's assume I have a x*y buffer of atomics that serves as my counter of fragments per pixel (if that's the way to do it). As another fragment comes in I can check the counter. If less than K => insertion sort; if equal to K, insertion sort and drop the last. But if two threads are working on the same pixel, would I need to define my entire storage as atomic? That would be a performance killer (I imagine). Could you point me to some (pseudo) shader code that would allow me to store up to K entries per pixel in a safe way? Thanks
  4. Hello, I need to write a shader where, for a specific pixel, as a fragment comes in I will sort a struct stored in memory based on the value of depth. For the sake of argument, let's assume I have an array of 10 entries per pixel of the struct containing {float depth; vec4 color}. As a new fragment comes in for a pixel I will use an insertion sort so I only keep the 10 front-most fragments and discard the rest. If OpenGL were sequential, this is a rather trivial operation: just program a proper insertion sort. However, my worry is that the same pixel may be processed in 2 different fragments simultaneously, so my insertion sort would fail because multiple threads would be accessing the same array. This leads me to 2 questions I'm hoping somebody has the insight to help out: 1) Can I be assured that, despite OpenGL's parallelism, no two fragments for the same pixel will ever be processed simultaneously? In other words, can I be sure that if I'm working on a pixel, then parallelism means that on another thread OpenGL will not be working on the same pixel? 2) If the answer to (1) above is no - that is, there are no guarantees - is there a way that would allow me do this in a safe way? Thanks.
  5. Hi cgrant,   I think my confusion right now is just one question: regardless how the code was compiled and on what platform, and with what version of OpenGL, is GL_VERSION (major and minor) obtained at runtime reliable ways (at runtime!) do bracket the source with "if" statements to skip over code that compiled properly but should not be called because the runtime version of opengl does not support it?   In other words, if my running machine only supports GL 1.1, can I reliably count on the fact that glGetString(GL_VERSION) will tell me that the runtime version is 1.1 and that I should skip some code that uses functionality in GL > 1.1?   I'm just hoping that glGetString(GL_VERSION) has no relation to the version used for compiling the code.   Thanks.
  6. Thanks to all for the responses.   So basically this is what I'm planning on doing:   1) When compiling I'll use #ifdef GL_VERSION_X_Y to make sure the compilation works properly.   2) When running it, let's say that glGetString(GL_VERSION) is supported. I understand that GLEW may have a bug in this function; but if I have a reliable way of parsing this string to get the major and minor version numbers, then these will be the ones available at runtime. Let's say I define an integer iversion = 10*major + minor. Then I can use #ifdef GL_VERSION_3_1 if(iversion >= 31) { /* my happy OpenGL 3.1 code here */ } #endif Of course, this is all predicated on two facts: (1) I can construct iversion reliably; and (2) iversion created at runtime by extracting the version through gl calls will give me the supported runtime version of gl - regardless of how it was compiled.   Am I correct?
  7. Osbios,   Messy all right...   Following the link that Waterlimon posted I learned that glGetString(GL_VERSION) is deprecated and has been removed in 3.1. So in order to find out the version I'm using at runtime I need to first know the version (!) so I know which function to call. I can certainly use #ifdef GL_VERSION_3_1 to decide which function to call depending on the compiler being used. But then I need to retrieve the runtime version to decide what to do.   For the moment we use no extensions, only the #ifdef GL_VERSION_X_Y at compile time, and glGetString(GL_VERSION) at runtime. I'm sure in the near future this will need to change...
  8. Hi mhagain,   Thanks.   Unfortunately, what we distribute is a library that gets embedded into an end-user application that may go to thousands of end users. And I have no control over what end users are still using (you'd be surprised!).   So I have to assume the worst - even if that means people may still be at GL 1 (ok... maybe not that far back). But my source is full of #ifdef GL_VERSION_X_Y so that the end-user application can be compiled regardless of the version of GL they choose to use, and their end users can run it also regardless of what they have on their machine.
  9. One more thing - although I'm not sure this is the place for the question:   I'm using GLEW on Windows, and include the GLEW DLL with the distribution.   Suppose I build with the latest version of GLEW then I try to run on a machine that is so old that the graphics card is unable to support the version I include in my distribution. Would glewInit() fail? Or - because the DLL is from the latest version of GLEW - could I see that glGetString returns a version I believe would work (because it is my GLEW DLL they are using), but the call could still fail?   In other words, I'm trying to protect myself from a crash. I have no problem reporting that a feature is not supported, but I cannot have the application crash. If glewInit() fails that's no problem because I will report this as an error.   Thanks again.
  10. Hi Waterlimon,   Thanks! Very clear.   So, if I understand this correctly, I can build my application on, say, OpenGL 4.2. Then, at runtime, use glGetString (GL_VERSION), parse the string to determine the version, and avoid calling functions that probably won't be available.   For example, #ifdef GL_VERSION_4_2 /* use 4.2 functionality here */ if(parsedversion(glGetString(GL_VERSION)) >= 42) { /* use the functionality here */ } #endif where "parsedversion" is some simple function that just parses the string with the version and generates an equivalent integer I can use for comparison purposes.   Of course, I could have a  "} else {" statement for a fall back approach to the functionality in case 42 is not available on the running machine. But, at this point, all I want is to make sure it won't crash.   If everything is about call a function with a null pointer, then the above code should prevent the crash. Correct?   Thanks!
  11. Hello,   I'm trying to understand a basic principle on how OpenGL works when the compilation/linking is done with one version of OpenGL, but the program actually runs on a different version.   I understand that if the runtime version of OpenGL is greater than the one it was built in this is not a problem: OpenGL is backward compatible so the program will run on a machine where a newer version of OpenGL is installed.   My problem is the other way around. My program is heavily dependent on advanced shader technology. So I have function calls such as glUniform... throughout the code.   So let's assume I built my program on a machine with the latest version of OpenGL. Now I'm going to take it to a machine running an older version. Quite possibly, a function such as glUniform... is not even present there. Given that nobody distributes software with OpenGL - either DLLs on Windows or shared libraries on Linux - will my program simply crash if I run it on a machine with an older version of OpenGL?   I'm used to building applications that rely on other libraries - but their shared libraries are usually shipped along with the application. But I don't think OpenGL follows this practice: people usually have OpenGL on their machines and use their own version.   Can somebody explain to me how this works in the general case? For example, can I just query OpenGL at runtime for the version number and simply skip calls that rely on newer versions? Will the application even load properly?   Thanks.
  12. amtri

    How to encode h264 video

    Stainless,   Isn't CUDA specific to NVIDIA graphics? Or am I missing something here? I'm supposed to assume that the only library I have is the original h264 library. Having to rely on CUDA would restrict usage to those using NVIDA graphics.   Am I correct?
  13. amtri

    How to encode h264 video

    Thanks fastcall22! I'll take a look at that thread.   Much appreciated!
  14. Hello,   I have been asked to take a series of images defined as simple bitmaps and encode them into a h264 file. I did manage to download and build the h264 libraries, but I'm having a tough time sorting through the documentation or examples to come up with a simple way of doing this through their API (I am required to use the h264 API directly).   Can somebody point me to some simple examples on how to do this?   Thanks.
  15. Yet another update: I changed the texture type to GL_TEXTURE_RECTANGLE. This way I can directly use gl_FragCoord.xy when passing data to the textures. I'm using the defaults, so I assume gl_FragCoord.xy will have values like 0.5, 1.5, 2.5, etc.   I store all my display data on display lists. I draw my display list once and save the color and depth buffer by create a frame buffer with GL_TEXTURE_RECTANGLE textures for both - one color, and one depth. The filters on both textures are set to GL_NEAREST.   I query the depth texture using   float depth = texture (depthtex,gl_FragCoord.xy).r;   My expectation is that this call should always find the exact same texel in my texture; so it writes the color and depth on one pass and reads with the exact same coordinates on the next path.   But, unfortunately, this is not the case. I "solved" my problem by using a tolerance such as   if(depth >= gl_FragCoord.z - 0.00001) discard;   on the second time I draw. The image looks perfect - pointing to the fact that this was indeed my problem. But   1) Why do I not get the exact same values on the second pass as the first pass, or... why does my comparison fails at times?\   2) Can I get better results by using different texture parameters?   Thanks.
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!