Jump to content

  • Log In with Google      Sign In   
  • Create Account

Headkaze

Member Since 19 Feb 2006
Offline Last Active Apr 27 2014 02:14 PM

Posts I've Made

In Topic: Using two shaders at the same time

19 December 2013 - 12:47 PM

In this particular case I may have to sacrifice performance for convenience. My engine needs to be flexible enough to apply two separate shaders. What I need to know is if it's possible and then the actual code to do it.

The reason I can't mix the shaders is because I have 32 'effects' and 31 'transitions'. That would be 992 shaders to combine them.

Transitions only occur when two 'layouts' transition between each other. A 'layout' is a bunch of objects that could include a 3d model, some quads, some text, a video etc. There can be two layouts in memory at one time. One is 'current' and the other is 'next'. The 'next' layout is only used when transitioning from one layout to the next. The 'current' layout is rendered to render target 0 (m_screenTexture[0].DXTexture) and 'next' is rendered to render target 1 (m_screenTexture[1].DXTexture). As you can see in the code these are assigned to the transition shader as Input1 / Input2. For the 'effect' shader render target 0 (m_screenTexture[0].DXTexture) is assigned to SourceTexture in the shader.

The transitions work great but for the sake of flexibility I need to be able to apply an 'effect' during this transition process.

In Topic: Setting members in VB.NET without constructors

13 November 2013 - 05:41 AM

That's great thanks. Never seen curly brackets used like that in VB.NET before. Is this feature only available to Visual Studio 9 (2008) and higher?

In Topic: Array.Sort performance issue

28 October 2013 - 05:20 PM

Here is the new CompareTo method

 

public int CompareTo(RenderObject other)
{
    if (this.Layer != other.Layer)
        return this.Layer.CompareTo(other.Layer);

    if (this.Translation.Z != other.Translation.Z)
        return this.Translation.Z.CompareTo(other.Translation.Z);

    for (int i = 0; i < TEXTURE_ARRAY_COUNT; i++)
    {
        if (this.TextureArray[i] == null)
        {
            if (other.TextureArray[i] != null)
                return -1;
        }
        else if (other.TextureArray[i] == null)
            return 1;
        else if (this.TextureArray[i].Id != other.TextureArray[i].Id)
            return this.TextureArray[i].Id.CompareTo(other.TextureArray[i].Id);
    }

    if (this.BlendMode != other.BlendMode)
        return this.BlendMode.CompareTo(other.BlendMode);

    if (this.ScissorRect != other.ScissorRect)
        return (this.ScissorRect.GetHashCode() - other.ScissorRect.GetHashCode());

    return this.Index.CompareTo(other.Index);
}

 

Unfortunately the performance has not improved.


In Topic: Array.Sort performance issue

28 October 2013 - 04:29 PM

I understand about StopWatch and how to profile performance. I did state in my original post that having only one evaluation in CompareTo would not effect performance. The frame rate drop is not a perfect measurement but it's enough to see there is a substantial performance hit. So I don't need to profile to know where the issue lies. At this stage it's important that my engine maintains a solid 60 FPS.

I think the best thing to do is break the render object list up into separate lists for each layer as suggested.

Another thing I could try would be to use a different sorting algorithm. Array.Sort uses a QuickSort and does not maintain the original list order (unstable). Any suggestions there would be appreciated.

phil_t and Eck make some good points about some of issues with comparisons I've made. Layer and Translation.Z are just floats so there is no reference comparison there. But you're right about the Texture's and null values and I did make a mistake with the BlendMode comparison returning 0 instead of -1. For the ScissorRect I've changed it to compare using Rect.GetHashCode().

Thanks to everyone for all the suggestions.

In Topic: Array.Sort performance issue

27 October 2013 - 04:53 PM

1) What is the time difference in milliseconds? a delta of 5fps when its running at 200fps is not too much to worry about.


It's running at vsync 60 FPS so it is a significant performance hit.

2) Can you use a linked list and manage the order of objects when they are added/removed?


I have never tried using a LinkedList<T>. If it would be a significant benefit in this case I could give it a try.

3) Could you split your list into two smaller lists, one which is for static objects which don't change per frame, and thus don't need the sort, and dynamic ones which do?


Not really.. the 1000 objects I refer to is all text (dynamic).

PARTNERS