This patch adds a set of unit tests for the new lifetime tracker. Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>tags/17.3-branchpoint
@@ -2921,6 +2921,7 @@ AC_CONFIG_FILES([Makefile | |||
src/mesa/drivers/osmesa/osmesa.pc | |||
src/mesa/drivers/x11/Makefile | |||
src/mesa/main/tests/Makefile | |||
src/mesa/state_tracker/tests/Makefile | |||
src/util/Makefile | |||
src/util/tests/hash_table/Makefile | |||
src/util/xmlpool/Makefile |
@@ -19,7 +19,7 @@ | |||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |||
# IN THE SOFTWARE. | |||
SUBDIRS = . main/tests | |||
SUBDIRS = . main/tests state_tracker/tests | |||
if HAVE_XLIB_GLX | |||
SUBDIRS += drivers/x11 |
@@ -601,7 +601,7 @@ static void dump_instruction(int line, prog_scope *scope, | |||
/* Scan the program and estimate the required register life times. | |||
* The array lifetimes must be pre-allocated | |||
*/ | |||
void | |||
bool | |||
get_temp_registers_required_lifetimes(void *mem_ctx, exec_list *instructions, | |||
int ntemps, struct lifetime *lifetimes) | |||
{ | |||
@@ -743,6 +743,15 @@ get_temp_registers_required_lifetimes(void *mem_ctx, exec_list *instructions, | |||
} | |||
break; | |||
} | |||
case TGSI_OPCODE_CAL: | |||
case TGSI_OPCODE_RET: | |||
/* These opcodes are not supported and if a subroutine would | |||
* be called in a shader, then the lifetime tracking would have | |||
* to follow that call to see which registers are used there. | |||
* Since this is not done, we have to bail out here and signal | |||
* that no register merge will take place. | |||
*/ | |||
return false; | |||
default: { | |||
for (unsigned j = 0; j < num_inst_src_regs(inst); j++) { | |||
const st_src_reg& src = inst->src[j]; | |||
@@ -782,6 +791,7 @@ get_temp_registers_required_lifetimes(void *mem_ctx, exec_list *instructions, | |||
RENAME_DEBUG(cerr << "==================================\n\n"); | |||
delete[] acc; | |||
return true; | |||
} | |||
/* Code below used for debugging */ |
@@ -38,7 +38,9 @@ struct lifetime { | |||
int end; | |||
}; | |||
/** Evaluates the required life times of temporary registers in a shader | |||
/** Evaluates the required life times of temporary registers in a shader. | |||
* The life time estimation can only be run sucessfully if the shader doesn't | |||
* call a subroutine. | |||
* @param[in] mem_ctx a memory context that can be used with the ralloc_* functions | |||
* @param[in] instructions the shader to be anlzyed | |||
* @param[in] ntemps number of temporaries reserved for this shader | |||
@@ -47,8 +49,10 @@ struct lifetime { | |||
* allocated memory that can hold ntemps lifetime structures. On output | |||
* the life times contains the life times for the registers with the | |||
* exception of TEMP[0]. | |||
* @returns: true if the lifetimes were estimated, false if not (i.e. if a | |||
* subroutine was called). | |||
*/ | |||
void | |||
bool | |||
get_temp_registers_required_lifetimes(void *mem_ctx, exec_list *instructions, | |||
int ntemps, struct lifetime *lifetimes); | |||
@@ -0,0 +1,36 @@ | |||
AM_CFLAGS = \ | |||
$(PTHREAD_CFLAGS) | |||
AM_CXXFLAGS = \ | |||
$(LLVM_CXXFLAGS) | |||
AM_CPPFLAGS = \ | |||
-I$(top_srcdir)/src/gtest/include \ | |||
-I$(top_srcdir)/src \ | |||
-I$(top_srcdir)/src/mapi \ | |||
-I$(top_builddir)/src/mesa \ | |||
-I$(top_srcdir)/src/mesa \ | |||
-I$(top_srcdir)/include \ | |||
-I$(top_srcdir)/src/gallium/include \ | |||
-I$(top_srcdir)/src/gallium/auxiliary \ | |||
$(DEFINES) | |||
TESTS = st-renumerate-test | |||
check_PROGRAMS = st-renumerate-test | |||
st_renumerate_test_SOURCES = \ | |||
test_glsl_to_tgsi_lifetime.cpp | |||
st_renumerate_test_LDFLAGS = \ | |||
$(LLVM_LDFLAGS) | |||
st_renumerate_test_LDADD = \ | |||
$(top_builddir)/src/mesa/libmesagallium.la \ | |||
$(top_builddir)/src/mapi/shared-glapi/libglapi.la \ | |||
$(top_builddir)/src/gallium/auxiliary/libgallium.la \ | |||
$(top_builddir)/src/util/libmesautil.la \ | |||
$(top_builddir)/src/gtest/libgtest.la \ | |||
$(GALLIUM_COMMON_LIB_DEPS) \ | |||
$(LLVM_LIBS) \ | |||
$(PTHREAD_LIBS) \ | |||
$(DLOPEN_LIBS) |