opengl-cursed

alright, thread time
333 Replies
TechPizza
TechPizzaOP3y ago
big thonk
No description
Lyris the Kitori
i have no idea what that function is glVertexElementArrayBuffer what also do you know why i have to create a new VAO for each set of buffers
Kai
Kai3y ago
beyley
No description
Kai
Kai3y ago
what the fuck
Lyris the Kitori
how else do i detect ogl version
TechPizza
TechPizzaOP3y ago
you create a gl context and get the version :)
Lyris the Kitori
this information is true but the driver lies
Kai
Kai3y ago
that was the issue
No description
Kai
Kai3y ago
I swear
Lyris the Kitori
bruhhhhhhhhhhhhh
Kai
Kai3y ago
at least do it in another process just put it in another process easy done
TechPizza
TechPizzaOP3y ago
how does it lie exactly?
Lyris the Kitori
ive dealt with old intel drivers that claim 3.2 support but dont actually let you create a context higher than 2.1 its a PITA so i just try EVERY opengl version
TechPizza
TechPizzaOP3y ago
how does that even work
Lyris the Kitori
the opengl string says its 3.2 but fails to create context on higher than 2.1 old vista/7 era drivers are cursed man
TechPizza
TechPizzaOP3y ago
i assume you were requesting a legacy context
Lyris the Kitori
i was requesting a core 3.2 context
Kai
Kai3y ago
renderdoc is very confused
No description
Lyris the Kitori
as am i
Lyris the Kitori
also the colour of that pentagon is still wrong
No description
TechPizza
TechPizzaOP3y ago
then how do you get this string before creating the context...
Kai
Kai3y ago
I think something is giga wrong with the color format
Lyris the Kitori
if i create a 2.1 context it says 3.2 in the string
TechPizza
TechPizzaOP3y ago
wat don't depend on the string then?
Lyris the Kitori
i dont have access to any 3.x functions like VAOs
Kai
Kai3y ago
the red blur that is what I get from the texture
Lyris the Kitori
is there specific function calls to get the ogl version?
King
King3y ago
What you could do is pull a Blizzard with older systems, where they run a compatibility tester that checks everything and auto selects best options based on what the system can handle
Lyris the Kitori
i was just looking at the version string
TechPizza
TechPizzaOP3y ago
yes, in integers
Lyris the Kitori
o well i just did what veldrid did and assumed it was fine which is try every ogl version
TechPizza
TechPizzaOP3y ago
mellinoe certified 💥
Kai
Kai3y ago
I'm suspecting you're doing something wrong with textures
No description
Kai
Kai3y ago
that is the input
Lyris the Kitori
how its fine on both NVidia and Intel textures are RGBA32
TechPizza
TechPizzaOP3y ago
glGetIntegerv(GetPName.MajorVersion, &majorVersion); glGetIntegerv(GetPName.MinorVersion, &minorVersion);
Lyris the Kitori
dont i need a context before i can do that?
TechPizza
TechPizzaOP3y ago
you do
Lyris the Kitori
how would i know what version to use for the context before i run that wont that return the version of the current context
TechPizza
TechPizzaOP3y ago
you request a context with the biggest version
Lyris the Kitori
5.0
TechPizza
TechPizzaOP3y ago
it does
Lyris the Kitori
so i just tell it to do 4.6 then check it? wont the driver just fail to create the context if its too high thats why i do the brute force method i could just shove it over to another process, how would i do that while keeping it in the same main codebase?
Kai
Kai3y ago
pointing out that this fixed(void* ptr = &accessor.GetRowSpan(i).GetPinnableReference()) is cursed and a GC hole, and you should do fixed(void* ptr = accessor.GetRowSpan(i)) instead, which is also easier to read
Lyris the Kitori
oh
Kai
Kai3y ago
GetPinnableReference is just there for the compiler to use when lowering fixed
Lyris the Kitori
ah it should be fine though, it shouldnt cause heavy texture corruption (ill fix the code rq dw) pushed the fix for that specific line i still dont know why the textures are that fucked for you though they shouldnt be unless your card doesnt support RGBA32 textures which would be silly
Kai
Kai3y ago
actually pinning the span has improved it somewhat
No description
Lyris the Kitori
how okay uhh im updating textures row by row it should be impossible for the data to be in the texture like that i can see a semblance of the texture
Kai
Kai3y ago
can you send the original texture?
Kai
Kai3y ago
For example, if the format​ is GL_RGB, and the type​ is GL_UNSIGNED_BYTE, and the width​ is 9, then each row is 27 bytes long. If the alignment is 8, this means that the second row begins 32 bytes after the first. If the alignment is 1, then the second row begins 27 bytes after the first row.
probably this?
Lyris the Kitori
what how can i tell it to not be aligned at all and just let me upload the darn data
Kai
Kai3y ago
something changed
No description
Lyris the Kitori
how tf also still very weird that the vertex colours are different for you which driver is at fault here mine or yours it should be a really colourful pentagon not 2 colours blended
Kai
Kai3y ago
I think in general AMD drivers are just more strict not really worse just more strict
Lyris the Kitori
but im following spec i think
Kai
Kai3y ago
so my driver is at "fault"
Lyris the Kitori
i dont see how a basic set of tris with vertex colours wouldnt be following spec
Kai
Kai3y ago
but nvidia is likely doing things not explicitly said in the spec I mean you also have the same texture bound 31 times so I'm assuming the code is still a bit buggy
Lyris the Kitori
different textures same data it's just for testing
TechPizza
TechPizzaOP3y ago
i'm not sure if the glsl version you're using is compatible with the newest opengl
Lyris the Kitori
oh that might actually be it
TechPizza
TechPizzaOP3y ago
so the AMD drivers acts very mature and corrects you :)
Lyris the Kitori
an error message would be appreciated
Kai
Kai3y ago
is this art?
No description
Lyris the Kitori
maybe save it in high quality i want that as a background
TechPizza
TechPizzaOP3y ago
god why is opengl such a moron you need to set context version before you create a window why does a window even need to know an opengl version angryturtle
Lyris the Kitori
nightmare
King
King3y ago
Reminds me of my childhood days turning the tv onto the SNES channel before turning on the console Nostalgic
Lyris the Kitori
thx
Lyris the Kitori
the art of graphics programming
No description
Kai
Kai3y ago
is there an easy way to make the engine not use Tex0 anymore? like for rendering object?
Kai
Kai3y ago
maybe the AMD driver isn't quite done yet
Lyris the Kitori
make it always use tex1+ only?
Kai
Kai3y ago
and it's still loading images by writing them to tex0 yes
Lyris the Kitori
uhh just tell it to start binding from tex1 in Draw
Kai
Kai3y ago
but then objects that were supposed to use tex0 fail?
Lyris the Kitori
o righ8 in get texture id make it return +1 then start binding from tex1
Kai
Kai3y ago
both of those or only one?
Lyris the Kitori
both
Kai
Kai3y ago
so I make it return + 1 and in draw I start the loop +1
Lyris the Kitori
ugh i cant upload screenshots again for no reason omg discord PLEASE
public override int GetTextureId(VixieTexture tex) {
if (tex is not VixieTextureGL texGl)
throw new InvalidOperationException($"You must pass a {typeof(VixieTextureGL)} into this function!");

if (texGl.BoundId != -1)
return texGl.BoundId;

texGl.BoundId = this._usedTextures;

this._texHandles[this._usedTextures] = texGl;

this._usedTextures++;

if (this._usedTextures >= this._backend.QueryMaxTextureUnits() - 1) {
this.DumpToBuffers();
return this.GetTextureId(tex);
}

return this._usedTextures - 1 + 1;
}
public override int GetTextureId(VixieTexture tex) {
if (tex is not VixieTextureGL texGl)
throw new InvalidOperationException($"You must pass a {typeof(VixieTextureGL)} into this function!");

if (texGl.BoundId != -1)
return texGl.BoundId;

texGl.BoundId = this._usedTextures;

this._texHandles[this._usedTextures] = texGl;

this._usedTextures++;

if (this._usedTextures >= this._backend.QueryMaxTextureUnits() - 1) {
this.DumpToBuffers();
return this.GetTextureId(tex);
}

return this._usedTextures - 1 + 1;
}
change the function to this
Kai
Kai3y ago
I don't think that worked
Lyris the Kitori
for (int i2 = 0; i2 < buf.UsedTextures; i2++) {
VixieTextureGL tex = buf.TexArray[i2];

tex.Bind(TextureUnit.Texture1 + i2);
}
for (int i2 = 0; i2 < buf.UsedTextures; i2++) {
VixieTextureGL tex = buf.TexArray[i2];

tex.Bind(TextureUnit.Texture1 + i2);
}
then do that that should be the exact same but starting from texunit 1
Kai
Kai3y ago
ok 1 sec
King
King3y ago
Toss them on imgur temporarily and just link here I guess
Kai
Kai3y ago
Lmao
No description
Lyris the Kitori
i just uploaded the code itself in a codeblock lmaoo same weird that the top left vert is the wrong tex im going to try upping the GLSL version
Kai
Kai3y ago
I mean that looks like the texture is loaded correctly
Lyris the Kitori
yup
Kai
Kai3y ago
it's just renderdoc pissing itself about the format
Lyris the Kitori
lmao in the OpenGL project go to the shaders folder, then change the GLSL version to 410 or 450 or smthn for both vertex and fragment its possible 140 is not liked by your driver if so ill just write some code to convert between the shader versions at runtime im already gonna have to do it for GL2.0 anyway
Kai
Kai3y ago
it looks different every time I have no idea what's going on
Lyris the Kitori
looks like renderdoc is pulling uninitialized ram for no reason
Kai
Kai3y ago
no I don't think so I think oh
Redhacker2
Redhacker23y ago
The fuck is going on there
Lyris the Kitori
tex coords
Redhacker2
Redhacker23y ago
Because OpenGL loading is window dependent IIRC But the upper left triangle
Lyris the Kitori
idk probably a different texture
Redhacker2
Redhacker23y ago
It is two colors blended, then the test are your texgyre How the fuck is it using two different textures in a draw call without him fucking something up royally Or you
Lyris the Kitori
what you can easily use many textures in a single draw call
Kai
Kai3y ago
I just removed like everything
Kai
Kai3y ago
shader is now only
No description
Redhacker2
Redhacker23y ago
Yes, but not just arbitrary pick which one per triangle without modification
Kai
Kai3y ago
and
No description
Lyris the Kitori
texture is per tri yes
Kai
Kai3y ago
and it still doesn't work
Redhacker2
Redhacker23y ago
You use a texture per tri?
Lyris the Kitori
i am in pain this makes no sense
TechPizza
TechPizzaOP3y ago
yes i have realized, but i shall not accept it
Kai
Kai3y ago
AHA!
No description
Kai
Kai3y ago
It kinda works now
Redhacker2
Redhacker23y ago
It's dumb
Lyris the Kitori
thats kinda better
Kai
Kai3y ago
that's expected result
Lyris the Kitori
i can see the outlines of the cirnodons
TechPizza
TechPizzaOP3y ago
what is tex_8
Lyris the Kitori
the 9th texture slot
TechPizza
TechPizzaOP3y ago
i don't think gpus like this nonuniform access...
Lyris the Kitori
shhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh its opengl it can do whatever it wants
TechPizza
TechPizzaOP3y ago
it would explain why AMD dies but nvidia doesn't
Redhacker2
Redhacker23y ago
You should try it on Mesa
Lyris the Kitori
ok
TechPizza
TechPizzaOP3y ago
i think it's architecture dependent...
Redhacker2
Redhacker23y ago
Mesa is super strict
Lyris the Kitori
building the latest build then ill slap on mesa software rendering with __GLX_VENDOR_LIBRARY_NAME=mesa LIBGL_ALWAYS_SOFTWARE=1 MESA_GLSL_VERSION_OVERRIDE=450 MESA_GL_VERSION_OVERRIDE=4.5 MESA_DEBUG=1 environment vars
TechPizza
TechPizzaOP3y ago
oh right i forgot you can do software rendering
Kai
Kai3y ago
more progress
No description
Redhacker2
Redhacker23y ago
There is a reason a lot of MC shaders don't run on Mesa
Lyris the Kitori
mesa isnt drawing imgui now for some reason what
Kai
Kai3y ago
so texture loading just doesn't work but everything else kinda does
Lyris the Kitori
oh there it goes it just took a sec
Lyris the Kitori
mesa is kinda happy
No description
Lyris the Kitori
not perfect tho
Kai
Kai3y ago
I just set the texture id
Lyris the Kitori
with a small change: mesa works perfectly
No description
Lyris the Kitori
(i reverted the 'start from tex unit 1' patch) dont be fooled its not running at 300fps its running at 5spf well 'perfectly' meaning its not completely broken, just like nvidia and intel, the draw order is still a little fucked but thats probably some off by 1 logic somewhere
Kai
Kai3y ago
I gotta go for now
TechPizza
TechPizzaOP3y ago
i can't be bothered with more opengl today
Lyris the Kitori
it hurts this is my current draw function
public override void Draw() {
this._shader.Bind();
this._shader.SetUniform("ProjectionMatrix", this._backend.ProjectionMatrix);

for (int i = 0; i < this._bufferList.Count; i++) {
BufferData buf = this._bufferList[i];
buf.Vao.Bind();

buf.Vtx.Bind();
buf.Idx.Bind();

buf.Texture.Bind();

this._gl.DrawElements(PrimitiveType.Triangles, buf.IndexCount, DrawElementsType.UnsignedShort, null);

buf.Idx.Unbind();
buf.Vtx.Unbind();

buf.Vao.Unbind();
}

this._shader.Unbind();
}
public override void Draw() {
this._shader.Bind();
this._shader.SetUniform("ProjectionMatrix", this._backend.ProjectionMatrix);

for (int i = 0; i < this._bufferList.Count; i++) {
BufferData buf = this._bufferList[i];
buf.Vao.Bind();

buf.Vtx.Bind();
buf.Idx.Bind();

buf.Texture.Bind();

this._gl.DrawElements(PrimitiveType.Triangles, buf.IndexCount, DrawElementsType.UnsignedShort, null);

buf.Idx.Unbind();
buf.Vtx.Unbind();

buf.Vao.Unbind();
}

this._shader.Unbind();
}
TechPizza
TechPizzaOP3y ago
although fun fact: my voxel engine has the same performance in all backends i optimized the opengl backend to hell and back
Lyris the Kitori
niice
TechPizza
TechPizzaOP3y ago
oh at least the program isn't re-bound every draw
Lyris the Kitori
ye
TechPizza
TechPizzaOP3y ago
also the unbinding of buffers does make it a good bit slower probably
Lyris the Kitori
oh right i probably dont need to do that just wanted to keep the state clean
TechPizza
TechPizzaOP3y ago
maybe make Unbind calls debug-only? a valid program should not need to ever unbind :P
Lyris the Kitori
that seems reasonable
Lyris the Kitori
tf
No description
TechPizza
TechPizzaOP3y ago
not worrying at all
Lyris the Kitori
oop i found the issue im reserving the data before i know whether i need to create a new buffer for a new texture i think i can solve that by making you pass in a texture for 'reserve' too then it returns your tex id with it yeah thatll work
TechPizza
TechPizzaOP3y ago
:p
Lyris the Kitori
there we go its fixed
No description
Lyris the Kitori
now we can see what carnage the 2k quad test does solid 23fps hmmm renderdoc claims 23fps too all 2k quads is done in 3 draw calls 3 draw calls including the pentagon 2 excluding the pentagon not having a debugger attached and disabling unbind still only nets me exactly 23fps now i just gotta figure out how to not have to create new vertex array objects for each buffer yeah only the last buffer draws if i just have a single VAO okay yeah the buffer for elements 0 1 and 2 is getting reset by the last buffer to be created cus the vertexattribcalls hmmmm i have no idea how to solve that lol
TechPizza
TechPizzaOP3y ago
ok so a VAO holds refs to vertex and index buffers and you need to enable each array element or the gpu wont read the value how quirky
Lyris the Kitori
whats happening is that the vao's buffer is being changed to the last one so im basically just drawing the last buffer over and over and over can i just not use a vao :^) i can send a renderdoc capture if you want
TechPizza
TechPizzaOP3y ago
veldrid doesnt :p
Lyris the Kitori
oh neat how would i go about not using one cus i just wanna bind the vertex buffer and have it use it
Lyris the Kitori
i tried just commenting out all the vao code and what invalidoperation on unbind
No description
TechPizza
TechPizzaOP3y ago
oh god you need vaos in the core profile veldrid uses a single global vao yikes opengl is so terrible
Lyris the Kitori
damnit to be able to do this id need to rerun my vertex attrib ptr calls every draw for every buffer id bind the global vao, bind the vtx buffer, run the vertexarribptr, then draw i dont know if thats better than just having separate vaos
TechPizza
TechPizzaOP3y ago
well, your batcher is currently disposing the vao every frame so :p no sorry
Lyris the Kitori
disposing the vao every begin not every frame
TechPizza
TechPizzaOP3y ago
every rebuild
Lyris the Kitori
ye its still bad i know ill fix it eventually
TechPizza
TechPizzaOP3y ago
i still dont understand the horrible fps though
Lyris the Kitori
it doesnt make sense to me either
TechPizza
TechPizzaOP3y ago
i profiled it and most 95% of the time was spent in silk windowing
Lyris the Kitori
i just pushed the single texture stuff rn pull that
TechPizza
TechPizzaOP3y ago
which i expect was the automatic swapbuffers
Lyris the Kitori
its 1fps faster than multitexture draw 1 22 -> 23
TechPizza
TechPizzaOP3y ago
i will test it in 30min (entering shower rn)
Lyris the Kitori
cool sounds good i got chemistry class now anyway :^)
Lyris the Kitori
is what my profile shows (make sure to limit the view to the main thread)
TechPizza
TechPizzaOP3y ago
dear lord how long are you in school
Lyris the Kitori
for another 2.5 hours
TechPizza
TechPizzaOP3y ago
beuh
Lyris the Kitori
i get to school at 8:30, leave at 15:40
TechPizza
TechPizzaOP3y ago
i just had a shower thought it's probably silk autoswapping way more than you necessary and your fps counter doesnt count the swaps
Lyris the Kitori
i mean renderdoc also claims the same fps counter 23
TechPizza
TechPizzaOP3y ago
hmm right but theres like no way that your app takes that much gpu and cpu
Lyris the Kitori
yeah it just doesnt make any god damn sense im so confused
TechPizza
TechPizzaOP3y ago
what happens if you turn on vsync
Lyris the Kitori
its actually only using 12% of my CPU lemme try vsync
TechPizza
TechPizzaOP3y ago
it maxed a core for me and 100% gpu as well and i have worse hardware so
Lyris the Kitori
vsync causes no change
TechPizza
TechPizzaOP3y ago
:|
Lyris the Kitori
like it caps the fps but it doesnt help the problem 2k quads with basic instancing and multitexture is 83fps but i really wanna support arbitrary meshes
TechPizza
TechPizzaOP3y ago
dont worry we'll figure it out
Lyris the Kitori
coolcool
Lyris the Kitori
this should be way faster is there any opengl state thing that i should set? cus i do set cull face mode but i dont know what else i should set
Alexx
Alexx3y ago
i took a look aswell and didn't find anything unusual, and im pretty sure the low fps is just due to the fact you are drawing 2000 large quads stacked on top of each other with overdraw, massive fragment fill rate abuse
TechPizza
TechPizzaOP3y ago
yup, i feel silly for not mentioning it earlier creating sprites at scale 0.01f and now i have 700fps it was all from the bloody overdraw a million quads at 170fps with batch size 1024, good shit 1M quads at 180fps with batch size 64K it can rebuild 100K quads every frame, very cpu bound
Lyris the Kitori
oh
TechPizza
TechPizzaOP3y ago
@baebey ok you have to start reusing buffers
No description
TechPizza
TechPizzaOP3y ago
opengl shits itself
Lyris the Kitori
lmao yea i'll do that once i'm in a class i can use my laptop in
TechPizza
TechPizzaOP3y ago
//TODO: make VAOs optional (for pre GL3.0)
and this todo is a step backwards
Lyris the Kitori
i'm in math class rn lol ?
TechPizza
TechPizzaOP3y ago
using VAO everywhere should in theory be simpler instead of creating two different paths
Lyris the Kitori
no vaos in 2.0 so i don't got a choice
TechPizza
TechPizzaOP3y ago
oh ok pain
Lyris the Kitori
it should hopefully be easy i think in Begin() i'll grab all the buffers that were used and drop them into a list, then grab them out of the list when needed, and allocate more once the list is empty should be ez
TechPizza
TechPizzaOP3y ago
sounds good to me
Lyris the Kitori
actually the list should be static so multiple renderers can use the list
TechPizza
TechPizzaOP3y ago
:|
Lyris the Kitori
why :/ i'll do a count of how many renderers there are and make sure that it gets disposed when all are gone
TechPizza
TechPizzaOP3y ago
i just don't like any static data, you can do whatever
Lyris the Kitori
ah ittl mean possibly less buffers used which is a plus
Kai
Kai3y ago
No static data = easy recreation and unit testing 👀
Lyris the Kitori
with how i'm going to track it easy recreation will still be just as easy, cus you need to dispose all renderers anyway to recreate i scaled the cirnodons down to 0.05f scale 4000 fps 2k quads 1.3k fps if i regenerate the thing every frame, (with buffer saving) so i reuse buffers now
TechPizza
TechPizzaOP3y ago
if you want more rebuild speed you can easily just reserve more at once, it's a great system 👌 the only problematic scenario is requesting more than the max batch size
Lyris the Kitori
i just did this and am going to let later me deal with it https://i.beyleyisnot.moe/HwBnhFc.png
TechPizza
TechPizzaOP3y ago
better than nothing
Lyris the Kitori
the max buffer size is enough to fit 1024 quads so thats 4096(?) verts and 1024*6 indices which should be more than enough for most cases
TechPizza
TechPizzaOP3y ago
try not making it too big in your current setup because you create a new buffer per texture right?
Lyris the Kitori
unfortanately so yea i should drop it to 256 quads in that case yea thats still a LOT of verts and indices and not too big to cause problems okay now that OpenGL p much 'just works' time to do veldrid
Lyris the Kitori
look at me using fancy bitmasking https://i.beyleyisnot.moe/3W2Z5Xw.png
Lyris the Kitori
this is to ensure usage is only indexbuffer or vertexbuffer
TechPizza
TechPizzaOP3y ago
veldrid checks that already :-p
Lyris the Kitori
for just normal CreateBuffer?
TechPizza
TechPizzaOP3y ago
i dont see why you couldnt support more usage types is it time to make a veldrid-cursed thread when
Lyris the Kitori
yes
Kai
Kai3y ago
@baebey update on AMD problems:
Unhandled exception. System.Exception: Failed to Compile shader of type VertexShaderArb, Error Message: ERROR: 0:9: 'location qualifier on output' : not supported for this version or the enabled extensions
ERROR: 1 compilation errors. No code generated.
Unhandled exception. System.Exception: Failed to Compile shader of type VertexShaderArb, Error Message: ERROR: 0:9: 'location qualifier on output' : not supported for this version or the enabled extensions
ERROR: 1 compilation errors. No code generated.
Lyris the Kitori
whwhat
TechPizza
TechPizzaOP3y ago
aren't location qualifiers for outputs only for vulkan?
Lyris the Kitori
are they?
Kai
Kai3y ago
looks like it
Lyris the Kitori
removed the extra qualifiers try pulling now
Kai
Kai3y ago
what's the variable to for GL again:?
Lyris the Kitori
what
Kai
Kai3y ago
the env variable to say it should use GL
Lyris the Kitori
o VIXIE_BACKEND_FORCE=OpenGL
Kai
Kai3y ago
IT WORKS
Lyris the Kitori
wooooooooo wait can you move imgui out of the way so i can see the pentagon
Lyris the Kitori
yup thats correct eyyyy
Kai
Kai3y ago
I mean
Lyris the Kitori
finally
Kai
Kai3y ago
I'm sad its' not SRGB so the pentagon is kinda sad but still
Kai
Kai3y ago
🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉
Lyris the Kitori
replace the test scene file with that
Lyris the Kitori
whats the average perf?
Kai
Kai3y ago
5.8-6.5k frames
Lyris the Kitori
eyyy lets go
Kai
Kai3y ago
also now
Lyris the Kitori
that kicks the ass of our previous instancing code
Kai
Kai3y ago
for the love of god please make this a verification test I'm literally begging you
Lyris the Kitori
a what
Kai
Kai3y ago
you make a unit test and the unit test does 4 things: - setup the scene - render one frame - dump everything to bytes in .png format - call Verify.Accept(yourBytes) and that's it verification test you win then do that, but parameterize it to do it for all backends and you have more testing then 99% of graphics dev
Lyris the Kitori
what unit testing framework i think we use Xunit in the main Furball repo
Kai
Kai3y ago
XUnit + Verify.Xunit
Lyris the Kitori
cool
Lyris the Kitori
that should actually be really easy to do tbh
Kai
Kai3y ago
it really should and it helps sooooo much and with verification tests you can even still look at the file and visually tell whether everything is good just then it's stored and you don't think about it
Lyris the Kitori
ill do that once i get veldrid and dx11 working, as then ill probably have a better idea of a good test scene that tests all aspects
Lyris the Kitori
gl 1.2 :^)
Redhacker2
Redhacker23y ago
What does verify.Accept do? Ahh, that seems a bit finicky IMO
Kai
Kai3y ago
it just writes to a file, and then you rename the file to .accepted.* I use a rider plugin to do the rename Acceptance testing is usually intended to just verify something is still working, so those files rarely change So the finicky / work aspect are tiny compared to the added confidence that something still works
Lyris the Kitori
one thing which will throw a wrench into the plan is that the png encoder in ImageSharp will likely change over time, and also its very very likely that different GPUs will be just a few pixels off when it comes to blending and stuff on different APIs even if it visually is the exact same it might be different when pixel peeping
Kai
Kai3y ago
well in that case you can just make it accept a +-10% image difference or something iirc image sharp even provides that?
Lyris the Kitori
oh in that case its easy
Kai
Kai3y ago
though then you can't use Verify.XUnit easy enough to do yourself though
Lyris the Kitori
yea even if imagesharp doesnt have it then i can just write it myself
TechPizza
TechPizzaOP3y ago
... i don't think you need to worry about PNG because it's a lossless format 🙃
Lyris the Kitori
what i mean is comparing the raw bytes
TechPizza
TechPizzaOP3y ago
but yes, blending on different gpus you should not be comparing raw bytes but colors :
Lyris the Kitori
yeye but kai said raw bytes not colours so thats why i mentioned encoding differences
TechPizza
TechPizzaOP3y ago
maybe use bitmaps then
Lyris the Kitori
maybe
TechPizza
TechPizzaOP3y ago
which won't be good for git history
Lyris the Kitori
but i think itd just be smarter to save it as png, then compare colour by colour
TechPizza
TechPizzaOP3y ago
yeah even monogame does that i think they have a repository submodule for test images so it doesn't clog the main repo
Lyris the Kitori
i think id be fine with a few pngs in the repo that change occiasionally
TechPizza
TechPizzaOP3y ago
it will slow down a lot of git operations so just use a submodule
Lyris the Kitori
o oki
Kai
Kai3y ago
wut how will it slow down git operations @techpizza ?
Lyris the Kitori
probably cus its binary files
Kai
Kai3y ago
that doesn't really inherently slow down git operations I mean, don't render at like 12k obviously
TechPizza
TechPizzaOP3y ago
the pack files grow super large
Kai
Kai3y ago
Only if the binary file is pretty big and changes often Verification tests change never / very rarely & have small files
TechPizza
TechPizzaOP3y ago
¯\_(ツ)_/¯
Lyris the Kitori
this._gl.BindAttribLocation(this._shader.ProgramId, 0, "VertexPosition");
this._gl.BindAttribLocation(this._shader.ProgramId, 1, "TextureCoordinate");
this._gl.BindAttribLocation(this._shader.ProgramId, 2, "VertexColor");
this._gl.BindAttribLocation(this._shader.ProgramId, 3, "TextureId2");
this._gl.BindAttribLocation(this._shader.ProgramId, 4, "TextureId");
this._gl.BindAttribLocation(this._shader.ProgramId, 0, "VertexPosition");
this._gl.BindAttribLocation(this._shader.ProgramId, 1, "TextureCoordinate");
this._gl.BindAttribLocation(this._shader.ProgramId, 2, "VertexColor");
this._gl.BindAttribLocation(this._shader.ProgramId, 3, "TextureId2");
this._gl.BindAttribLocation(this._shader.ProgramId, 4, "TextureId");
thankfully this is a thing so its easy for me to set the attribute location without the layout qualifier
System.Exception: Failed to Compile shader of type VertexShaderArb, Error Message: 0(9) : error C5060: out can't be used with non-varying _Color
0(10) : error C5060: out can't be used with non-varying _TextureCoordinate
0(11) : warning C7022: unrecognized profile specifier "flat"
0(11) : error C0502: syntax error at token "flat"
0(11) : error C5060: out can't be used with non-varying _TextureId
System.Exception: Failed to Compile shader of type VertexShaderArb, Error Message: 0(9) : error C5060: out can't be used with non-varying _Color
0(10) : error C5060: out can't be used with non-varying _TextureCoordinate
0(11) : warning C7022: unrecognized profile specifier "flat"
0(11) : error C0502: syntax error at token "flat"
0(11) : error C5060: out can't be used with non-varying _TextureId
i think i know how i did this shaders successfully ported to GLSL 110 now time to test under mesa gl 2.0 with GLSL 110
Lyris the Kitori
oh so the nvidia compiler LIED to me https://i.beyleyisnot.moe/jdti2cE.png
Lyris the Kitori
can i do a reinterpret cast in GLSL :^) im trying to abuse VertexAttribPointer but its not working the one time i want vertexattribpointer to autocast to float it wont let me IT WORKED YES this is such hard abuse of what it was probably meant for but it works
Lyris the Kitori
@furball.vixie is it good if i create one set of Shaders then reuse that for all the renderers? currently we create a new shader pair for every renderer which can get a little slow when we are doing a lot of renderers and is very memory intensive
Furball
Furball3y ago
that sounds like a very good idea both for speed and vram sake
Lyris the Kitori
cool will do
Furball
Furball3y ago
although idk how much shaders take up in vram
Lyris the Kitori
probably not much, but when we load up on Renderers, it will add up and any improvement is good improvement in my book
Furball
Furball3y ago
when we're targetting machines that could potentially have max 128mb VRAM any save is good
Lyris the Kitori
ye oo i can save 1 gl call per renderer draw if i set the projection matrix only when it changes, then bam ive just saved a single gl call per draw
Furball
Furball3y ago
insane
Lyris the Kitori
hey look ok i get excited about this stuff its fun to optimize like this i like looking at code and using pure brain muscle to save microseconds
Furball
Furball3y ago
i know im trying to play along
Lyris the Kitori
i know i know im joking the double juke
Lyris the Kitori
i just realized we can actually share shaders between multiple backends now cus they are nearly identical its something ill look into
Furball
Furball3y ago
spirv cant target version 100 or 110
Lyris the Kitori
nothing a little search&replace cant fix
Furball
Furball3y ago
nor can it target d3d9 if i recall rorrectly only 9.3
Lyris the Kitori
well yeah but it would be nice to at least have 2 backends sharing shader code just makes upkeeping them that little bit less painful
Furball
Furball3y ago
i think getting this to work would be more painful than having them seperate
Lyris the Kitori
well yeah but itd be fun and we'd get any optimizations the Spir-V compiler does so approximately 0 because its going to GLSL and HLSL down the line anyway btw how did you compile the Vulkan shaders, id like to work on that a little bit since i have the time
Furball
Furball3y ago
when did i compile vulkan shaders
Lyris the Kitori
here
Furball
Furball3y ago
i dont remember ever compiling vulkan shaders
Lyris the Kitori
eh whatever ill just write a script to do it
Furball
Furball3y ago
okay no i do remember cuz the fucking compiler is an actual ape head and cant deal with utf8 and the byte order mark made compilation fail every single time
Lyris the Kitori
oh you can disable the BOM in rider, ive had to do that with the OpenGL backend too
Furball
Furball3y ago
i shouldnt have to but cuz the compiler is stupid sure i guess i did notice that at the bottom it also took me solid 20 minutes to figure out why it didnt want to work it involved me going into a hex editor to see what the hell is happening and googling the bytes i thought 'what are those' google then correctly told me it was the byte order mark in utf8
Lyris the Kitori
rip
glslc HardcodedTriangle/FragmentShader.glsl -o Compiled/HardcodedTriangle/FragmentShader.spv
glslc HardcodedTriangle/VertexShader.glsl -o Compiled/HardcodedTriangle/VertexShader.spv
glslc HardcodedTriangle/FragmentShader.glsl -o Compiled/HardcodedTriangle/FragmentShader.spv
glslc HardcodedTriangle/VertexShader.glsl -o Compiled/HardcodedTriangle/VertexShader.spv
there we go simple script you can even run the script through rider

Did you find this page helpful?