[Mesa-dev] Question regarding cs_gem_write_reloc in radeon_cs_gem.c

Miguel Lopes Santos Ramos org.mesa3d at miguel.ramos.name
Fri Jun 15 06:15:34 PDT 2012


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?


Thank you very much,

--
Miguel Ramos


More information about the mesa-dev mailing list