On Tue, Nov 22, 2016 at 2:00 AM, Matteo Bruni matteo.mystral@gmail.com wrote:
Would it make sense to always generate a shader epilogue for shader model <= 3, and handle the RET instruction in a special way for shader model >= 4?
Notice that the RET instruction is also used for returning from subroutines. Now, I don't know that anyone has ever used subroutines in d3d shaders (especially for SM <= 3) but probably the correct thing to do is to only generate an additional shader epilogue for RETs called from the main function. That means keeping track of whether we are in the main shader or in a subroutine (maybe by extending / renaming struct wined3d_shader_loop_state) and only generating the epilogue for RETs called from the main shader.
Yeah, but generating a shader epilogue always in shader_glsl_generate_pshader() and shader_glsl_generate_vshader(), i.e. the current behavior should work fine for shader model <= 3. We will probably need to revisit this code when implementing tessellation shaders or SM4 subroutines.