Hello,
When I run my pixelshader in the main thread, it works fine, but when I run it in a separate thread created by love.thread.newThread() it crashes with this message: "Your GPU does not support shaders". (or something like that)
I enabled the love.graphics module.
Any ideas?
Can threads use shaders?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Luke100000
- Party member
- Posts: 232
- Joined: Mon Jul 22, 2013 9:17 am
- Location: Austria
- Contact:
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Can threads use shaders?
love.graphics can only be used in the main thread (the [wiki]love.thread[/wiki] wiki page mentions this as well).
"Using" a shader in a different thread wouldn't do much anyway, since shaders are actually bits of code that are run on your GPU, not your CPU.
"Using" a shader in a different thread wouldn't do much anyway, since shaders are actually bits of code that are run on your GPU, not your CPU.
- Luke100000
- Party member
- Posts: 232
- Joined: Mon Jul 22, 2013 9:17 am
- Location: Austria
- Contact:
Re: Can threads use shaders?
Well, my plan was to render a texture. Since this would not draw the texture direct on the screen it should go (I think). About half of the time my code needs to load, prepare and save the texture. I wanted to short this time by using threads and in addition the main thread should not lag to much.slime wrote:love.graphics can only be used in the main thread (the [wiki]love.thread[/wiki] wiki page mentions this as well).
"Using" a shader in a different thread wouldn't do much anyway, since shaders are actually bits of code that are run on your GPU, not your CPU.
Re: Can threads use shaders?
I'm going to throw a related question in here.
Is it possible to just load a shader in another thread? I assume no.
It's annoying that making all my lg.newShader() and lg.newCanvas() freezes my game for a bit, and I can't put it into my load thread
Is it possible to just load a shader in another thread? I assume no.
It's annoying that making all my lg.newShader() and lg.newCanvas() freezes my game for a bit, and I can't put it into my load thread
butts
- Luke100000
- Party member
- Posts: 232
- Joined: Mon Jul 22, 2013 9:17 am
- Location: Austria
- Contact:
Re: Can threads use shaders?
farzher wrote:I'm going to throw a related question in here.
Is it possible to just load a shader in another thread? I assume no.
It's annoying that making all my lg.newShader() and lg.newCanvas() freezes my game for a bit, and I can't put it into my load thread
nope, I was totally wrong, switched it with love.image
Last edited by Luke100000 on Tue Mar 01, 2016 8:24 pm, edited 1 time in total.
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Can threads use shaders?
You cannot do any love.graphics operation or use any love.graphics class in any thread other than the main one. love will hard-crash... or worse, if you try.
The big warning on the [wiki]love.thread[/wiki] wiki page is there for a reason!
The big warning on the [wiki]love.thread[/wiki] wiki page is there for a reason!
Re: Can threads use shaders?
What do you mean by "about half the time"? If you mean "about every other frame", then it sounds like you need to really need to rethink your rendering structure, to make it faster. There isn't much point in rendering stuff to textures if their contents change often.Luke100000 wrote:Well, my plan was to render a texture. Since this would not draw the texture direct on the screen it should go (I think). About half of the time my code needs to load, prepare and save the texture. I wanted to short this time by using threads and in addition the main thread should not lag to much.slime wrote:love.graphics can only be used in the main thread (the [wiki]love.thread[/wiki] wiki page mentions this as well).
"Using" a shader in a different thread wouldn't do much anyway, since shaders are actually bits of code that are run on your GPU, not your CPU.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
- Luke100000
- Party member
- Posts: 232
- Joined: Mon Jul 22, 2013 9:17 am
- Location: Austria
- Contact:
Re: Can threads use shaders?
I'm working on a library for my game which renders textures, you can download my program here: Simple click the button left bottom, put a random small image (64*64px) into the folder and press 'pixel'T-Bone wrote:What do you mean by "about half the time"? If you mean "about every other frame", then it sounds like you need to really need to rethink your rendering structure, to make it faster. There isn't much point in rendering stuff to textures if their contents change often.Luke100000 wrote:Well, my plan was to render a texture. Since this would not draw the texture direct on the screen it should go (I think). About half of the time my code needs to load, prepare and save the texture. I wanted to short this time by using threads and in addition the main thread should not lag to much.slime wrote:love.graphics can only be used in the main thread (the [wiki]love.thread[/wiki] wiki page mentions this as well).
"Using" a shader in a different thread wouldn't do much anyway, since shaders are actually bits of code that are run on your GPU, not your CPU.
Because this can run in the background, it should be threaded.
AH I found my issues, I meant love.image, not the graphics module.You cannot do any love.graphics operation or use any love.graphics class in any thread other than the main one. love will hard-crash... or worse, if you try.
trAInsported uses this methode I think.
Re: Can threads use shaders?
I can't test your game right now (my computer is currently disconnected from the internet) and I'm having a hard time understand exactly what you're trying to achieve... But the only way I know of to make images in the background is by manually setting pixel values to ImageData. That allows you to implement shader-like code (in Lua) that runs on the background. It's typically very slow.
I also don't understand this sentence:
"Because this can run in the background, it should be threaded." Just because something can run in the background doesn't necessarily mean it should. It might be that you can make it fast enough by utilizing the GPU (which in turn does run things "in the background", in a way). So even though the GPU can only be accessed from the main thread, it could still be faster than running stuff from a background thread (or not, it totally depends on what you're trying to do).
I also don't understand this sentence:
"Because this can run in the background, it should be threaded." Just because something can run in the background doesn't necessarily mean it should. It might be that you can make it fast enough by utilizing the GPU (which in turn does run things "in the background", in a way). So even though the GPU can only be accessed from the main thread, it could still be faster than running stuff from a background thread (or not, it totally depends on what you're trying to do).
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Who is online
Users browsing this forum: Google [Bot] and 6 guests