[Mesa-dev] [PATCH 4/4] radeonsi: Enable VGPR spilling for all shader types

Michel Dänzer michel at daenzer.net
Thu Jan 8 18:52:38 PST 2015


On 09.01.2015 04:41, Tom Stellard wrote:
> On Thu, Jan 08, 2015 at 07:51:58PM +0100, Marek Olšák wrote:
>> On Thu, Jan 8, 2015 at 7:17 PM, Tom Stellard <tom at stellard.net> wrote:
>>> On Thu, Jan 08, 2015 at 07:00:11PM +0100, Marek Olšák wrote:
>>>> On Wed, Jan 7, 2015 at 10:03 PM, Tom Stellard <thomas.stellard at amd.com> wrote:
>>>>>
>>>>> @@ -33,6 +33,22 @@
>>>>>  #include "util/u_memory.h"
>>>>>  #include "util/u_simple_shaders.h"
>>>>>
>>>>> +static void si_shader_setup_scratch_buffer(struct si_shader *shader,
>>>>> +                                       struct si_pm4_state *pm4) {
>>>>> +       if (shader->scratch_bytes_per_wave == 0) {
>>>>> +               return;
>>>>> +       }
>>>>> +
>>>>> +       assert(shader->scratch_bo);
>>>>> +
>>>>> +       si_pm4_set_reg(pm4, R_0286E8_SPI_TMPRING_SIZE,
>>>>> +                       S_0286E8_WAVES(shader->scratch_waves)
>>>>> +                       | S_0286E8_WAVESIZE(shader->scratch_bytes_per_wave >> 10));
>>>>
>>>> What happens if all VS, GS, and PS spill VGPRs? Will they share the
>>>> scratch buffer? Will the scratch buffer be large enough for all of
>>>> them? Will the WAVES and WAVESIZE parameters be the same for all of them?
>>>>
>>>
>>> Each shader will have its own scratch buffer.  WAVES will always be the
>>> same, but WAVESIZE depends on the number of VGPRs spilled.
>>
>> But SPI_TMPRING_SIZE is shared by all stages, right? Will it not cause
>> problems if the register value (especially WAVESIZE) is different for
>> ES, GS, VS, and PS? Perhaps WAVESIZE should be set to a maximum of all
>> enabled shaders, right?
>>
>> Example sequence of state emission:
>> - emit VS regs
>> - emit SPI_TMPRING_SIZE for VS
>> - emit PS regs
>> - emit SPI_TMPRING_SIZE for PS
>>
>> Assuming VS.SPI_TMPRING_SIZE != PS.SPI_TMPRING_SIZE.
>>
> 
> Ok, I see why this is a problem.
> 
> If we use the same WAVESIZE for all shader types, then this means that
> we either need to use the same scratch buffer for all shader types or
> have all the scratch buffers be the same size.
> 
> In a pipeline with VS and PS, do we know that all VS threads will
> complete before any of the PS threads start?

I don't think so.

> If not, I think we will need one scratch buffer per shader type.

Indeed.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the mesa-dev mailing list