<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic OpenGL - glTexSubImage2D on Intel 4 Series/Windows 7 Performance in Developing Games on Intel Graphics</title>
    <link>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775339#M43</link>
    <description>glTexSubImage2D is unacceptably slow with an Intel Series 4 on Windows 7, driver version 8.15.10.2141 (latest). Benchmarked with the following code:&lt;BR /&gt;&lt;PRE&gt;	DWORD start = timeGetTime ();

	for (int i = 0; i &amp;lt; NUM_TEXIMAGE; i++)
	{
		glBindTexture (GL_TEXTURE_2D, teximage&lt;I&gt;);
		glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, TEX_WIDTH, TEX_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, sibuffer);
	}

	DWORD end = timeGetTime ();
&lt;/I&gt;&lt;/PRE&gt;A single call requires some 20ms to return for a 512x512 texture; the code above (TEX_WIDTH is 64, TEX_HEIGHT is 512, NUM_TEXIMAGE is 16, timeBeginPeriod (1)) requires ~45ms, compared to &amp;lt; 5ms on an Intel 945, older driver rev, Windows XP. Have ensured formats match and have attempted use of PBO with no measurable performance difference. PFD_SUPPORT_COMPOSITION makes no difference&lt;BR /&gt;&lt;BR /&gt;Is there a pullback from texture memory to system memory happening here?&lt;BR /&gt;</description>
    <pubDate>Thu, 22 Jul 2010 20:54:36 GMT</pubDate>
    <dc:creator>mfah</dc:creator>
    <dc:date>2010-07-22T20:54:36Z</dc:date>
    <item>
      <title>OpenGL - glTexSubImage2D on Intel 4 Series/Windows 7 Performance</title>
      <link>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775339#M43</link>
      <description>glTexSubImage2D is unacceptably slow with an Intel Series 4 on Windows 7, driver version 8.15.10.2141 (latest). Benchmarked with the following code:&lt;BR /&gt;&lt;PRE&gt;	DWORD start = timeGetTime ();

	for (int i = 0; i &amp;lt; NUM_TEXIMAGE; i++)
	{
		glBindTexture (GL_TEXTURE_2D, teximage&lt;I&gt;);
		glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, TEX_WIDTH, TEX_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, sibuffer);
	}

	DWORD end = timeGetTime ();
&lt;/I&gt;&lt;/PRE&gt;A single call requires some 20ms to return for a 512x512 texture; the code above (TEX_WIDTH is 64, TEX_HEIGHT is 512, NUM_TEXIMAGE is 16, timeBeginPeriod (1)) requires ~45ms, compared to &amp;lt; 5ms on an Intel 945, older driver rev, Windows XP. Have ensured formats match and have attempted use of PBO with no measurable performance difference. PFD_SUPPORT_COMPOSITION makes no difference&lt;BR /&gt;&lt;BR /&gt;Is there a pullback from texture memory to system memory happening here?&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Jul 2010 20:54:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775339#M43</guid>
      <dc:creator>mfah</dc:creator>
      <dc:date>2010-07-22T20:54:36Z</dc:date>
    </item>
    <item>
      <title>OpenGL - glTexSubImage2D on Intel 4 Series/Windows 7 Performanc</title>
      <link>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775340#M44</link>
      <description>Update:&lt;BR /&gt;&lt;BR /&gt;Internal Format: GL_RGBA&lt;BR /&gt;Format: GL_BGRA&lt;BR /&gt;Type: GL_UNSIGNED_INT_8_8_8_8_REV&lt;BR /&gt;&lt;BR /&gt;Problem completely goes away.&lt;BR /&gt;&lt;BR /&gt;I suspect that the driver was pulling the teximage data back to system memory otherwise. Can anyone confirm or deny?&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE align="center" border="0" cellpadding="3" cellspacing="1" width="90%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;BR /&gt;&lt;/TD&gt;	&lt;/TR&gt;	&lt;TR&gt;	  &lt;TD class="code"&gt;mode: 0 320ms [GL_RGBA/GL_UNSIGNED_BYTE] (OK)
