Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


Pachanoi

Member Since 22 Mar 2005
Offline Last Active Yesterday, 05:06 PM

Posts I've Made

In Topic: Get Buffer from Constant Buffer

25 January 2014 - 01:43 PM

If you are trying to retrieve a constant buffer that is currently bound to the device, this is the only way that I'm aware of to do it.  But it does seem fairly well documented to me.  The first parameter is the starting register, the second is the number of buffers you want to retrieve starting from the register you gave as the first parameter, and the last is a pointer to the array of ID3D11Buffer pointers where you want to store the results. So if you wanted to get the constant buffer in register 1, you would do something like:

ID3D11Buffer* buffer[1];
context->VSGetConstantBuffers(1, 1, &buffer);

In Topic: Pass entire vector of objects to constructor by reference?

20 January 2014 - 10:56 PM

I'm going to assume that your variable heroes is not a pointer, in which case you should not use the * operator and just pass it directly to the constructor: spells.push_back(new Star(heroes));

 

It works for your single objects since they are pointers.

 


In Topic: Light Culling on the GPU for a Tile Based Forward Renderer.

04 October 2013 - 08:50 AM

There are a lot of cases where it's useful or required to use dynamic branching in this way, where one thread needs to perform some operations. But I'm not sure if this is what you really want to be doing here, since you are using a single thread to loop over the entire group's shared data.  Have you looked into InterlockedMax?  You should be able to compute your max depth without doing any sort of looping over the data, or need for the cache other than a single groupshared uint. Just remember you will need to convert your sampled depth to uint first, and then convert the final max depth back to a float before storing in your max z buffer.

 

 

Edit:

 

As far as the branching goes, it's perfectly ok to have the first thread do some work if it's going to be shared across the group.  For example, computing the frustum for each tile would just need to be done for the one thread. Obviously only do this in cases where it only makes sense for one thread to do it.

 

Based on the comments it looks like you have your light list building code inside that if statement. This can be distributed as well.  I believe one of the tile based shading articles in GPU Pro 4 shows how to do this, and I'm pretty sure it's done in this sample.  Something like this:

 

// Get a list of the lights that affect the tile
for(uint i=0; i<g_NumLights; i+=GROUP_SIZE)
{
    uint lightIndex = groupIndex + i;
    if( lightIndex < g_NumLights )
    {
        // Check if the light affects this tile
        if( light is visible to the tile )
        {
            // Update the counter
            uint currentTileLightIndex;
            InterlockedAdd(sharedTileLightCounter, 1, currentTileLightIndex);

            // Add the light to the list
            if(currentTileLightIndex < MAX_LIGHTS)
                g_LightList[currentTileLightIndex] = lightIndex;
        }
    }
}
GroupMemoryBarrierWithGroupSync();

In Topic: Question about game portfolio and sprite sheets

29 September 2013 - 04:55 PM

I have seen games use a spritesheet in their games while the game I made does not use a spritesheet. Instead my game uses individual images that are loaded into the game rather than what most people would do is to figure out the subimage of the spritesheet that are they are interested in drawing into the game screen which involves some hardcoded offsets of x and y coordinates which can be exteremely messy code.

 

Is it not the whole point to programming the game with clean code as possible? This was the reason why I did not go for the spritesheet approach.

 

Well you definitely don't have to hard code the values. In the 2d games I've worked on we've always used an animation tool to determine the image rects for each frame, and this was exported to file.  We wrote our own editor so we could tie events to certain frames a bit easier but I know there are a few free tools that will do this from a sprite sheet. I'm sorry but I can't remember any of the names at the moment, try google. But if you prefer having your frames as individual images then go for it, do whatever works best for your project.


In Topic: Sparse Virtual Textures - Is there a way/hack to save that extra geometry pass?

25 March 2013 - 09:37 PM

If you are targeting d3d11, you can store your page visibility list in a RWStructuredBuffer<int>.  All you need is the page ID, which is easy to compute from the UV coords.  In my engine I store this as an array of all pages, and increment the corresponding page index in the pixel shader in the geometry pass.  This also gives you the number of pixels that use each page, which you can use to prioritize the page streaming.


PARTNERS