Denis,<br><br>This is a great proposal. I have a few comments and suggestions, though.<br><br>I think the OpenCL state tracker should not be implemented using fragment shaders, framebuffers, and generally the 3D engine as is exposed via pipe_context. It might be useful for some initial experiments, but it&#39;s kinda non-natural, because there is hardware which can do OpenCL and/or CUDA more or less natively. So I think we should come up with a separate set of pipe_context functions for running compute kernels. This will be an advantage for you, because you will be able to design you own Gallium driver functions, assuming you commit to working on the OpenCL state tracker, of course.<br>



<br>Besides reading the OpenCL spec, you might need to take a look at these interfaces when designing the Gallium interface for compute kernels:<br>- DirectCompute and compute shaders (part of DirectX 11)<br>

- CUDA<br>Especially you will need to make sure that the compute subset of DirectX 11 will be implementable (at least in theory).<br><br>I only have experience with CUDA, so here are some ideas on new driver entrypoints that could be added to pipe_context, from the top of my head:<br>



<br>void *create_compute_shader(...); // like shaders<br>void bind_compute_shader(...);<br>void delete_compute_shader(...);<br>// set_constant_buffer can be reused<br>void set_compute_shader_sampler_states(ctx, num, states);<br>





void set_compute_shader_sampler_views(ctx, num, views);<br>

void set_compute_shader_readwrite_resources(ctx, num, resources); // like samplers, but for read-write resources<br>void run_compute_shader(ctx, info);<br>// anything not specific to draw_vbo can be reused too, like transfers, resource_copy_region, etc.<br>



<br>Don&#39;t take the list literally, I haven&#39;t given it much thought.<br><br>Also, I wouldn&#39;t bother with TGSI at the beginning. Let&#39;s stick to the LLVM IR for simplicity and using llvmpipe to execute the compute kernels on a CPU, even that is a lot of work for GSoC. Once it works, we can resolve any remaining issues like what IR will be used etc. The complete OpenCL implementation will take more than a few months, so let&#39;s concentrate on making something work first.<br>

<br>BTW I haven&#39;t taken a look at the clover codebase, so some of my comments might be a little off.<br>

<br>Marek<br><br><br><div class="gmail_quote">On Sat, Mar 26, 2011 at 9:52 PM, Denis Steckelmacher <span dir="ltr">&lt;<a href="mailto:steckdenis@yahoo.fr" target="_blank">steckdenis@yahoo.fr</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">



Hello,<br>
<br>
After some messages on this list, I reconsidered my GSoC proposal and decided<br>
to give a try at an OpenCL state tracker. I will base my work on the Clover<br>
branch of Mesa.<br>
<br>
I read its code, which is very well-done and clean, but I saw one big<br>
difficulty : I don&#39;t know how to translate LLVM IR to TGSI. The big problem is<br>
that TGSI is made mostly with OpenGL in mind. We can use it to decode video<br>
frames using vertex and fragment shader stages, but using it to run on the GPU<br>
the complex output given by LLVM, and without using any part of the OpenGL<br>
pipeline (OpenCL can be used to do mathematics, and that doesn&#39;t draw anything<br>
on the screen), is tricky.<br>
<br>
The problem is how OpenCL can upload data on the GPU and then download the<br>
computed results. One solution may be to create one or more textures<br>
containing the input data (maybe one texture by input data type), and then use<br>
a fragment shader to compute the resulting values and to put them in a render<br>
buffer that will never be drawn on screen but instead downloaded from the GPU<br>
and sent back to the application.<br>
<br>
I don&#39;t know if it would be possible to do things like that, especially<br>
considering that precise results across all graphics cards may be difficult to<br>
get with OpenGL. An other problem of this LLVM to TGSI conversion is that the<br>
TGSI instruction set is not completely implemented on all the pipe drivers,<br>
and that unimplemented instructions may be needed by a specific LLVM IR<br>
instruction.<br>
<br>
I&#39;m open to any suggestion regarding this OpenCL state tracker. If you say it<br>
will be very difficult to do that during the summer, I think I will apply to<br>
work on the OpenGL 3+ support in Mesa (without doing a new state tracker) and<br>
the GLSL compiler.<br>
<br>
Best regards,<br>
<font color="#888888">Denis Steckelmacher.<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></blockquote></div><br>