PDA

View Full Version : About shader over gl3, why and where?



reader1
03-24-2015, 03:50 AM
We create a shader,
SHc = glCreateShader( type); where is the SHc? some doc said it locate at mainboard memory, some say it at display card mem? who is right? ( where SHc points to an area in display card mem).

2] next, we read shader text into mem by textFileRead("..."), then input it into display card mem by glShaderSource( ), Why don't we read it into display card mem directly, cancel the read procedure.

3] then compile and create a program for GPU runs.
Why don't we create the program at very first? them add shaders and compile, link, which may be more suitable to the custom of programming,

reader1
03-24-2015, 04:07 AM
Does this proceduer do more good?
1] generate a gpu program,
2] create shader pointers,
3] read shaders text into VBO diresctly
4] compile and link the program which will be run by GPU.

Alfonse Reinheart
03-24-2015, 06:09 AM
where is the SHc?

Nowhere. It's just a number, an opaque handle that represents the created shader object. Where the implementation allocates the memory for this object is irrelevant to you.


next, we read shader text into mem by textFileRead("..."), then input it into display card mem by glShaderSource( ), Why don't we read it into display card mem directly, cancel the read procedure.

And how exactly would that be of some benefit, when the very next step is to run a CPU-based process (ie: compiling the shader)?


Why don't we create the program at very first?

Because there's no point, since the program object needs compiled shader objects to work. Unless you creating separate programs (https://www.opengl.org/wiki_132/index.php?title=Separate_Program).

reader1
03-24-2015, 06:59 AM
hot to use this multi-quote? like you used that.

reader1
03-24-2015, 07:47 AM
Nowhere. It's just a number, an opaque handle that represents the created shader object. Where the implementation allocates the memory for this object is irrelevant to you.



And how exactly would that be of some benefit, when the very next step is to run a CPU-based process (ie: compiling the shader)?



Because there's no point, since the program object needs compiled shader objects to work. Unless you creating separate programs (https://www.opengl.org/wiki_132/index.php?title=Separate_Program).

most docs say like this. it allocates gc mem just like that os allocate system mem for object. which has nothing to do with programmer. but the name show us a delusion.

the benefit will be reducing coding, and compact. and make design clear, not get error. just like a subprogram running in a mainprog.

Alfonse Reinheart
03-24-2015, 09:36 AM
hot to use this multi-quote? like you used that.

It's text formatting, standard PHP forum markup. I just copy-and-pasted your text into quote blocks that I wrote.

Of course, you'd have to expend more than a couple seconds worth of effort in formulating a reply.


most docs say like this. it allocates gc mem just like that os allocate system mem for object. which has nothing to do with programmer. but the name show us a delusion.

What "most docs"? Show me an example of one that says this.


the benefit will be reducing coding, and compact. and make design clear, not get error. just like a subprogram running in a mainprog.

Except that it would in no way do any of these. First, shaders are not "like a subprogram running in a mainprog", so trying to pretend that they are does not make the design clear. Second, you only "get error" if you do it wrong. Third, the implementation needs to compile your shader. This is a CPU process, not a GPU one, so putting the shader source code into GPU memory is completely worthless.

Fourth, as your posts indicate, you have too minimal of an understanding of the API or graphics hardware to be making suggestions about what would be a better API.

Dark Photon
03-24-2015, 05:05 PM
hot to use this multi-quote? like you used that.

You haven't got a helpful reply on this yet, so I'll help you out. Websearch "bbcode". Example hits (the first from this site):

* https://www.opengl.org/discussion_boards/misc.php?do=bbcode
* https://www.phpbb.com/community/faq.php?mode=bbcode

Search down on each for "quote". For instance:

My quote
Stuff.

More of my quote
More stuff.


would display as:


My quote Stuff.
More of my quote More stuff.


Of course, you can put carriage returns in there where you want for readability. You can also use the quote "toolbar button" in the editing dialog to do this as well, if you can't remember the markup.

By the way, you're asking good questions. Keep reading up on OpenGL and asking probing questions like this, and don't let the attitude of some discourage you. However, these aren't really advanced questions. Consider posting in the Beginner's forum until you're sure you've got your footing and know you're asking an advanced question.

reader1
03-24-2015, 07:01 PM
You haven't got a helpful reply on this yet, so I'll help you out. Websearch "bbcode". Example hits (the first from this site):

* https://www.opengl.org/discussion_boards/misc.php?do=bbcode
* https://www.phpbb.com/community/faq.php?mode=bbcode

Search down on each for "quote". For instance:

Stuff.

More stuff.


would display as:

Stuff. More stuff.


Of course, you can put carriage returns in there where you want for readability. You can also use the quote "toolbar button" in the editing dialog to do this as well, if you can't remember the markup.

By the way, you're asking good questions. Keep reading up on OpenGL and asking probing questions like this, and don't let the attitude of some discourage you. However, these aren't really advanced questions. Consider posting in the Beginner's forum until you're sure you've got your footing and know you're asking an advanced question.

