Author Topic: Does setStaticUniform upload GPU every frame?  (Read 2973 times)

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Does setStaticUniform upload GPU every frame?
« on: November 12, 2014, 10:35:42 am »
Hi Egon,

Does setStaticUniform upload its value to GPU every frame? If yes, is it possible if we can make it upload only once and reuse afterwards, like texture?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Does setStaticUniform upload GPU every frame?
« Reply #1 on: November 12, 2014, 10:47:44 am »
No, it doesn't. That's what it's meant for. However, if you are using it, you have to take care of context changes (pause/resume and similar stuff) and set it again in that case.

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Does setStaticUniform upload GPU every frame?
« Reply #2 on: November 13, 2014, 02:23:43 am »
Do you mean we have to use setStaticUniform on context change? Does setStaticUniform upload to GPU directly or it will upload again automatically during rendering after I use the method on context change?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Does setStaticUniform upload GPU every frame?
« Reply #3 on: November 13, 2014, 08:54:40 am »
It uploads during the first render pass. And yes, you have to re-apply the setters after a context change. That's why i actually don't use it anymore myself.

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Does setStaticUniform upload GPU every frame?
« Reply #4 on: November 13, 2014, 11:27:18 am »
Thanks egon. I guess i'll have to set it on every context change

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Does setStaticUniform upload GPU every frame?
« Reply #5 on: November 13, 2014, 03:32:03 pm »
Hi egon,

How about vertex attributes? Is it doable if we have it static and only upload to GPU once?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Does setStaticUniform upload GPU every frame?
« Reply #6 on: November 13, 2014, 03:38:28 pm »
No, those are different. The only 'upload' here is a pointer to a buffer and each attribute from that buffer will be injected into the vertex shader for the corresponding vertex. That's the basic idea of a vertex shader. You can't prevent it and it wouldn't make any sense, because it would leave the vertex shader without data.