Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/compiler/nir/nir_divergence_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ visit_intrinsic(nir_intrinsic_instr *instr, struct divergence_state *state)
case nir_intrinsic_load_texture_scale:
case nir_intrinsic_load_inline_data_intel:
case nir_intrinsic_resource_intel:
case nir_intrinsic_load_smp_meta_pco:
case nir_intrinsic_load_push_constant: {
unsigned num_srcs = nir_intrinsic_infos[instr->intrinsic].num_srcs;
for (unsigned i = 0; i < num_srcs; i++) {
Expand Down
10 changes: 8 additions & 2 deletions src/imagination/g5p/g5p_texel_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
#define PVR_G5P_TBO_LIMIT 65536u
#define PVR_G5P_TBO_MAGIC 0x54424f31u /* software metadata, never a GPU field */
#define PVR_G5P_TBO_NIR_FOLDED (1u << 31)
/* Texel buffers have not run on the device: not advertised */
/* Uniform texel buffers in fragment and vertex programs. This path (a
* linear 4096-wide 2D state over the buffer, the NIR fold of the index, the
* range in software metadata) gave exact pixels on the A9 for 30 formats,
* 1 to 65536 elements, offsets 64 and 128, the size query and out-of-range
* reads, in fragment and vertex programs. The fetch instruction is the
* general texture encoder's. Storage texel buffers and compute fetches stay
* refused by name. */
static inline bool pvr_g5p_tbo_probe(void)
{
return false;
return true;
}

#endif
12 changes: 8 additions & 4 deletions src/imagination/g5p/g5p_usc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1720,15 +1720,19 @@ unsigned g5p_usc_position_xy(uint8_t *out, unsigned dst_half, unsigned words, un
return finish(out, raw, source_half ? 6 : 4);
}

unsigned g5p_usc_position_zw(uint8_t *out, unsigned dst_half, bool z, bool both, int long_form)
/* The screen-linear position iterator: one coefficient set (set 0, or set 1
* with set1), or sets 0 and 1 together (both). The last byte is the set << 1,
* as in the varying iterator: Apple puts W at set 0 and Z at set 1, or Z at
* set 0 when no W is iterated (Apple's compiles f_raster_pos_z/w). */
unsigned g5p_usc_position_zw(uint8_t *out, unsigned dst_half, bool set1, bool both, int long_form)
{
CHECK(!(both && z), "invalid position iterator");
CHECK(!(both && set1), "invalid position iterator");
CHECK(!(dst_half & 1), "position iterator needs a dword-aligned destination");
CHECK(dst_half < 256, "position destination must be u8");
bool minimum = dst_half || z || both;
bool minimum = dst_half || set1 || both;
bool wide = long_form < 0 ? minimum : long_form;
CHECK(!(minimum && !wide), "short position iterator omits nonzero fields");
uint8_t raw[4] = {8, (both ? 0x10 : 8) | wide, dst_half, z ? 2 : 0};
uint8_t raw[4] = {8, (both ? 0x10 : 8) | wide, dst_half, set1 ? 2 : 0};
return finish(out, raw, wide ? 4 : 2);
}

Expand Down
2 changes: 1 addition & 1 deletion src/imagination/g5p/g5p_usc.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ unsigned g5p_usc_cond_select(uint8_t *out, unsigned dst_half, struct g5p_src con
struct g5p_src f, unsigned bank, unsigned source_extension, unsigned header);
/* Raster position, tile access and native-f16 blend arithmetic. */
unsigned g5p_usc_position_xy(uint8_t *out, unsigned dst_half, unsigned words, unsigned source_half);
unsigned g5p_usc_position_zw(uint8_t *out, unsigned dst_half, bool z, bool both, int long_form);
unsigned g5p_usc_position_zw(uint8_t *out, unsigned dst_half, bool set1, bool both, int long_form);
unsigned g5p_usc_tile_read(uint8_t *out, unsigned dst_half, unsigned words);
unsigned g5p_usc_half_binary(uint8_t *out, bool mul, unsigned dst_half, struct g5p_src a, struct g5p_src b,
struct g5p_ctl k, int source_control);
Expand Down
281 changes: 236 additions & 45 deletions src/imagination/g5p/pco_g5p_general.c

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions src/imagination/g5p/pco_g5p_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@ enum pco_g5p_upload_kind {
PCO_G5P_UPLOAD_XFB, /* per-draw driver block, PCO_G5P_XFB_* dwords */
PCO_G5P_UPLOAD_BLEND_CONSTANTS, /* 4 dwords: the dynamic blend constants (f32) */
PCO_G5P_UPLOAD_FETCH_SAMPLER, /* two generated samplerless-read policy words */
/* sampler metadata dwords [offset / 4, offset / 4 + dwords) of the sampler at (set, binding, element):
* pvr_sampler_descriptor::meta (load_smp_meta_pco; the LOD-bias variant reads the sampler's mipLodBias,
* PVR_G5P_SAMPLER_META_LOD_BIAS) */
PCO_G5P_UPLOAD_SAMPLER_META,
};
/* nir_tex_instr.backend_flags, set by the driver's LOD-bias lowering (pvr_g5p_nir.c lod_bias_lower()): the
* sample adds its sampler's mipLodBias (pco_g5p_program::lod_samplers[].biased) */
#define PCO_G5P_TEX_SAMPLER_BIAS (1u << 28)
#define PCO_G5P_MAX_LOD_SAMPLERS 16
/* PCO_G5P_UPLOAD_IMAGE's offset (the state is always descriptor +0): how the
* program samples it. AS_2D: an array sample at the constant layer 0, drawn
* as a 2D sample, so the driver uploads the view's base layer as a 2D state
Expand All @@ -164,6 +172,17 @@ enum pco_g5p_upload_kind {
#define PCO_G5P_SSBO_SIZE_OFFSET 0xfffcu
#define PCO_G5P_UPLOAD_IMAGE_AS_2D 1u
#define PCO_G5P_UPLOAD_IMAGE_ARRAY 2u
/* ONE_LAYER: an array sample at any layer of a one-layer view, drawn as a 2D
* sample. Vulkan's layer is clamp(RNE(z), 0, layers - 1), so with one layer
* every z reads the base layer. Only the driver's one-layer program variant
* has such samples (pvr_g5p_nir.c one_layer_as_2d()), and the draw selects
* that variant only when every array view it samples has one layer. The
* driver uploads a 2D state of that layer, and refuses a multi-layer view by
* name (pvr_g5p_tex_state_for()). */
#define PCO_G5P_UPLOAD_IMAGE_ONE_LAYER 4u
/* nir_tex_instr.backend_flags, set by the driver's one-layer lowering: this
* former array sample reads PCO_G5P_UPLOAD_IMAGE_ONE_LAYER state */
#define PCO_G5P_TEX_ONE_LAYER_AS_2D (1u << 29)


/* Varyings (docs/gpu/experiments/varyings.md). Apple's A9 compiler takes at
Expand All @@ -178,6 +197,8 @@ enum pco_g5p_upload_kind {
* included). Before: 16 vec4, 64 components. */
#define PCO_G5P_MAX_FS_VARYINGS 28
#define PCO_G5P_VARYING_SLOTS 32 /* VARYING_SLOT_VAR0..VAR31 */
/* pco_g5p_program::z_set: fragment position Z; host tests check for it */
#define PCO_G5P_HAVE_Z_SET 1

enum pco_g5p_interp {
PCO_G5P_INTERP_UNREAD = 0, /* VS link: the fragment program does not read it */
Expand Down Expand Up @@ -250,6 +271,10 @@ struct pco_g5p_program {
unsigned num_varyings;
struct pco_g5p_varying vary[PCO_G5P_MAX_FS_VARYINGS];
bool w_set; /* coefficient set 0 is W (some varying is perspective-correct) */
/* gl_FragCoord.z is read: the next coefficient set (1 after W, else 0) is the
* TSP's unclamped Z, which TA_OUTPUT_SEL tsp_unclamped_z_pres puts right after
* the RHW (AGXMetalA9 FragmentProgramVariant 0x207d28be0, varying item type 6) */
bool z_set;
/* VS: first output dword of each VARn (0 = not written) and its
* interpolation; outputs are grouped linear, flat, npc (STATE_VARYING0). */
uint8_t vout_dword[PCO_G5P_VARYING_SLOTS];
Expand All @@ -271,6 +296,18 @@ struct pco_g5p_program {
* (set by pvr_g5p_nir.c after compilation; polygon mode POINT refuses it) */
bool psize_dropped;
uint8_t clip_count; /* VS: user clip distances, the last output dwords (TA user planes 0..n-1) */
/* The samplers whose LOD a sample uses (tex, txb, txl, txd; not txf, size queries or gathers): a sampler's
* mipLodBias applies to them (Vulkan's LOD operation: lambda' = lambda_base + clamp(sampler bias + shader
* bias)). `biased`: the program adds the bound sampler's bias itself (the LOD-bias variant,
* PCO_G5P_TEX_SAMPLER_BIAS); the draw selects programs from these (pvr_arch_g5p_gfx.c). More than
* PCO_G5P_MAX_LOD_SAMPLERS sets lod_samplers_overflow. */
unsigned num_lod_samplers;
bool lod_samplers_overflow;
struct pco_g5p_lod_sampler {
uint8_t set, binding;
uint16_t element;
bool biased;
} lod_samplers[PCO_G5P_MAX_LOD_SAMPLERS];
char refusal[512];
};

Expand Down
6 changes: 6 additions & 0 deletions src/imagination/g9p/g9p_a9_tex.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ a9_txs(struct g9p_ctx *ctx, nir_tex_instr *tex)
a9_tex_refuse(ctx, "texture size query of a texture without a constant binding");
return false;
}
/* a buffer view's size is its element count (pvr_g5p_tbo_upload()), which
* the compute uploads do not carry; texel-buffer fetches are refused too */
if (tex->sampler_dim == GLSL_SAMPLER_DIM_BUF) {
a9_tex_refuse(ctx, "texel-buffer size query in a compute shader");
return false;
}
if (tex->op == nir_texop_txs && li >= 0) {
if (!nir_src_is_const(tex->src[li].src)) {
a9_tex_refuse(ctx, "textureDimensions at a non-constant level in a compute shader");
Expand Down
8 changes: 8 additions & 0 deletions src/imagination/vulkan/pvr_arch_g5p_compute.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,14 @@ PVR_PER_ARCH(g5p_cmd_dispatch)(struct pvr_cmd_buffer *cmd_buffer,
mesa_logw("G5P refuses: compute set %u binding %u: a sampler without A9 words",u->set,u->binding);
return vk_errorf(cmd_buffer,VK_ERROR_OUT_OF_HOST_MEMORY,"G5P compute: a sampler without A9 words");
}
/* the A9 sampler word has no LOD bias: graphics adds it in the LOD-bias fragment variant
* (pvr_g5p_nir.c lod_bias_lower()); compute samples at a shared constant level and has no such
* program, so a biased sampler is refused rather than sampled at the unbiased level */
if(d[2*ROGUE_NUM_TEXSTATE_SAMPLER_WORDS+PVR_G5P_SAMPLER_META_LOD_BIAS]) {
mesa_logw("G5P refuses: compute set %u binding %u: a sampler LOD bias of %g (no LOD-bias compute program)",
u->set,u->binding,uif(d[2*ROGUE_NUM_TEXSTATE_SAMPLER_WORDS+PVR_G5P_SAMPLER_META_LOD_BIAS]));
return vk_errorf(cmd_buffer,VK_ERROR_OUT_OF_HOST_MEMORY,"G5P compute: a sampler LOD bias");
}
memcpy(out,d,4*2);
break;
case G9P_A9_UP_SIZE:
Expand Down
Loading
Loading