&lt;BR /&gt;
mode: 1 317ms [GL_BGRA/GL_UNSIGNED_BYTE] (OK)
&lt;BR /&gt;
mode: 2 377ms [GL_RGBA/GL_UNSIGNED_INT_8_8_8_8] (OK)
&lt;BR /&gt;
mode: 3 375ms [GL_BGRA/GL_UNSIGNED_INT_8_8_8_8] (OK)
&lt;BR /&gt;
mode: 4 376ms [GL_RGBA/GL_UNSIGNED_INT_8_8_8_8_REV] (OK)
&lt;BR /&gt;
mode: 5 12ms [GL_BGRA/GL_UNSIGNED_INT_8_8_8_8_REV] (OK)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 24 Jul 2010 00:48:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775340#M44</guid>
      <dc:creator>mfah</dc:creator>
      <dc:date>2010-07-24T00:48:02Z</dc:date>
    </item>
    <item>
      <title>OpenGL - glTexSubImage2D on Intel 4 Series/Windows 7 Performanc</title>
      <link>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775341#M45</link>
      <description>Hi mfah,&lt;BR /&gt;&lt;BR /&gt;What do you mean the problem completely goes away? &lt;BR /&gt;&lt;BR /&gt;From your first post, I take the problem as a performance differnence concern from older driver on 945 versus a newer driver on Intel 4 Series card.&lt;BR /&gt;&lt;BR /&gt;Are you saying that if you used the GL_UNSIGNED_INT_8_8_8_8_REV / GL_BGRA, this performance difference is not seen anymore?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;-Ganesh</description>
      <pubDate>Thu, 29 Jul 2010 17:15:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775341#M45</guid>
      <dc:creator>Doraisamy_G_Intel</dc:creator>
      <dc:date>2010-07-29T17:15:53Z</dc:date>
    </item>
    <item>
      <title>OpenGL - glTexSubImage2D on Intel 4 Series/Windows 7 Performanc</title>
      <link>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775342#M46</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Yes, this is correct. The older part/older driver did not exhibit this performance problem, the newer one does. Running a VMWare session (via VMWare's SVGA driver) on the newer part/newer driver also does not exhibit this problem.&lt;BR /&gt;&lt;BR /&gt;By switching the type and format to GL_UNSIGNED_INT_8_8_8_8_REV/GL_BGRA the performance problem is removed.&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Sep 2010 15:30:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775342#M46</guid>
      <dc:creator>mfah</dc:creator>
      <dc:date>2010-09-13T15:30:14Z</dc:date>
    </item>
    <item>
      <title>OpenGL - glTexSubImage2D on Intel 4 Series/Windows 7 Performanc</title>
      <link>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775343#M47</link>
      <description>&lt;P&gt;Can you provide a test kernel? We will try to replicate the issue and try to provide a better explanation.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2010 18:15:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775343#M47</guid>
      <dc:creator>Doraisamy_G_Intel</dc:creator>
      <dc:date>2010-09-16T18:15:04Z</dc:date>
    </item>
    <item>
      <title>OpenGL - glTexSubImage2D on Intel 4 Series/Windows 7 Performanc</title>
      <link>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775344#M48</link>
      <description>The following test app (SDL, mostly portable, compiles with MSVC 2008) can be used to test/verify this issue:
&lt;PRE&gt;#define WINDOW_WIDTH    800
#define WINDOW_HEIGHT    600

#include "SDL.h"
#include "SDL_opengl.h"

#pragma comment (lib, "SDL.lib")
#pragma comment (lib, "SDLmain.lib")
#pragma comment (lib, "opengl32.lib")

#define TEX_WIDTH 512
#define TEX_HEIGHT 512

unsigned int sibuffer[TEX_WIDTH * TEX_HEIGHT];
unsigned int teximage = 0;
unsigned int framecount = 0;

// find the fastest modes to use for glTexSubImage2D
typedef struct tsitest_s
{
    char formatstr[64];
    char typestr[64];
    GLenum format;
    GLenum type;
    int modespeed;
    bool failed;
} tsitest_t;

tsitest_t tsimodes[] =
{
    {"GL_RGBA", "GL_UNSIGNED_BYTE", GL_RGBA, GL_UNSIGNED_BYTE, 666, true},
    {"GL_BGRA", "GL_UNSIGNED_BYTE", GL_BGRA, GL_UNSIGNED_BYTE, 666, true},
    {"GL_RGBA", "GL_UNSIGNED_INT_8_8_8_8", GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 666, true},
    {"GL_BGRA", "GL_UNSIGNED_INT_8_8_8_8", GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 666, true},
    {"GL_RGBA", "GL_UNSIGNED_INT_8_8_8_8_REV", GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 666, true},
    {"GL_BGRA", "GL_UNSIGNED_INT_8_8_8_8_REV", GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 666, true}
};


int fastest = 666;
int bestspeed = 32768;

GLuint R_MakeMeATexture (int width, int height, GLenum format, GLenum type)
{
    GLuint texnum = 0;

    glEnable (GL_TEXTURE_2D);
    glGenTextures (1, &amp;amp;texnum);
    glBindTexture (GL_TEXTURE_2D, texnum);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, format, type, NULL);

    // commit the buffer so that timings are valid
    glFinish ();

    return texnum;
}


