libagx: port to common libcl.h
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32529>
This commit is contained in:
committed by
Marge Bot
parent
a0694fd5c3
commit
d695c84829
@@ -8,100 +8,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "compiler/libcl/libcl.h"
|
||||
#include "util/bitpack_helpers.h"
|
||||
|
||||
#ifndef __OPENCL_VERSION__
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include "util/bitpack_helpers.h"
|
||||
#include "util/half_float.h"
|
||||
#define FILE_TYPE FILE
|
||||
#define CONSTANT_ const
|
||||
#define GLOBAL_
|
||||
#else
|
||||
|
||||
#include "libagx.h"
|
||||
#define assert(x)
|
||||
#define FILE_TYPE void
|
||||
#define CONSTANT_ constant
|
||||
#define GLOBAL_ global
|
||||
#define BITFIELD64_MASK(x) ((x == 64) ? ~0ul : ((1ul << x) - 1))
|
||||
#define IS_POT(v) (((v) & ((v) - 1)) == 0)
|
||||
#define IS_POT_NONZERO(v) ((v) != 0 && IS_POT(v))
|
||||
|
||||
static uint64_t
|
||||
util_bitpack_uint(uint64_t v, uint32_t start, uint32_t end)
|
||||
{
|
||||
return v << start;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
util_bitpack_sint(int64_t v, uint32_t start, uint32_t end)
|
||||
{
|
||||
const int bits = end - start + 1;
|
||||
const uint64_t mask = BITFIELD64_MASK(bits);
|
||||
return (v & mask) << start;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
util_bitpack_float(float v)
|
||||
{
|
||||
union {
|
||||
float f;
|
||||
uint32_t dw;
|
||||
} x;
|
||||
x.f = v;
|
||||
return x.dw;
|
||||
}
|
||||
|
||||
static inline float
|
||||
uif(uint32_t ui)
|
||||
{
|
||||
union {
|
||||
float f;
|
||||
uint32_t dw;
|
||||
} fi;
|
||||
fi.dw = ui;
|
||||
return fi.f;
|
||||
}
|
||||
|
||||
#define DIV_ROUND_UP(A, B) (((A) + (B) - 1) / (B))
|
||||
#define CLAMP(X, MIN, MAX) ((X) > (MIN) ? ((X) > (MAX) ? (MAX) : (X)) : (MIN))
|
||||
#define ALIGN_POT(x, pot_align) (((x) + (pot_align) - 1) & ~((pot_align) - 1))
|
||||
|
||||
static inline unsigned
|
||||
util_logbase2(unsigned n)
|
||||
{
|
||||
return ((sizeof(unsigned) * 8 - 1) - __builtin_clz(n | 1));
|
||||
}
|
||||
|
||||
static inline int64_t
|
||||
util_sign_extend(uint64_t val, unsigned width)
|
||||
{
|
||||
unsigned shift = 64 - width;
|
||||
return (int64_t)(val << shift) >> shift;
|
||||
}
|
||||
|
||||
static inline uint16_t
|
||||
_mesa_float_to_half(float f)
|
||||
{
|
||||
union {
|
||||
half h;
|
||||
uint16_t w;
|
||||
} hi;
|
||||
hi.h = convert_half(f);
|
||||
return hi.w;
|
||||
}
|
||||
|
||||
static inline float
|
||||
_mesa_half_to_float(uint16_t w)
|
||||
{
|
||||
union {
|
||||
half h;
|
||||
uint16_t w;
|
||||
} hi;
|
||||
hi.w = w;
|
||||
return convert_float(hi.h);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define __gen_unpack_float(x, y, z) uif(__gen_unpack_uint(x, y, z))
|
||||
@@ -109,7 +22,7 @@ _mesa_half_to_float(uint16_t w)
|
||||
_mesa_half_to_float(__gen_unpack_uint(x, y, z))
|
||||
|
||||
static inline uint64_t
|
||||
__gen_unpack_uint(CONSTANT_ uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
__gen_unpack_uint(constant uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
{
|
||||
uint64_t val = 0;
|
||||
const int width = end - start + 1;
|
||||
@@ -135,13 +48,13 @@ __gen_pack_lod(float f, uint32_t start, uint32_t end)
|
||||
}
|
||||
|
||||
static inline float
|
||||
__gen_unpack_lod(CONSTANT_ uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
__gen_unpack_lod(constant uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
{
|
||||
return ((float)__gen_unpack_uint(cl, start, end)) / (1 << 6);
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
__gen_unpack_sint(CONSTANT_ uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
__gen_unpack_sint(constant uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
{
|
||||
int size = end - start + 1;
|
||||
int64_t val = __gen_unpack_uint(cl, start, end);
|
||||
@@ -177,16 +90,16 @@ __gen_from_groups(uint32_t value, uint32_t group_size, uint32_t length)
|
||||
|
||||
#define agx_pack(dst, T, name) \
|
||||
for (struct AGX_##T name = {AGX_##T##_header}, \
|
||||
*_loop_count = (GLOBAL_ void *)((uintptr_t)0); \
|
||||
*_loop_count = (global void *)((uintptr_t)0); \
|
||||
(uintptr_t)_loop_count < 1; ( \
|
||||
{ \
|
||||
AGX_##T##_pack((GLOBAL_ uint32_t *)(dst), &name); \
|
||||
_loop_count = (GLOBAL_ void *)(((uintptr_t)_loop_count) + 1); \
|
||||
AGX_##T##_pack((global uint32_t *)(dst), &name); \
|
||||
_loop_count = (global void *)(((uintptr_t)_loop_count) + 1); \
|
||||
}))
|
||||
|
||||
#define agx_unpack(fp, src, T, name) \
|
||||
struct AGX_##T name; \
|
||||
AGX_##T##_unpack(fp, (CONSTANT_ uint8_t *)(src), &name)
|
||||
AGX_##T##_unpack(fp, (constant uint8_t *)(src), &name)
|
||||
|
||||
#define agx_print(fp, T, var, indent) AGX_##T##_print(fp, &(var), indent)
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ class Group(object):
|
||||
convert = None
|
||||
|
||||
args = []
|
||||
args.append('(CONSTANT_ uint32_t *) cl')
|
||||
args.append('(constant uint32_t *) cl')
|
||||
args.append(str(fieldref.start))
|
||||
args.append(str(fieldref.end))
|
||||
|
||||
@@ -573,7 +573,7 @@ class Parser(object):
|
||||
print("};\n")
|
||||
|
||||
def emit_pack_function(self, name, group):
|
||||
print("static inline void\n%s_pack(GLOBAL_ uint32_t * restrict cl,\n%sconst struct %s * restrict values)\n{" %
|
||||
print("static inline void\n%s_pack(global uint32_t * restrict cl,\n%sconst struct %s * restrict values)\n{" %
|
||||
(name, ' ' * (len(name) + 6), name))
|
||||
|
||||
group.emit_pack_function()
|
||||
@@ -590,7 +590,7 @@ class Parser(object):
|
||||
|
||||
def emit_unpack_function(self, name, group):
|
||||
print("static inline bool")
|
||||
print("%s_unpack(FILE_TYPE *fp, CONSTANT_ uint8_t * restrict cl,\n%sstruct %s * restrict values)\n{" %
|
||||
print("%s_unpack(FILE *fp, constant uint8_t * restrict cl,\n%sstruct %s * restrict values)\n{" %
|
||||
(name.upper(), ' ' * (len(name) + 8), name))
|
||||
|
||||
group.emit_unpack_function()
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
* Copyright 2024 Valve Corporation
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include "compiler/libcl/libcl.h"
|
||||
#include "compiler/nir/nir_defines.h"
|
||||
#include "compiler/shader_enums.h"
|
||||
#include "agx_pack.h"
|
||||
#include "compression.h"
|
||||
#include "libagx.h"
|
||||
#include "libagx_intrinsics.h"
|
||||
|
||||
/*
|
||||
* Decompress in place. The metadata is updated, so other processes can read the
|
||||
@@ -38,7 +39,7 @@ index_metadata(uint3 c, uint width, uint height, uint layer_stride)
|
||||
uint major_coord = width > height ? c.x : c.y;
|
||||
uint minor_dim = min(width, height);
|
||||
|
||||
uint intl_bits = libagx_logbase2_ceil(minor_dim);
|
||||
uint intl_bits = util_logbase2_ceil(minor_dim);
|
||||
uint intl_mask = (1 << intl_bits) - 1;
|
||||
uint2 intl_coords = c.xy & intl_mask;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include "agx_pack.h"
|
||||
#include "libagx.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -11,4 +10,4 @@ struct libagx_decompress_images {
|
||||
struct agx_texture_packed compressed;
|
||||
struct agx_pbe_packed uncompressed;
|
||||
};
|
||||
AGX_STATIC_ASSERT(sizeof(struct libagx_decompress_images) == 48);
|
||||
static_assert(sizeof(struct libagx_decompress_images) == 48);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright 2024 Valve Corporation
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include "libagx.h"
|
||||
#include "compiler/libcl/libcl.h"
|
||||
|
||||
/*
|
||||
* To implement drawIndirectCount generically, we dispatch a kernel to
|
||||
|
||||
@@ -5,19 +5,10 @@
|
||||
*/
|
||||
|
||||
#include "geometry.h"
|
||||
#include "libagx_intrinsics.h"
|
||||
#include "query.h"
|
||||
#include "tessellator.h"
|
||||
|
||||
/* Compatible with util/u_math.h */
|
||||
static inline uint
|
||||
util_logbase2_ceil(uint n)
|
||||
{
|
||||
if (n <= 1)
|
||||
return 0;
|
||||
else
|
||||
return 32 - clz(n - 1);
|
||||
}
|
||||
|
||||
/* Swap the two non-provoking vertices third vert in odd triangles. This
|
||||
* generates a vertex ID list with a consistent winding order.
|
||||
*
|
||||
@@ -332,10 +323,11 @@ static uint
|
||||
first_true_thread_in_workgroup(bool cond, local uint *scratch)
|
||||
{
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
scratch[get_sub_group_id()] = nir_ballot(cond);
|
||||
scratch[get_sub_group_id()] = sub_group_ballot(cond)[0];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
uint first_group = ctz(nir_ballot(scratch[get_sub_group_local_id()]));
|
||||
uint first_group =
|
||||
ctz(sub_group_ballot(scratch[get_sub_group_local_id()])[0]);
|
||||
uint off = ctz(first_group < 32 ? scratch[first_group] : 0);
|
||||
return (first_group * 32) + off;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "compiler/libcl/libcl.h"
|
||||
#include "compiler/shader_enums.h"
|
||||
#include "libagx.h"
|
||||
|
||||
#ifndef __OPENCL_VERSION__
|
||||
#include "util/bitscan.h"
|
||||
@@ -30,7 +30,7 @@ struct agx_geometry_state {
|
||||
GLOBAL(uchar) heap;
|
||||
uint32_t heap_bottom, heap_size;
|
||||
} PACKED;
|
||||
AGX_STATIC_ASSERT(sizeof(struct agx_geometry_state) == 4 * 4);
|
||||
static_assert(sizeof(struct agx_geometry_state) == 4 * 4);
|
||||
|
||||
struct agx_ia_state {
|
||||
/* Index buffer if present. */
|
||||
@@ -44,7 +44,7 @@ struct agx_ia_state {
|
||||
*/
|
||||
uint32_t verts_per_instance;
|
||||
} PACKED;
|
||||
AGX_STATIC_ASSERT(sizeof(struct agx_ia_state) == 4 * 4);
|
||||
static_assert(sizeof(struct agx_ia_state) == 4 * 4);
|
||||
|
||||
static inline uint64_t
|
||||
libagx_index_buffer(uint64_t index_buffer, uint size_el, uint offset_el,
|
||||
@@ -139,7 +139,7 @@ struct agx_geometry_params {
|
||||
*/
|
||||
uint32_t input_topology;
|
||||
} PACKED;
|
||||
AGX_STATIC_ASSERT(sizeof(struct agx_geometry_params) == 82 * 4);
|
||||
static_assert(sizeof(struct agx_geometry_params) == 82 * 4);
|
||||
|
||||
/* TCS shared memory layout:
|
||||
*
|
||||
@@ -237,8 +237,8 @@ libagx_tcs_out_stride(uint nr_patch_out, uint out_patch_size,
|
||||
static uint
|
||||
libagx_compact_prim(enum mesa_prim prim)
|
||||
{
|
||||
AGX_STATIC_ASSERT(MESA_PRIM_QUAD_STRIP == MESA_PRIM_QUADS + 1);
|
||||
AGX_STATIC_ASSERT(MESA_PRIM_POLYGON == MESA_PRIM_QUADS + 2);
|
||||
static_assert(MESA_PRIM_QUAD_STRIP == MESA_PRIM_QUADS + 1);
|
||||
static_assert(MESA_PRIM_POLYGON == MESA_PRIM_QUADS + 2);
|
||||
|
||||
#ifndef __OPENCL_VERSION__
|
||||
assert(prim != MESA_PRIM_QUADS);
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
* Copyright 2023 Asahi Lina
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include "compiler/libcl/libcl.h"
|
||||
#include "helper.h"
|
||||
#include "libagx.h"
|
||||
#include "libagx_intrinsics.h"
|
||||
|
||||
#define DB_NEXT 32
|
||||
#define DB_ACK 48
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#ifndef LIBAGX_HELPER_H
|
||||
#define LIBAGX_HELPER_H
|
||||
|
||||
#include "compiler/libcl/libcl.h"
|
||||
#include "agx_pack.h"
|
||||
#include "libagx.h"
|
||||
|
||||
// Enable this to debug core mappings.
|
||||
// #define SCRATCH_DEBUG_CORES 512
|
||||
@@ -26,7 +26,7 @@
|
||||
struct agx_helper_block {
|
||||
uint32_t blocks[4];
|
||||
} PACKED;
|
||||
AGX_STATIC_ASSERT(sizeof(struct agx_helper_block) == 16);
|
||||
static_assert(sizeof(struct agx_helper_block) == 16);
|
||||
|
||||
struct agx_helper_core {
|
||||
GLOBAL(struct agx_helper_block) blocklist;
|
||||
@@ -36,15 +36,15 @@ struct agx_helper_core {
|
||||
uint32_t _pad;
|
||||
uint32_t alloc_count[AGX_SPILL_SIZE_BUCKETS];
|
||||
} PACKED;
|
||||
AGX_STATIC_ASSERT(sizeof(struct agx_helper_core) ==
|
||||
(8 + 3 * 4 + AGX_SPILL_SIZE_BUCKETS * 4 + 4));
|
||||
static_assert(sizeof(struct agx_helper_core) ==
|
||||
(8 + 3 * 4 + AGX_SPILL_SIZE_BUCKETS * 4 + 4));
|
||||
|
||||
struct agx_helper_header {
|
||||
uint32_t subgroups;
|
||||
uint32_t _pad;
|
||||
struct agx_helper_core cores[AGX_MAX_CORE_ID];
|
||||
} PACKED;
|
||||
AGX_STATIC_ASSERT(sizeof(struct agx_helper_header) ==
|
||||
(4 + 4 + AGX_MAX_CORE_ID * sizeof(struct agx_helper_core)));
|
||||
static_assert(sizeof(struct agx_helper_header) ==
|
||||
(4 + 4 + AGX_MAX_CORE_ID * sizeof(struct agx_helper_core)));
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023 Alyssa Rosenzweig
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef LIBAGX_H
|
||||
#define LIBAGX_H
|
||||
|
||||
/* Define stdint types compatible between the CPU and GPU for shared headers */
|
||||
#ifndef __OPENCL_VERSION__
|
||||
#include <stdint.h>
|
||||
#include "util/macros.h"
|
||||
#define GLOBAL(type_) uint64_t
|
||||
#define CONSTANT(type_) uint64_t
|
||||
#define AGX_STATIC_ASSERT(_COND) static_assert(_COND, #_COND)
|
||||
#define global_
|
||||
#define constant_
|
||||
#else
|
||||
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
|
||||
#define PACKED __attribute__((packed, aligned(4)))
|
||||
#define GLOBAL(type_) global type_ *
|
||||
#define CONSTANT(type_) constant type_ *
|
||||
#define global_ global
|
||||
#define constant_ constant
|
||||
#define ASSERTED
|
||||
#define assert(x)
|
||||
#define BITFIELD_BIT(b) (1u << b)
|
||||
#define BITFIELD_MASK(m) (((m) == 32) ? 0xffffffff : ((1u << (m)) - 1))
|
||||
|
||||
typedef ulong uint64_t;
|
||||
typedef uint uint32_t;
|
||||
typedef ushort uint16_t;
|
||||
typedef uchar uint8_t;
|
||||
|
||||
typedef long int64_t;
|
||||
typedef int int32_t;
|
||||
typedef short int16_t;
|
||||
typedef char int8_t;
|
||||
|
||||
/* Define NIR intrinsics for CL */
|
||||
uint32_t nir_interleave_agx(uint16_t x, uint16_t y);
|
||||
void nir_doorbell_agx(uint8_t value);
|
||||
void nir_stack_map_agx(uint16_t index, uint32_t address);
|
||||
uint32_t nir_stack_unmap_agx(uint16_t index);
|
||||
uint32_t nir_load_core_id_agx(void);
|
||||
uint32_t nir_load_helper_op_id_agx(void);
|
||||
uint32_t nir_load_helper_arg_lo_agx(void);
|
||||
uint32_t nir_load_helper_arg_hi_agx(void);
|
||||
void nir_fence_helper_exit_agx(void);
|
||||
|
||||
uint4 nir_bindless_image_load(uint2 handle, int4 coord, uint sample, uint lod,
|
||||
uint image_dim, uint image_array, uint format,
|
||||
uint access, uint dest_type);
|
||||
|
||||
void nir_bindless_image_store(uint2 handle, int4 coord, uint sample,
|
||||
uint4 datum, uint lod, uint image_dim,
|
||||
uint image_array, uint format, uint access,
|
||||
uint src_type);
|
||||
|
||||
/* I have no idea why CL doesn't have this */
|
||||
uint nir_ballot(bool cond);
|
||||
|
||||
#define _S(x) #x
|
||||
#define AGX_PASTE_(x, y) x##y
|
||||
#define AGX_PASTE(x, y) AGX_PASTE_(x, y)
|
||||
#define AGX_STATIC_ASSERT(_COND) \
|
||||
typedef char AGX_PASTE(static_assertion, __LINE__)[(_COND) ? 1 : -1]
|
||||
|
||||
#define KERNEL(x) __attribute__((reqd_work_group_size(x, 1, 1))) kernel void
|
||||
|
||||
static inline uint
|
||||
align(uint x, uint y)
|
||||
{
|
||||
return (x + y - 1) & ~(y - 1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
libagx_logbase2_ceil(uint32_t n)
|
||||
{
|
||||
return (n <= 1) ? 0 : 32 - clz(n - 1);
|
||||
}
|
||||
|
||||
#define offsetof(x, y) __builtin_offsetof(x, y)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -5,24 +5,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "compiler/libcl/libcl.h"
|
||||
#include "agx_pack.h"
|
||||
#include "libagx.h"
|
||||
|
||||
#ifdef __OPENCL_VERSION__
|
||||
#define NDEBUG
|
||||
#define memcpy __builtin_memcpy
|
||||
#define STATIC_ASSERT AGX_STATIC_ASSERT
|
||||
#endif
|
||||
|
||||
#define agx_push(ptr, T, cfg) \
|
||||
for (unsigned _loop = 0; _loop < 1; \
|
||||
++_loop, ptr = (global_ void *)(((uintptr_t)ptr) + AGX_##T##_LENGTH)) \
|
||||
++_loop, ptr = (global void *)(((uintptr_t)ptr) + AGX_##T##_LENGTH)) \
|
||||
agx_pack(ptr, T, cfg)
|
||||
|
||||
#define agx_push_packed(ptr, src, T) \
|
||||
STATIC_ASSERT(sizeof(src) == AGX_##T##_LENGTH); \
|
||||
static_assert(sizeof(src) == AGX_##T##_LENGTH); \
|
||||
memcpy(ptr, &src, sizeof(src)); \
|
||||
ptr = (global_ void *)(((uintptr_t)ptr) + sizeof(src));
|
||||
ptr = (global void *)(((uintptr_t)ptr) + sizeof(src));
|
||||
|
||||
struct agx_workgroup {
|
||||
uint32_t x, y, z;
|
||||
@@ -85,8 +79,8 @@ enum agx_chip {
|
||||
AGX_CHIP_G14X,
|
||||
};
|
||||
|
||||
static inline global_ uint32_t *
|
||||
agx_cdm_launch(global_ uint32_t *out, enum agx_chip chip, struct agx_grid grid,
|
||||
static inline global uint32_t *
|
||||
agx_cdm_launch(global uint32_t *out, enum agx_chip chip, struct agx_grid grid,
|
||||
struct agx_workgroup wg,
|
||||
struct agx_cdm_launch_word_0_packed launch, uint32_t usc)
|
||||
{
|
||||
@@ -134,8 +128,8 @@ agx_cdm_launch(global_ uint32_t *out, enum agx_chip chip, struct agx_grid grid,
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline global_ uint32_t *
|
||||
agx_cdm_barrier(global_ uint32_t *out, enum agx_chip chip)
|
||||
static inline global uint32_t *
|
||||
agx_cdm_barrier(global uint32_t *out, enum agx_chip chip)
|
||||
{
|
||||
agx_push(out, CDM_BARRIER, cfg) {
|
||||
cfg.unk_5 = true;
|
||||
@@ -181,8 +175,8 @@ agx_cdm_barrier(global_ uint32_t *out, enum agx_chip chip)
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline global_ uint32_t *
|
||||
agx_cdm_return(global_ uint32_t *out)
|
||||
static inline global uint32_t *
|
||||
agx_cdm_return(global uint32_t *out)
|
||||
{
|
||||
agx_push(out, CDM_STREAM_RETURN, cfg)
|
||||
;
|
||||
@@ -190,8 +184,8 @@ agx_cdm_return(global_ uint32_t *out)
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline global_ uint32_t *
|
||||
agx_cdm_terminate(global_ uint32_t *out)
|
||||
static inline global uint32_t *
|
||||
agx_cdm_terminate(global uint32_t *out)
|
||||
{
|
||||
agx_push(out, CDM_STREAM_TERMINATE, _)
|
||||
;
|
||||
@@ -199,8 +193,8 @@ agx_cdm_terminate(global_ uint32_t *out)
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline global_ uint32_t *
|
||||
agx_vdm_terminate(global_ uint32_t *out)
|
||||
static inline global uint32_t *
|
||||
agx_vdm_terminate(global uint32_t *out)
|
||||
{
|
||||
agx_push(out, VDM_STREAM_TERMINATE, _)
|
||||
;
|
||||
@@ -208,8 +202,8 @@ agx_vdm_terminate(global_ uint32_t *out)
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline global_ uint32_t *
|
||||
agx_cdm_jump(global_ uint32_t *out, uint64_t target)
|
||||
static inline global uint32_t *
|
||||
agx_cdm_jump(global uint32_t *out, uint64_t target)
|
||||
{
|
||||
agx_push(out, CDM_STREAM_LINK, cfg) {
|
||||
cfg.target_lo = target & BITFIELD_MASK(32);
|
||||
@@ -219,8 +213,8 @@ agx_cdm_jump(global_ uint32_t *out, uint64_t target)
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline global_ uint32_t *
|
||||
agx_vdm_jump(global_ uint32_t *out, uint64_t target)
|
||||
static inline global uint32_t *
|
||||
agx_vdm_jump(global uint32_t *out, uint64_t target)
|
||||
{
|
||||
agx_push(out, VDM_STREAM_LINK, cfg) {
|
||||
cfg.target_lo = target & BITFIELD_MASK(32);
|
||||
@@ -230,14 +224,14 @@ agx_vdm_jump(global_ uint32_t *out, uint64_t target)
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline global_ uint32_t *
|
||||
agx_cs_jump(global_ uint32_t *out, uint64_t target, bool vdm)
|
||||
static inline global uint32_t *
|
||||
agx_cs_jump(global uint32_t *out, uint64_t target, bool vdm)
|
||||
{
|
||||
return vdm ? agx_vdm_jump(out, target) : agx_cdm_jump(out, target);
|
||||
}
|
||||
|
||||
static inline global_ uint32_t *
|
||||
agx_cdm_call(global_ uint32_t *out, uint64_t target)
|
||||
static inline global uint32_t *
|
||||
agx_cdm_call(global uint32_t *out, uint64_t target)
|
||||
{
|
||||
agx_push(out, CDM_STREAM_LINK, cfg) {
|
||||
cfg.target_lo = target & BITFIELD_MASK(32);
|
||||
@@ -248,8 +242,8 @@ agx_cdm_call(global_ uint32_t *out, uint64_t target)
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline global_ uint32_t *
|
||||
agx_vdm_call(global_ uint32_t *out, uint64_t target)
|
||||
static inline global uint32_t *
|
||||
agx_vdm_call(global uint32_t *out, uint64_t target)
|
||||
{
|
||||
agx_push(out, VDM_STREAM_LINK, cfg) {
|
||||
cfg.target_lo = target & BITFIELD_MASK(32);
|
||||
@@ -285,7 +279,7 @@ struct agx_shader {
|
||||
|
||||
/* Opaque structure representing a USC program being constructed */
|
||||
struct agx_usc_builder {
|
||||
global_ uint8_t *head;
|
||||
global uint8_t *head;
|
||||
|
||||
#ifndef NDEBUG
|
||||
uint8_t *begin;
|
||||
@@ -294,11 +288,11 @@ struct agx_usc_builder {
|
||||
} PACKED;
|
||||
|
||||
#ifdef __OPENCL_VERSION__
|
||||
AGX_STATIC_ASSERT(sizeof(struct agx_usc_builder) == 8);
|
||||
static_assert(sizeof(struct agx_usc_builder) == 8);
|
||||
#endif
|
||||
|
||||
static struct agx_usc_builder
|
||||
agx_usc_builder(global_ void *out, ASSERTED size_t size)
|
||||
agx_usc_builder(global void *out, ASSERTED size_t size)
|
||||
{
|
||||
return (struct agx_usc_builder){
|
||||
.head = out,
|
||||
@@ -358,7 +352,7 @@ agx_usc_uniform(struct agx_usc_builder *b, unsigned start_halfs,
|
||||
}
|
||||
|
||||
static inline void
|
||||
agx_usc_words_precomp(global_ uint32_t *out, constant_ struct agx_shader *s,
|
||||
agx_usc_words_precomp(global uint32_t *out, constant struct agx_shader *s,
|
||||
uint64_t data, unsigned data_size)
|
||||
{
|
||||
/* Map the data directly as uniforms starting at u0 */
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2023 Alyssa Rosenzweig
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "compiler/libcl/libcl.h"
|
||||
|
||||
uint32_t nir_interleave_agx(uint16_t x, uint16_t y);
|
||||
void nir_doorbell_agx(uint8_t value);
|
||||
void nir_stack_map_agx(uint16_t index, uint32_t address);
|
||||
uint32_t nir_stack_unmap_agx(uint16_t index);
|
||||
uint32_t nir_load_core_id_agx(void);
|
||||
uint32_t nir_load_helper_op_id_agx(void);
|
||||
uint32_t nir_load_helper_arg_lo_agx(void);
|
||||
uint32_t nir_load_helper_arg_hi_agx(void);
|
||||
void nir_fence_helper_exit_agx(void);
|
||||
|
||||
uint4 nir_bindless_image_load(uint2 handle, int4 coord, uint sample, uint lod,
|
||||
uint image_dim, uint image_array, uint format,
|
||||
uint access, uint dest_type);
|
||||
|
||||
void nir_bindless_image_store(uint2 handle, int4 coord, uint sample,
|
||||
uint4 datum, uint lod, uint image_dim,
|
||||
uint image_array, uint format, uint access,
|
||||
uint src_type);
|
||||
@@ -4,7 +4,7 @@
|
||||
* Copyright 2022 Collabora Ltd. and Red Hat Inc.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include "libagx.h"
|
||||
#include "compiler/libcl/libcl.h"
|
||||
#include "query.h"
|
||||
|
||||
static inline void
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Copyright 2022 Collabora Ltd. and Red Hat Inc.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include "libagx.h"
|
||||
#include "compiler/libcl/libcl.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "libagx.h"
|
||||
#include "compiler/libcl/libcl.h"
|
||||
|
||||
enum libagx_tess_partitioning {
|
||||
LIBAGX_TESS_PARTITIONING_FRACTIONAL_ODD,
|
||||
@@ -25,7 +25,7 @@ struct libagx_tess_point {
|
||||
uint32_t u;
|
||||
uint32_t v;
|
||||
};
|
||||
AGX_STATIC_ASSERT(sizeof(struct libagx_tess_point) == 8);
|
||||
static_assert(sizeof(struct libagx_tess_point) == 8);
|
||||
|
||||
struct libagx_tess_args {
|
||||
/* Heap to allocate tessellator outputs in */
|
||||
@@ -104,4 +104,4 @@ struct libagx_tess_args {
|
||||
*/
|
||||
uint32_t ccw;
|
||||
} PACKED;
|
||||
AGX_STATIC_ASSERT(sizeof(struct libagx_tess_args) == 35 * 4);
|
||||
static_assert(sizeof(struct libagx_tess_args) == 35 * 4);
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* Copyright 2023 Valve Corporation
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include "libagx.h"
|
||||
#include "compiler/libcl/libcl.h"
|
||||
#include "libagx_intrinsics.h"
|
||||
#include <agx_pack.h>
|
||||
|
||||
uint3
|
||||
|
||||
Reference in New Issue
Block a user