From: Hans de Goede <hdegoede@redhat.com>
To: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: mesa-dev@lists.freedesktop.org, nouveau@lists.freedesktop.org
Subject: Re: [RFC mesa] nouveau: Add support for OpenCL global memory buffers
Date: Mon, 14 Mar 2016 16:28:49 +0100 [thread overview]
Message-ID: <56E6D8B1.60604@redhat.com> (raw)
In-Reply-To: <CAKb7UvgcDxt0_GHr6W5zNvUwEY8FJSSfPD3wEhqr4t-3i5xPLg@mail.gmail.com>
Hi,
On 14-03-16 16:05, Ilia Mirkin wrote:
> There's a less hacky and more hacky way forward. The more hacky solution is
> to set file index to -1 or something and then not do the lowering when you
> see that.
>
> The less hacky solution is the one you proposed as #1 - introduce a new
> file for "buffer" memory and lower it to the global file by adding a base
> offset.
>
> Right now the meaning of global is overloaded - before lowering it
> implicitly includes the buffer vase address, and after lowering, it
> explicitly includes it. Splitting it out I to another file type seems like
> the cleaner way forward, not sure what issue you were seeing with that
> approach.
Ok.
> (I didn't understand your argument about potential future
> issues.)
There was not much to understand, it is just something I worried about,
but was not sure if there actually was something to worry about :)
If you feel that solution #1 (which was also my first hunch) is
the right one then I will go and implement that.
> What I really don't want is to somehow differentiate glsl-sourced
> and opencl-sourced compute programs in the backend.
Ok, understood.
Regards,
Hans
> On Mar 14, 2016 6:22 AM, "Hans de Goede" <hdegoede@redhat.com> wrote:
>
>> This little "hack" fixes the use of OpenCL global memory buffers with
>> nouveau, but clearly the #if 0 is not a solution as it breaks buffers
>> with GLSL.
>>
>> The reason I'm posting this as an RFC patch is to discuss how to solve
>> this properly, 2 solutions come to mind:
>>
>> 1) Use separate nv50_ir::FILE_MEMORY_xxx values for buffers versus
>> TGSI_FILE_MEMORY with TGSI_MEMORY_TYPE_GLOBAL, looking at
>> translateFile()
>> we currently have:
>>
>> case TGSI_FILE_BUFFER: return nv50_ir::FILE_MEMORY_GLOBAL;
>> case TGSI_FILE_MEMORY: return nv50_ir::FILE_MEMORY_GLOBAL;
>>
>> So doing a s/nv50_ir::FILE_MEMORY_GLOBAL/nv50_ir::FILE_MEMORY_BUFFER/
>> everywhere and then adding a new FILE_MEMORY_GLOBAL seems like an
>> obvious fix.
>>
>> But I'm afraid that we will have similar issues with OpenCL using
>> flat addresses where as GLSL will have some implied base-address /
>> offset in other places too, which brings me to solution 2:
>>
>> 2) Add a flag to Program to indicate that it is an OpenCL compute kernel;
>> or possible use a different Program::TYPE_* for OpenCL ?
>>
>> I've a feeling that this is what we want since the addressing models
>> are just different and we likely will need to implement different
>> behavior
>> in various places based on this.
>>
>> This will also allow us to use INPUT and CONST in tgsi code build from
>> OpenCL programs and use that flag to do the right thing, rather then
>> introducing new MEMORY[x], INPUT resp. MEMORY[x], CONST declarations
>> for this.
>>
>> I'm esp. worried that once GLSL gets global support it will want
>> different behavior for TGSI_FILE_MEMORY with TGSI_MEMORY_TYPE_GLOBAL
>> then OpenCL, just like things are now with buffers, rendering solution
>> 1. a non solution
>>
>> So I'm seeking input on how to move forward with this ... ?
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>> src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 4 ++++
>> src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 2 ++
>> 2 files changed, 6 insertions(+)
>>
>> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
>> b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
>> index de0c72b..15012ac 100644
>> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
>> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
>> @@ -1525,6 +1525,10 @@ Converter::makeSym(uint tgsiFile, int fileIdx, int
>> idx, int c, uint32_t address)
>>
>> if (tgsiFile == TGSI_FILE_MEMORY) {
>> switch (code->memoryFiles[fileIdx].mem_type) {
>> + case TGSI_MEMORY_TYPE_GLOBAL:
>> + /* No-op this is the default for TGSI_FILE_MEMORY */
>> + sym->setFile(FILE_MEMORY_GLOBAL);
>> + break;
>> case TGSI_MEMORY_TYPE_SHARED:
>> sym->setFile(FILE_MEMORY_SHARED);
>> break;
>> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
>> b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
>> index 6cb4dd4..bcc96de 100644
>> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
>> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
>> @@ -2106,6 +2106,7 @@ NVC0LoweringPass::visit(Instruction *i)
>> } else if (i->src(0).getFile() == FILE_SHADER_OUTPUT) {
>> assert(prog->getType() == Program::TYPE_TESSELLATION_CONTROL);
>> i->op = OP_VFETCH;
>> +#if 0
>> } else if (i->src(0).getFile() == FILE_MEMORY_GLOBAL) {
>> Value *ind = i->getIndirect(0, 1);
>> Value *ptr = loadResInfo64(ind, i->getSrc(0)->reg.fileIndex *
>> 16);
>> @@ -2126,6 +2127,7 @@ NVC0LoweringPass::visit(Instruction *i)
>> if (i->defExists(0)) {
>> bld.mkMov(i->getDef(0), bld.mkImm(0));
>> }
>> +#endif
>> }
>> break;
>> case OP_ATOM:
>> --
>> 2.7.2
>>
>>
>
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
next prev parent reply other threads:[~2016-03-14 15:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-14 13:22 [RFC mesa] nouveau: Add support for OpenCL global memory buffers Hans de Goede
[not found] ` <1457961752-1461-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-03-14 15:05 ` Ilia Mirkin
2016-03-14 15:28 ` Hans de Goede [this message]
2016-03-14 15:41 ` Samuel Pitoiset
[not found] ` <56E6DBA2.8060605-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-03-14 19:50 ` Hans de Goede
[not found] ` <56E71623.7040201-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-03-14 20:50 ` Samuel Pitoiset
[not found] ` <56E72426.8070606-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-03-17 16:07 ` Hans de Goede
[not found] ` <56EAD653.3000209-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-03-17 16:14 ` Samuel Pitoiset
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56E6D8B1.60604@redhat.com \
--to=hdegoede@redhat.com \
--cc=imirkin@alum.mit.edu \
--cc=mesa-dev@lists.freedesktop.org \
--cc=nouveau@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.