void R_SetTSIMode (void)
{
    int numtsimodes = sizeof (tsimodes) / sizeof (tsitest_t);

    for (int i = 0; i &amp;lt; numtsimodes; i++)
    {
        // clear last the error (if any)
        glGetError ();

        // create a new texture object
        GLuint texnum = R_MakeMeATexture (TEX_WIDTH, TEX_HEIGHT, tsimodes&lt;I&gt;.format, tsimodes&lt;I&gt;.type);

        Uint32 start = SDL_GetTicks ();

        // SDL_GetTicks has insufficient resolution to measure one call so we need to run a few of them
        for (int t = 0; t &amp;lt; 16; t++)
            glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, TEX_WIDTH, TEX_HEIGHT, tsimodes&lt;I&gt;.format, tsimodes&lt;I&gt;.type, sibuffer);

        Uint32 end = SDL_GetTicks ();

        // commit the buffer so that timings are valid
        glFinish ();

        glDeleteTextures (1, &amp;amp;texnum);

        if (glGetError () != GL_NO_ERROR)
            tsimodes&lt;I&gt;.failed = true;
        else tsimodes&lt;I&gt;.failed = false;

        tsimodes&lt;I&gt;.modespeed = (end - start);
    }

    for (int i = 0; i &amp;lt; numtsimodes; i++)
    {
        printf ("mode: %i %4ims [%s/%s] (%s)\n", i, tsimodes&lt;I&gt;.modespeed, tsimodes&lt;I&gt;.formatstr, 
            tsimodes&lt;I&gt;.typestr, tsimodes&lt;I&gt;.failed ? "FAILED" : "OK");

        if (tsimodes&lt;I&gt;.modespeed &amp;lt;= bestspeed &amp;amp;&amp;amp; !tsimodes&lt;I&gt;.failed)
        {
            bestspeed = tsimodes&lt;I&gt;.modespeed;
            fastest = i;
        }
    }

    if (fastest == 666)
    {
        MessageBox (NULL, "Failed to find a format!", "Error", MB_OK | MB_ICONSTOP);
        exit (0);
    }
}


void RenderOpenGL (void)
{
    framecount++;

    for (int i = 0, w = 0; w &amp;lt; TEX_WIDTH; w++)
    {
        for (int h = 0; h &amp;lt; TEX_HEIGHT; h++, i++)
        {
            unsigned char *rgba = (unsigned char *) &amp;amp;sibuffer&lt;I&gt;;

            // 2 == red, 1 == green, 0 == blue
            rgba[2] = ((h * i) + framecount) &amp;amp; 255;
            rgba[1] = ((w * h) + framecount) &amp;amp; 255;
            rgba[0] = ((w * i) + framecount) &amp;amp; 255;
            rgba[3] = 255;
        }
    }

    glClear (GL_COLOR_BUFFER_BIT);

    glViewport (0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);

    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity ();

    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    glOrtho (0, WINDOW_WIDTH, WINDOW_HEIGHT, 0, -99999, 99999);

    glBindTexture (GL_TEXTURE_2D, teximage);
    glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

    glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, TEX_WIDTH, TEX_HEIGHT, tsimodes[fastest].format, tsimodes[fastest].type, sibuffer);

    glBegin (GL_QUADS);

    glTexCoord2f (0, 0);
    glVertex2f (0, 0);

    glTexCoord2f (1, 0);
    glVertex2f (TEX_WIDTH, 0);

    glTexCoord2f (1, 1);
    glVertex2f (TEX_WIDTH, TEX_HEIGHT);

    glTexCoord2f (0, 1);
    glVertex2f (0, TEX_HEIGHT);

    glEnd ();
}


int main (int argc, char *argv[])
{
    if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) != 0)
    {
        printf ("Unable to initialize SDL: %s\n", SDL_GetError ());
        return 1;
    }

    SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
    SDL_Surface *screen = SDL_SetVideoMode (WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_OPENGL);

    R_SetTSIMode ();
    teximage = R_MakeMeATexture (TEX_WIDTH, TEX_HEIGHT, tsimodes[fastest].format, tsimodes[fastest].type);
    glClearColor (0, 0, 0, 1);

    int done = 0;
    SDL_Event evt;

    while (!done)
    {
        while (!done &amp;amp;&amp;amp; SDL_PollEvent (&amp;amp;evt))
        {
            if (evt.type == SDL_QUIT)
            {
                done = 1;
                break;
            }
        }

        // run the screen update here
        RenderOpenGL ();
        SDL_GL_SwapBuffers ();
    }

    return 0;
}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Sep 2010 17:20:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Developing-Games-on-Intel/OpenGL-glTexSubImage2D-on-Intel-4-Series-Windows-7-Performance/m-p/775344#M48</guid>
      <dc:creator>mfah</dc:creator>
      <dc:date>2010-09-27T17:20:31Z</dc:date>
    </item>
  </channel>
</rss>

