if(get_current_thread_id() == m_main_thread){
return getShaderIdDirect(name);
} else {
- infostream<<"getShaderId(): Queued: name=\""<<name<<"\""<<std::endl;
+ /*errorstream<<"getShaderId(): Queued: name=\""<<name<<"\""<<std::endl;*/
// We're gonna ask the result to be put into here
- ResultQueue<std::string, u32, u8, u8> result_queue;
+
+ static ResultQueue<std::string, u32, u8, u8> result_queue;
// Throw a request in
m_get_shader_queue.add(name, 0, 0, &result_queue);
- infostream<<"Waiting for shader from main thread, name=\""
- <<name<<"\""<<std::endl;
+ /* infostream<<"Waiting for shader from main thread, name=\""
+ <<name<<"\""<<std::endl;*/
try{
- // Wait result for a second
- GetResult<std::string, u32, u8, u8>
+ while(true) {
+ // Wait result for a second
+ GetResult<std::string, u32, u8, u8>
result = result_queue.pop_front(1000);
- // Check that at least something worked OK
- assert(result.key == name);
-
- return result.item;
+ if (result.key == name) {
+ return result.item;
+ }
+ }
}
catch(ItemNotFoundException &e){
- infostream<<"Waiting for shader timed out."<<std::endl;
+ errorstream<<"Waiting for shader " << name << " timed out."<<std::endl;
return 0;
}
}
GetRequest<std::string, u32, u8, u8>
request = m_get_shader_queue.pop();
- /*infostream<<"ShaderSource::processQueue(): "
+ /**errorstream<<"ShaderSource::processQueue(): "
<<"got shader request with "
<<"name=\""<<request.key<<"\""
- <<std::endl;*/
+ <<std::endl;**/
- GetResult<std::string, u32, u8, u8>
- result;
- result.key = request.key;
- result.callers = request.callers;
- result.item = getShaderIdDirect(request.key);
-
- request.dest->push_back(result);
+ m_get_shader_queue.pushResult(request,getShaderIdDirect(request.key));
}
}
setter->onSetConstants(services, is_highlevel);
}
}
-
+
ShaderInfo generate_shader(std::string name, IrrlichtDevice *device,
video::IShaderConstantSetCallBack *callback,
SourceShaderCache *sourcecache)
}
}
- // 0 = off, 1 = assembly shaders only, 2 = highlevel or assembly
bool enable_shaders = g_settings->getBool("enable_shaders");
if(!enable_shaders)
return shaderinfo;
}
}
- if(enable_shaders){
- // Look for assembly shaders
- if(drivertype == video::EDT_DIRECT3D8){
- // Direct3D 8 assembly shaders
- vertex_program = sourcecache->getOrLoad(name, "d3d8_vertex.asm");
- pixel_program = sourcecache->getOrLoad(name, "d3d8_pixel.asm");
- }
- else if(drivertype == video::EDT_DIRECT3D9){
- // Direct3D 9 assembly shaders
- vertex_program = sourcecache->getOrLoad(name, "d3d9_vertex.asm");
- pixel_program = sourcecache->getOrLoad(name, "d3d9_pixel.asm");
- }
- else if(drivertype == video::EDT_OPENGL){
- // OpenGL assembly shaders
- vertex_program = sourcecache->getOrLoad(name, "opengl_vertex.asm");
- pixel_program = sourcecache->getOrLoad(name, "opengl_fragment.asm");
- }
- if(vertex_program != "" || pixel_program != "")
- return;
- }
}