I can use the bbcode. and how to quote a paragraph. however, I think its too trouble to write it one by one, so I just use the toolbar prompt, but don't know how to use that multiquote one by one.
forget it. it's not important for our question.
I don't care what the apitude the reply is. verybody has his own words style. what I want is to get result. the correct result,
Im not lazer , but muany books wrote like a lecture in a class without emphases. often can't get use to it.
What I put the matter here is imagine there may be more skillful specialists to reply and answer.
In fact, beginner question and that of advance have no distinclt gap, I think how to install, get materials is belong to beginner, others may be to advace catalogue.

reader1
03-24-2015, 07:46 PM
It's text formatting, standard PHP forum markup. I just copy-and-pasted your text into quote blocks that I wrote.

Of course, you'd have to expend more than a couple seconds worth of effort in formulating a reply.



What "most docs"? Show me an example of one that says this.



Except that it would in no way do any of these. First, shaders are not "like a subprogram running in a mainprog", so trying to pretend that they are does not make the design clear. Second, you only "get error" if you do it wrong. Third, the implementation needs to compile your shader. This is a CPU process, not a GPU one, so putting the shader source code into GPU memory is completely worthless.

Fourth, as your posts indicate, you have too minimal of an understanding of the API or graphics hardware to be making suggestions about what would be a better API.
control -c and c one by one? too trouble, forget it.
2] but all the books are translated from Eng, they are in Chinese. I have no Eng original book one. the sample is from those books, you may be familiar with them. and know where they are from which books.
3]no, I haven't yet said that the shader is a subprog, just said the prog in glsl looks like a subprog, as it were.
4]I siad as you do, it compliesand then add to the prog. just consern about sequence.
they are compiled and linked in cpu procedure, just run in gpu. as the glsl is a gpu language.
5]you are right to guess that, Im out of gpu hardware and api of gl, despite they have the same style as winapi.
and what is important, havnt' yet found how gopu process these api parallelly.
Can you show me one sample how the gpu(n ora) process tow , three or more sharders sync.?

reader1
03-24-2015, 07:53 PM
or say process vertices sync parallely. for exaple, if the gpu has 12 pipelines, how glsl controls them to process 12 vertices sync?
How to reflect that in gl api?

Alfonse Reinheart
03-24-2015, 10:53 PM
or say process vertices sync parallely. for exaple, if the gpu has 12 pipelines, how glsl controls them to process 12 vertices sync?
How to reflect that in gl api?

It doesn't need to. Just like you don't need to know exactly how your mail gets from one place to another in order to send it. OpenGL removes those details from your consideration. If you render 12 vertices in a draw call, OpenGL will do what it says it will do. Exactly how the GPU farms out vertex shader invocations and so forth is both unimportant and hardware-dependent.

reader1
03-25-2015, 12:03 AM
It doesn't need to. Just like you don't need to know exactly how your mail gets from one place to another in order to send it. OpenGL removes those details from your consideration. If you render 12 vertices in a draw call, OpenGL will do what it says it will do. Exactly how the GPU farms out vertex shader invocations and so forth is both unimportant and hardware-dependent.
No, I dont totlally agree to you at this spot.
Sometimes, Im always curious how many routers the mail pass through. that may be more important form other one who does his work.
just like task schedual, know how opengl operates the paralle running may be useful sometimes.
opengl tells pipeline work routine, but no parallel, how about if we calculate 128, or 360 vertices, but if display card has only 128 pipelines?

Alfonse Reinheart
03-25-2015, 07:38 AM
No, I dont totlally agree to you at this spot.
Sometimes, Im always curious how many routers the mail pass through. that may be more important form other one who does his work.
just like task schedual, know how opengl operates the paralle running may be useful sometimes.
opengl tells pipeline work routine, but no parallel, how about if we calculate 128, or 360 vertices, but if display card has only 128 pipelines?

Then obviously some of those vertices will have to wait to begin their execution. This sort of scheduling is generally handled internally by the GPU.

reader1
03-25-2015, 07:07 PM
Then obviously some of those vertices will have to wait to begin their execution. This sort of scheduling is generally handled internally by the GPU.
you are certainly right. but How does opengl call the instructions is vague.
which api can shed a light on it?

Alfonse Reinheart
03-25-2015, 11:37 PM
you are certainly right. but How does opengl call the instructions is vague.
which api can shed a light on it?

None. No API, not even the upcoming Vulkan or Direct3D 12, is that low-level that it involves explicit details of GPU workload scheduling.

You are talking about specific details about things that vary significantly from hardware to hardware. The question cannot be answered in the general case anymore than I already have: it's handled internally in an implementation-defined manor, typically implemented in GPU scheduling logic, possibly informed by data provided at render-time.

reader1
03-26-2015, 09:20 AM
None. No API, not even the upcoming Vulkan or Direct3D 12, is that low-level that it involves explicit details of GPU workload scheduling.

You are talking about specific details about things that vary significantly from hardware to hardware. The question cannot be answered in the general case anymore than I already have: it's handled internally in an implementation-defined manor, typically implemented in GPU scheduling logic, possibly informed by data provided at render-time.
I don;t like to discuss hardware here. just wish to know how the language works.
well, I seem to forget what question I have asked here. I shall review. lets go back to our right way.