~pixelherodev/c3lib

6b8dff27dba376bd88ada521141630c0dff9e98c — Noam Preil 25 days ago 718f594
add glsl doc
1 files changed, 63 insertions(+), 0 deletions(-)

A design/glsl.roff
A design/glsl.roff => design/glsl.roff +63 -0
@@ 0,0 1,63 @@
.so shared.roff
GLSL AST ideas

.sh
Preliminary design

.pg
Given the following input:

.cd
#version 460 core
out vec4 oColor;
void main()
{
    // set output color to white
    oColor = vec4(1);
}
.ec

.pg
The following AST is produced by the frontend:

.cd
STRUCT{
	DECL{
		"glsl_outputs"
		STRUCT{
			FIELD{
				"oColor"
				VECTOR{
					4
					FLOAT
				}
			}
		}
	}
	EXPORT{
		"c" // C ABI
		"glsl_main" // or some other name
		DECL{
			"main"
			FUNCTION{
				FNTYPE{
					BOOL
					PARAM{
						"glsl_outputs"
						PTR{[[glsl_outputs]]} // pointer to a value whose type is the decl from above
				}
				BLOCK{
					ASSIGNMENT{
						FIELD_LOOKUP{
							IDENT{"glsl_outputs"}
							"oColor"
						}
						
					}
					RETURN{1}
				}
			}
		}
	}
}
.ec