pan/bi: Make some headers compilable with C++

This will allow have tests that use gtest (which is C++) for.

Note the reordering of designated initializers in structs is
because C++ requires them to follow the order that they were
defined in the struct.

The table `bifrost_reg_ctrl_lut` is not used by the tests at the
moment, so bailed out trying to replace the C syntax designated
initializer for arrays (that doesn't have an equivalent in C++), and
simply #ifdef it out when including from C++ code.

Also, use not_mod instead of not. not is a keyword in C++ and can't be
used. Luckily, the naming is not determined by the XML, so we can freely
rename.

[Alyssa: squash in not_mod]

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13684>
This commit is contained in:
Caio Oliveira 2021-11-04 14:28:01 -07:00 committed by Marge Bot
parent bee2c9c081
commit 3a9210c93d
3 changed files with 34 additions and 16 deletions

View File

@ -95,7 +95,7 @@ struct bi_op_props {
bool not_result : 1;
unsigned abs : 3;
unsigned neg : 3;
bool not : 1;
bool not_mod : 1;
};
/* Generated in bi_opcodes.c.py */

View File

@ -30,6 +30,10 @@
#include <stdbool.h>
#include <assert.h>
#ifdef __cplusplus
extern "C" {
#endif
#define BIFROST_DBG_MSGS 0x0001
#define BIFROST_DBG_SHADERS 0x0002
#define BIFROST_DBG_SHADERDB 0x0004
@ -270,9 +274,9 @@ enum bi_clause_subword {
BI_CLAUSE_SUBWORD_UPPER_56 = BI_CLAUSE_SUBWORD_UPPER_0 + 56,
};
#define L(x) (BI_CLAUSE_SUBWORD_LITERAL_0 + x)
#define U(x) (BI_CLAUSE_SUBWORD_UPPER_0 + x)
#define T(x) (BI_CLAUSE_SUBWORD_TUPLE_0 + x)
#define L(x) ((enum bi_clause_subword)(BI_CLAUSE_SUBWORD_LITERAL_0 + x))
#define U(x) ((enum bi_clause_subword)(BI_CLAUSE_SUBWORD_UPPER_0 + x))
#define T(x) ((enum bi_clause_subword)(BI_CLAUSE_SUBWORD_TUPLE_0 + x))
#define EC BI_CLAUSE_SUBWORD_CONSTANT
#define M BI_CLAUSE_SUBWORD_M
#define Z BI_CLAUSE_SUBWORD_Z
@ -371,6 +375,7 @@ struct bifrost_reg_ctrl_23 {
bool slot3_fma;
};
#ifndef __cplusplus
static const struct bifrost_reg_ctrl_23 bifrost_reg_ctrl_lut[32] = {
[BIFROST_R_WL_FMA] = { BIFROST_OP_READ, BIFROST_OP_WRITE_LO, true },
[BIFROST_R_WH_FMA] = { BIFROST_OP_READ, BIFROST_OP_WRITE_HI, true },
@ -399,6 +404,7 @@ static const struct bifrost_reg_ctrl_23 bifrost_reg_ctrl_lut[32] = {
[BIFROST_WH_WL_MIX] = { BIFROST_OP_WRITE_HI, BIFROST_OP_WRITE_LO, false },
[BIFROST_IDLE] = { BIFROST_OP_IDLE, BIFROST_OP_IDLE, true },
};
#endif
/* Texture operator descriptors in various states. Usually packed in the
* compiler and stored as a constant */
@ -576,4 +582,8 @@ bi_constant_field(unsigned idx)
return values[idx] << 4;
}
#ifdef __cplusplus
} /* extern C */
#endif
#endif

View File

@ -34,6 +34,10 @@
#include "util/u_math.h"
#include "util/half_float.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Swizzles across bytes in a 32-bit word. Expresses swz in the XML directly.
* To express widen, use the correpsonding replicated form, i.e. H01 = identity
* for widen = none, H00 for widen = h0, B1111 for widen = b1. For lane, also
@ -134,11 +138,11 @@ static inline bi_index
bi_get_index(unsigned value, bool is_reg, unsigned offset)
{
return (bi_index) {
.type = BI_INDEX_NORMAL,
.value = value,
.swizzle = BI_SWIZZLE_H01,
.offset = offset,
.reg = is_reg,
.type = BI_INDEX_NORMAL,
};
}
@ -148,9 +152,9 @@ bi_register(unsigned reg)
assert(reg < 64);
return (bi_index) {
.type = BI_INDEX_REGISTER,
.value = reg,
.swizzle = BI_SWIZZLE_H01,
.value = reg
.type = BI_INDEX_REGISTER,
};
}
@ -158,9 +162,9 @@ static inline bi_index
bi_imm_u32(uint32_t imm)
{
return (bi_index) {
.type = BI_INDEX_CONSTANT,
.value = imm,
.swizzle = BI_SWIZZLE_H01,
.value = imm
.type = BI_INDEX_CONSTANT,
};
}
@ -186,9 +190,9 @@ static inline bi_index
bi_passthrough(enum bifrost_packed_src value)
{
return (bi_index) {
.type = BI_INDEX_PASS,
.value = value,
.swizzle = BI_SWIZZLE_H01,
.value = value
.type = BI_INDEX_PASS,
};
}
@ -212,7 +216,7 @@ static inline bi_index
bi_swz_16(bi_index idx, bool x, bool y)
{
assert(idx.swizzle == BI_SWIZZLE_H01);
idx.swizzle = BI_SWIZZLE_H00 | (x << 1) | y;
idx.swizzle = (enum bi_swizzle)(BI_SWIZZLE_H00 | (x << 1) | y);
return idx;
}
@ -227,7 +231,7 @@ bi_byte(bi_index idx, unsigned lane)
{
assert(idx.swizzle == BI_SWIZZLE_H01);
assert(lane < 4);
idx.swizzle = BI_SWIZZLE_B0000 + lane;
idx.swizzle = (enum bi_swizzle)(BI_SWIZZLE_B0000 + lane);
return idx;
}
@ -676,10 +680,10 @@ static inline bi_index
bi_fau(enum bir_fau value, bool hi)
{
return (bi_index) {
.type = BI_INDEX_FAU,
.value = value,
.swizzle = BI_SWIZZLE_H01,
.offset = hi ? 1 : 0
.offset = hi ? 1u : 0u,
.type = BI_INDEX_FAU,
};
}
@ -742,7 +746,7 @@ static inline bi_index
bi_node_to_index(unsigned node, unsigned node_count)
{
assert(node < node_count);
assert(node_count < ~0);
assert(node_count < ~0u);
return bi_get_index(node >> 1, node & PAN_IS_REG, 0);
}
@ -1162,4 +1166,8 @@ bi_word_node(bi_index idx)
bool bi_lower_divergent_indirects(nir_shader *shader, unsigned lanes);
#ifdef __cplusplus
} /* extern C */
#endif
#endif