Skip to content
  • Antía Puentes's avatar
    nir: Fix OpAtomicCounterIDecrement for uniform atomic counters · fbcebfc5
    Antía Puentes authored and Alejandro Piñeiro's avatar Alejandro Piñeiro committed
    
    
    From the SPIR-V 1.0 specification, section 3.32.18, "Atomic
    Instructions":
    
       "OpAtomicIDecrement:
        <skip>
        The instruction's result is the Original Value."
    
    However, we were implementing it, for uniform atomic counters, as a
    pre-decrement operation, as was the one available from GLSL.
    
    Renamed the former nir intrinsic 'atomic_counter_dec*' to
    'atomic_counter_pre_dec*' for clarification purposes, as it implements
    a pre-decrement operation as specified for GLSL. From GLSL 4.50 spec,
    section 8.10, "Atomic Counter Functions":
    
       "uint atomicCounterDecrement (atomic_uint c)
    
        Atomically
        1. decrements the counter for c, and
        2. returns the value resulting from the decrement operation.
    
        These two steps are done atomically with respect to the atomic
        counter functions in this table."
    
    Added a new nir intrinsic 'atomic_counter_post_dec*' which implements
    a post-decrement operation as required by SPIR-V.
    
    v2: (Timothy Arceri)
       * Add extra spec quotes on commit message
       * Use "post" instead "pos" to avoid confusion with "position"
    
    Signed-off-by: default avatarAntia Puentes <apuentes@igalia.com>
    Signed-off-by: default avatarAlejandro Piñeiro <apinheiro@igalia.com>
    
    Reviewed-by: default avatarTimothy Arceri <tarceri@itsqueeze.com>
    fbcebfc5