[Mesa-dev] Question regarding cs_gem_write_reloc in radeon_cs_gem.c
Alex Deucher
alexdeucher at gmail.com
Thu Jun 21 07:07:13 PDT 2012
On Fri, Jun 15, 2012 at 11:16 AM, Miguel Ramos <mail at miguel.ramos.name> wrote:
> 2012/6/15 Marek Olšák <maraeo at gmail.com>:
>> On Fri, Jun 15, 2012 at 3:15 PM, Miguel Lopes Santos Ramos
>> <org.mesa3d at miguel.ramos.name> wrote:
>>> Hi all,
>>>
>>> I'm trying to learn to program radeons in assembly in Linux and
>>> already got help once in this mailing list.
>>>
>>> I'm programming in C++ using the kernel DRM ioctls directly because
>>> libdrm appears to be a thin wrapper around these (for my purpose,
>>> which is using the GPU for computing), but in doing so, I need to
>>> understand what libdrm is doing.
>>>
>>> Now, the cs_gem_write_reloc function, emits two dwords which encode a
>>> relocation and adds information on that relocation to an array which
>>> is passed to the kernel.
>>> The function goes to some length to make sure a single
>>> drm_radeon_cs_reloc structure is passed to the kernel for each buffer
>>> object.
>>>
>>> Now, I'm trying to understand what are the constraints, I don't know
>>> what is the desired behaviour.
>>>
>>> This function begins with:
>>>
>>> if ((read_domain && write_domain) || (!read_domain && !write_domain)) {
>>> /* in one CS a bo can only be in read or write domain but not
>>> * in read & write domain at the same sime
>>> */
>>>
>>> Now, the comment seems to say one thing whereas the if-condition seems
>>> to say the opposite. Am I mistaken? Which is the desired behaviour,
>>> that of the comment or that of the code?
>>>
>>> Then, the code block within if (reloc->handle == bo->handle) { ... }
>>> is even more confusing to me.
>>> For instance, the following line:
>>>
>>> reloc->flags |= (flags & reloc->flags);
>>>
>>> This seems to be a no-op. Anyway, I'm not so worried about these flags
>>> which appear never to be used...
>>> But what are really the constraints for this read_domains and write_domain?
>>
>> I no longer remember how exactly the libdrm CS code works. Radeon
>> gallium drivers don't use it, because it's inefficient and awful.
>>
>> To answer your question: the kernel uses write_domain if it's
>> non-zero, otherwise it uses read_domains. That's it.
>
> Thanks, that is clear.
>
>> The Mesa code that replaces libdrm resides in the Mesa repository in:
>> src/gallium/winsys/radeon/drm/
>
> Hum, yes, it looks better, good formating and I see you are also using
> a hash table.
> I think this is all I need from DRM, now I only need to dig into the registers.
>
> BTW, not that anyone cares, it's not useful, but since I'm reading so
> much code from the people related to this list, for the sake of
> attribution, I'm working here:
> https://github.com/migle/trials/tree/master/radeon
If you just want to play with simple shaders and setting up the 3D
pipeline, radeondemo is an easy place to start:
http://cgit.freedesktop.org/~airlied/radeondemo
Alex
>
> --
> Miguel Ramos <mail at miguel.ramos.name>
> PGP A006A14C
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list