1

I am working on an opengl application development. I used the opengl function :glCompressedTexImage2D(), to upload video frame texture in ASTC texture compression format. It works well in mobile phone which the GPU support the opengl extension:GL_KHR_texture_compression_astc_ldr and the compression texture format is:GL_COMPRESSED_RGBA_ASTC_8x8_KHR,the upload time is about 2ms per frame.

I want to porting the application to Windows platform with opengl 4.5 and Nvidia GTX 750 hardware ,find that the upload success, but the upload cost too much time, which is about 200ms~300ms per frame. I look at the hardware database: http://delphigl.de/glcapsviewer/listreports.php ,find that GTX 750 not support GL_KHR_texture_compression_astc_ldr extension. Then I used Intel(R) HD Graphics 530, which support GL_KHR_texture_compression_astc_ldr extension and the upload time is about 2ms per frame. So I want to know why Nvidia GTX 750 could upload ASTC texture success but cost so much time,is there any way to upload ASTC texture in normal time(2ms per frame) using the Nvidia GTX 750.The Intel(R) HD Graphics 530 could not support complicated 3D application.

Here is the upload code:

glCompressedTexImage2D(GL_TEXTURE_2D,
                                0,
                                compressed_data_internal_format,
                                xsize,
                                ysize,
                                0,
                                n_bytes_to_read,
                                astc_data_ptr);

GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,     GL_REPEAT));
GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,     GL_REPEAT));
genpfault
  • 51,148
  • 11
  • 85
  • 139
  • "*the upload cost too much time, which is about 200ms~300ms per frame.*" What does "per-frame" mean with regard to uploading data? – Nicol Bolas Mar 15 '16 at 18:22
  • It means when I call glCompressedTexImage2D() once, the time cost of the function is about 2ms in mobile device GPU and Intel(R) HD Graphics 530 which support GL_KHR_texture_compression_astc_ldr extension. In the Nvidia GTX 750, the time is about 200ms~300ms, using the same data to upload. – francisyang Mar 16 '16 at 01:54

2 Answers2

1

is there any way to upload ASTC texture in normal time(2ms per frame) using the Nvidia GTX 750

If the implementation does not expose the GL_KHR_texture_compression_astc_ldr extension, then the implementation does not support ASTC. And therefore, you cannot upload that data to it, regardless of how much time it takes.

NVIDIA's driver should have errored out when you attempted to allocate texture storage in a format it does not support. But whether it does or not, it makes no sense to optimize erroneous code. Nor does it make sense to look at the timings of erroneous code.

Before you get to optimizations, you need to get code that is supposed to work. And yours should not, not unless that extension is supported.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • The upload success, the image is rendered in the screen and I get no error from the glGetError() function, why could it happen? – francisyang Mar 16 '16 at 00:55
  • @francisyang: A driver bug. What's probably happening is that the driver is *decompressing* your image data. Hence the slowdown. I'd say that NVIDIA's unified driver model is probably responsible; some part of the code was developed to allow ASTC formats (for Tegra, perhaps), but without the hardware support, it just defaults to decompression. – Nicol Bolas Mar 16 '16 at 01:02
  • So you mean that I could only use glCompressedTexImage2D() to upoad ASTC compression texture to GPU which support GL_KHR_texture_compression_astc_ldr extension and the specific compression texture format. Is there any links or materials could detailed describe the driver process when GPU doing upload ASTC texture? Thank you very much for your help. – francisyang Mar 16 '16 at 01:45
  • "*Is there any links or materials could detailed describe the driver process when GPU doing upload ASTC texture?*" I don't really know what you mean. All that should be happening is what normally happens when you upload any texture: data gets copied into driver-allocated memory. – Nicol Bolas Mar 16 '16 at 02:07
0

Been there.. Everything works fine in the mobile platform with ASTC. But when I test it in the linux ( with a Nvidia Tesla T4 video card ), the glCompressedTexImage2D spend 66ms per frame. FYI, no glError or render issue.

The strack show the stack call below:

Thread 1 (Thread 0x7fe36885f840 (LWP 22683)):
#0  0x00007fe3619521a4 in ?? () from /lib64/libnvidia-eglcore.so.450.102.04
#1  0x00007fe361971d06 in ?? () from /lib64/libnvidia-eglcore.so.450.102.04
#2  0x00007fe361c7ff23 in ?? () from /lib64/libnvidia-eglcore.so.450.102.04
#3  0x00007fe361f4df01 in ?? () from /lib64/libnvidia-eglcore.so.450.102.04
#4  0x00007fe362010368 in ?? () from /lib64/libnvidia-eglcore.so.450.102.04
#5  0x00007fe362010ec9 in ?? () from /lib64/libnvidia-eglcore.so.450.102.04
#6  0x00007fe361c3814b in ?? () from /lib64/libnvidia-eglcore.so.450.102.04
#7  0x00007fe361c3f4b6 in ?? () from /lib64/libnvidia-eglcore.so.450.102.04
#8  0x0000000000594253 in glCompressedTexImage2D(width=720, height=1280, options=..., internelFormat=37808, bytesToRead=921600, data=0x5ecbe80) at /home/video-dev/Template/NESTImage/header/xxx.hpp:94

It seems that the driver (/lib64/libnvidia-eglcore.so.450.102.04) handle the stuff Maybe the driver decompress the ASTC in the CPU side but not the GPU.

Paul
  • 109
  • 1
  • 9