*/
#include "main/imports.h"
+#include "main/streaming-load-memcpy.h"
+#include "x86/common_x86_asm.h"
#include "intel_batchbuffer.h"
#include "brw_state.h"
#include "brw_wm.h"
{
struct brw_context *brw = cache->brw;
struct brw_bo *new_bo;
- void *llc_map;
new_bo = brw_bo_alloc(brw->bufmgr, "program cache", new_size, 64);
if (can_do_exec_capture(brw->screen))
new_bo->kflags = EXEC_OBJECT_CAPTURE;
- if (brw->has_llc) {
- llc_map = brw_bo_map(brw, new_bo, MAP_READ | MAP_WRITE |
- MAP_ASYNC | MAP_PERSISTENT);
- }
+
+ void *map = brw_bo_map(brw, new_bo, MAP_READ | MAP_WRITE |
+ MAP_ASYNC | MAP_PERSISTENT);
/* Copy any existing data that needs to be saved. */
if (cache->next_offset != 0) {
- if (brw->has_llc) {
- memcpy(llc_map, cache->map, cache->next_offset);
- } else {
- void *map = brw_bo_map(brw, cache->bo, MAP_READ);
- brw_bo_subdata(new_bo, 0, cache->next_offset, map);
- brw_bo_unmap(cache->bo);
- }
+#ifdef USE_SSE41
+ if (!cache->bo->cache_coherent && cpu_has_sse4_1)
+ _mesa_streaming_load_memcpy(map, cache->map, cache->next_offset);
+ else
+#endif
+ memcpy(map, cache->map, cache->next_offset);
}
- if (brw->has_llc)
- brw_bo_unmap(cache->bo);
+ brw_bo_unmap(cache->bo);
brw_bo_unreference(cache->bo);
cache->bo = new_bo;
- cache->map = brw->has_llc ? llc_map : NULL;
- cache->bo_used_by_gpu = false;
+ cache->map = map;
/* Since we have a new BO in place, we need to signal the units
* that depend on it (state base address on gen5+, or unit state before).
enum brw_cache_id cache_id,
const void *data, unsigned data_size)
{
- struct brw_context *brw = cache->brw;
unsigned i;
const struct brw_cache_item *item;
for (i = 0; i < cache->size; i++) {
for (item = cache->items[i]; item; item = item->next) {
- int ret;
-
- if (item->cache_id != cache_id || item->size != data_size)
- continue;
-
- void *map;
- if (!brw->has_llc)
- map = brw_bo_map(brw, cache->bo, MAP_READ);
- else
- map = cache->map;
-
- ret = memcmp(map + item->offset, data, item->size);
- if (!brw->has_llc)
- brw_bo_unmap(cache->bo);
- if (ret)
+ if (item->cache_id != cache_id || item->size != data_size ||
+ memcmp(cache->map + item->offset, data, item->size) != 0)
continue;
return item;
brw_alloc_item_data(struct brw_cache *cache, uint32_t size)
{
uint32_t offset;
- struct brw_context *brw = cache->brw;
/* Allocate space in the cache BO for our new program. */
if (cache->next_offset + size > cache->bo->size) {
brw_cache_new_bo(cache, new_size);
}
- /* If we would block on writing to an in-use program BO, just
- * recreate it.
- */
- if (!brw->has_llc && cache->bo_used_by_gpu) {
- perf_debug("Copying busy program cache buffer.\n");
- brw_cache_new_bo(cache, cache->bo->size);
- }
-
offset = cache->next_offset;
/* Programs are always 64-byte aligned, so set up the next one now */
uint32_t *out_offset,
void *out_aux)
{
- struct brw_context *brw = cache->brw;
struct brw_cache_item *item = CALLOC_STRUCT(brw_cache_item);
const struct brw_cache_item *matching_data =
brw_lookup_prog(cache, cache_id, data, data_size);
item->offset = brw_alloc_item_data(cache, data_size);
/* Copy data to the buffer */
- if (brw->has_llc) {
- memcpy(cache->map + item->offset, data, data_size);
- } else {
- brw_bo_subdata(cache->bo, item->offset, data_size, data);
- }
+ memcpy(cache->map + item->offset, data, data_size);
}
/* Set up the memory containing the key and aux_data */
cache->bo = brw_bo_alloc(brw->bufmgr, "program cache", 4096, 64);
if (can_do_exec_capture(brw->screen))
cache->bo->kflags = EXEC_OBJECT_CAPTURE;
- if (brw->has_llc) {
- cache->map = brw_bo_map(brw, cache->bo, MAP_READ | MAP_WRITE |
- MAP_ASYNC | MAP_PERSISTENT);
- }
+
+ cache->map = brw_bo_map(brw, cache->bo, MAP_READ | MAP_WRITE |
+ MAP_ASYNC | MAP_PERSISTENT);
}
static void
/* This can be NULL if context creation failed early on */
if (cache->bo) {
- if (brw->has_llc)
- brw_bo_unmap(cache->bo);
+ brw_bo_unmap(cache->bo);
brw_bo_unreference(cache->bo);
cache->bo = NULL;
cache->map = NULL;
{
const struct brw_cache *cache = &brw->cache;
struct brw_cache_item *item;
- void *map;
-
- if (!brw->has_llc)
- map = brw_bo_map(brw, cache->bo, MAP_READ);
- else
- map = cache->map;
for (unsigned i = 0; i < cache->size; i++) {
for (item = cache->items[i]; item; item = item->next) {
fprintf(stderr, "%s:\n", cache_name(i));
- brw_disassemble(&brw->screen->devinfo, map,
+ brw_disassemble(&brw->screen->devinfo, cache->map,
item->offset, item->size, stderr);
}
}
-
- if (!brw->has_llc)
- brw_bo_unmap(cache->bo);
}