commit f920a5dabebd03348b02c5c5362691ec9d189df9
parent a58644c88ff5f43d89b953c36cdf97c8aada9a5e
Author: Michael Forney <mforney@mforney.org>
Date: Sat, 13 Jul 2013 12:51:58 -0700
libintelbatch is now it's own package
Diffstat:
10 files changed, 11 insertions(+), 423 deletions(-)
diff --git a/Makefile.am b/Makefile.am
@@ -1,7 +1,7 @@
# swc: Makefile.am
ACLOCAL_AMFLAGS = -I m4
-AM_CFLAGS = $(pixman_CFLAGS) $(drm_CFLAGS)
+AM_CFLAGS = $(pixman_CFLAGS) $(drm_CFLAGS) $(intelbatch_CFLAGS)
lib_LTLIBRARIES = libswc.la
@@ -29,7 +29,8 @@ libswc_la_SOURCES = \
libswc_la_LIBADD = $(wayland_server_LIBS) $(udev_LIBS) $(xkbcommon_LIBS) \
$(drm_LIBS) $(drm_intel_LIBS) $(gbm_LIBS) $(egl_LIBS) \
- $(pixman_LIBS) intel/libintel.la launch/liblaunch-protocol.la
+ $(pixman_LIBS) $(intelbatch_LIBS) \
+ launch/liblaunch-protocol.la
-SUBDIRS = launch intel
+SUBDIRS = launch
diff --git a/configure.ac b/configure.ac
@@ -25,6 +25,7 @@ PKG_CHECK_MODULES([udev], [libudev])
PKG_CHECK_MODULES([xkbcommon], [xkbcommon])
PKG_CHECK_MODULES([drm], [libdrm])
PKG_CHECK_MODULES([drm_intel], [libdrm_intel])
+PKG_CHECK_MODULES([intelbatch], [intelbatch])
PKG_CHECK_MODULES([gbm], [gbm])
PKG_CHECK_MODULES([egl], [egl])
PKG_CHECK_MODULES([pixman], [pixman-1])
@@ -32,6 +33,6 @@ PKG_CHECK_MODULES([pixman], [pixman-1])
PKG_CHECK_MODULES([wayland_client], [wayland-client])
dnl }}}
-AC_CONFIG_FILES([Makefile intel/Makefile launch/Makefile])
+AC_CONFIG_FILES([Makefile launch/Makefile])
AC_OUTPUT
diff --git a/drm.c b/drm.c
@@ -8,13 +8,13 @@
#include <xf86drm.h>
#include <libdrm/i915_drm.h>
#include <libdrm/intel_bufmgr.h>
+#include <intelbatch/batch.h>
//#include <xf86drmMode.h>
#include <wayland-util.h>
#include "drm.h"
#include "output.h"
#include "event.h"
-#include "intel/batch.h"
static struct udev_device * find_primary_drm_device(struct udev * udev,
const char * seat)
diff --git a/intel/Makefile.am b/intel/Makefile.am
@@ -1,13 +0,0 @@
-# intel/Makefile.am
-
-AM_CFLAGS = $(drm_CFLAGS)
-
-noinst_LTLIBRARIES = libintel.la
-
-libintel_la_SOURCES = \
- batch.c batch.h \
- blt.h \
- mi.h
-
-libintel_la_LIBADD = $(drm_LIBS)
-
diff --git a/intel/batch.c b/intel/batch.c
@@ -1,72 +0,0 @@
-/* swc: intel/batch.c
- *
- * Copyright (c) 2013 Michael Forney
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include "batch.h"
-#include "mi.h"
-
-#include <stdio.h>
-#include <xf86drm.h>
-
-void intel_batch_initialize(struct intel_batch * batch,
- drm_intel_bufmgr * bufmgr)
-{
- batch->bufmgr = bufmgr;
- batch->command_count = 0;
-
- /* Alignment (4096) is not used */
- batch->bo = drm_intel_bo_alloc(bufmgr, "batchbuffer",
- sizeof batch->commands, 4096);
-}
-
-void intel_batch_finalize(struct intel_batch * batch)
-{
- drm_intel_bo_unreference(batch->bo);
-}
-
-void intel_batch_flush(struct intel_batch * batch)
-{
- if (batch->command_count == 0)
- return;
-
- intel_batch_add_dword(batch, MI_BATCH_BUFFER_END);
-
- /* Pad the batch buffer to the next quad-word. */
- if (batch->command_count & 1)
- intel_batch_add_dword(batch, MI_NOOP);
-
- drm_intel_bo_subdata(batch->bo, 0, batch->command_count << 2,
- batch->commands);
- int ret = drm_intel_bo_exec(batch->bo, batch->command_count << 2, NULL, 0,
- 0);
- //printf("ret: %d\n", ret);
- drm_intel_gem_bo_clear_relocs(batch->bo, 0);
-
- batch->command_count = 0;
-}
-
-void intel_batch_ensure_space(struct intel_batch * batch, uint32_t size)
-{
- if (intel_batch_space(batch) < size)
- intel_batch_flush(batch);
-}
-
diff --git a/intel/batch.h b/intel/batch.h
@@ -1,82 +0,0 @@
-/* swc: intel/batch.h
- *
- * Copyright (c) 2013 Michael Forney
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef SWC_INTEL_BATCH_H
-#define SWC_INTEL_BATCH_H 1
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <stdarg.h>
-
-#include <intel_bufmgr.h>
-
-#define INTEL_MAX_COMMANDS (1 << 13)
-
-struct intel_batch
-{
- drm_intel_bufmgr * bufmgr;
- drm_intel_bo * bo;
-
- uint32_t commands[INTEL_MAX_COMMANDS];
- uint32_t command_count;
-};
-
-void intel_batch_initialize(struct intel_batch * batch, drm_intel_bufmgr * bufmgr);
-
-void intel_batch_finalize(struct intel_batch * batch);
-
-void intel_batch_flush(struct intel_batch * batch);
-
-void intel_batch_ensure_space(struct intel_batch * batch, uint32_t size);
-
-static inline uint32_t intel_batch_space(struct intel_batch * batch)
-{
- /* XXX: reserved space */
- return INTEL_MAX_COMMANDS - batch->command_count;
-}
-
-
-static inline void intel_batch_add_dword(struct intel_batch * batch,
- uint32_t dword)
-{
- batch->commands[batch->command_count++] = dword;
-}
-
-static inline void intel_batch_add_dwords(struct intel_batch * batch,
- uint32_t count, ...)
-{
- va_list dwords;
- va_start(dwords, count);
- while (count--)
- intel_batch_add_dword(batch, va_arg(dwords, uint32_t));
- va_end(dwords);
-}
-
-static inline uint32_t intel_batch_offset(struct intel_batch * batch,
- uint32_t command_index)
-{
- return (batch->command_count + command_index) << 2;
-}
-
-#endif
-
diff --git a/intel/blt.h b/intel/blt.h
@@ -1,193 +0,0 @@
-/* swc: intel/blt.h
- *
- * Copyright (c) 2013 Michael Forney
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef SWC_INTEL_BLT_H
-#define SWC_INTEL_BLT_H 1
-
-#include "batch.h"
-
-#include <i915_drm.h>
-
-#define COMMAND_TYPE_2D 0x2
-
-#define BLT_OPCODE_XY_COLOR_BLT 0x50
-#define BLT_OPCODE_XY_SRC_COPY_BLT 0x53
-
-#define BR00_32BPP_BYTE_MASK_ALPHA (1 << 0)
-#define BR00_32BPP_BYTE_MASK_COLOR (1 << 1)
-
-static inline uint32_t br00(uint8_t client, uint8_t opcode,
- uint8_t mask_32bpp,
- bool src_tiling_enable, bool dst_tiling_enable,
- uint8_t dword_length)
-{
- return client << 29 /* 31:29 */
- | opcode << 22 /* 28:22 */
- | mask_32bpp << 20 /* 21:20 */
- /* 19:16 */
- | src_tiling_enable << 15 /* 15 */
- /* 14:12 */
- | dst_tiling_enable << 11 /* 11 */
- /* 10:8 */
- | dword_length << 0 /* 7:0 */
- ;
-}
-
-static inline uint32_t br09(uint32_t destination_address)
-{
- /* 31:29 */
- return destination_address << 0 /* 28:0 */
- ;
-}
-
-static inline uint32_t br11(uint16_t source_pitch)
-{
- /* 31:16 */
- return source_pitch << 0 /* 15:0 */
- ;
-}
-
-static inline uint32_t br12(uint32_t source_address)
-{
- /* 31:29 */
- return source_address << 0 /* 28:0 */
- ;
-}
-
-#define BR13_COLOR_DEPTH_8BIT 0x0
-#define BR13_COLOR_DEPTH_16BIT_565 0x1
-#define BR13_COLOR_DEPTH_16BIT_1555 0x2
-#define BR13_COLOR_DEPTH_32BIT 0x3
-
-/* Commonly used raster operations */
-#define BR13_RASTER_OPERATION_SOURCE 0xcc
-#define BR13_RASTER_OPERATION_PATTERN 0xf0
-
-static inline uint32_t br13(bool clipping_enable, uint8_t color_depth,
- uint8_t raster_operation,
- uint16_t destination_pitch)
-{
- /* 31 */
- return clipping_enable << 30 /* 30 */
- /* 29:26 */
- | color_depth << 24 /* 25:24 */
- | raster_operation << 16 /* 23:16 */
- | destination_pitch << 0 /* 15:0 */
- ;
-}
-
-static inline uint32_t br16(uint32_t color)
-{
- return color << 0 /* 31:0 */
- ;
-}
-
-static inline uint32_t br22(uint16_t destination_y1, uint16_t destination_x1)
-{
- return destination_y1 << 16 /* 31:16 */
- | destination_x1 << 0 /* 15:0 */
- ;
-}
-
-static inline uint32_t br23(uint16_t destination_y2, uint16_t destination_x2)
-{
- return destination_y2 << 16 /* 31:16 */
- | destination_x2 << 0 /* 15:0 */
- ;
-}
-
-static inline uint32_t br26(uint16_t source_y1, uint16_t source_x1)
-{
- return source_y1 << 16 /* 31:16 */
- | source_x1 << 0 /* 15:0 */
- ;
-};
-
-static inline void xy_src_copy_blt(struct intel_batch * batch,
- drm_intel_bo * src, uint16_t src_pitch,
- uint16_t src_x, uint16_t src_y,
- drm_intel_bo * dst, uint16_t dst_pitch,
- uint16_t dst_x, uint16_t dst_y,
- uint16_t width, uint16_t height)
-{
- uint32_t src_tiling_mode, dst_tiling_mode, swizzle;
-
- intel_batch_ensure_space(batch, 8);
-
- drm_intel_bo_get_tiling(dst, &dst_tiling_mode, &swizzle);
- drm_intel_bo_get_tiling(src, &src_tiling_mode, &swizzle);
-
- drm_intel_bo_emit_reloc_fence
- (batch->bo, intel_batch_offset(batch, 4), dst, 0,
- I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
- drm_intel_bo_emit_reloc_fence
- (batch->bo, intel_batch_offset(batch, 7), src, 0,
- I915_GEM_DOMAIN_RENDER, 0);
-
- intel_batch_add_dwords(batch, 8,
- br00(COMMAND_TYPE_2D, BLT_OPCODE_XY_SRC_COPY_BLT,
- BR00_32BPP_BYTE_MASK_ALPHA | BR00_32BPP_BYTE_MASK_COLOR,
- src_tiling_mode != I915_TILING_NONE,
- dst_tiling_mode != I915_TILING_NONE, 6),
- br13(false, BR13_COLOR_DEPTH_32BIT, BR13_RASTER_OPERATION_SOURCE,
- dst_pitch >> 2),
- br22(dst_y, dst_x),
- br23(dst_y + height, dst_x + width),
- br09(dst->offset),
- br26(src_y, src_x),
- br11(src_pitch >> 2),
- br12(src->offset)
- );
-}
-
-static inline void xy_color_blt(struct intel_batch * batch,
- drm_intel_bo * dst, uint16_t dst_pitch,
- uint16_t dst_x1, uint16_t dst_y1,
- uint16_t dst_x2, uint16_t dst_y2,
- uint32_t color)
-{
- uint32_t tiling_mode, swizzle_mode;
-
- intel_batch_ensure_space(batch, 6);
-
- drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
-
- drm_intel_bo_emit_reloc_fence
- (batch->bo, intel_batch_offset(batch, 4), dst, 0,
- I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
-
- intel_batch_add_dwords(batch, 6,
- br00(COMMAND_TYPE_2D, BLT_OPCODE_XY_COLOR_BLT,
- BR00_32BPP_BYTE_MASK_ALPHA | BR00_32BPP_BYTE_MASK_COLOR,
- false, tiling_mode != I915_TILING_NONE, 4),
- br13(false, BR13_COLOR_DEPTH_32BIT, BR13_RASTER_OPERATION_PATTERN,
- dst_pitch >> 2),
- br22(dst_y1, dst_x1),
- br23(dst_y2, dst_x2),
- br09(dst->offset),
- br16(color)
- );
-}
-
-#endif
-
diff --git a/intel/mi.h b/intel/mi.h
@@ -1,55 +0,0 @@
-/* swc: intel/mi.h
- *
- * Copyright (c) 2013 Michael Forney
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef SWC_INTEL_MI_H
-#define SWC_INTEL_MI_H 1
-
-#include "batch.h"
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#define COMMAND_TYPE_MI 0x0
-
-#define MI_OP(opcode) ( \
- COMMAND_TYPE_MI << 29 /* 31:29 */ \
- | opcode << 23 /* 28:23 */ \
-)
-
-#define MI_NOOP MI_OP(0x00)
-#define MI_FLUSH MI_OP(0x04)
-#define MI_BATCH_BUFFER_END MI_OP(0x0A)
-
-/* MI_NOOP */
-#define MI_NOOP_IDENTIFICATION_NUMBER(number) (1 << 22 | number)
-
-/* MI_FLUSH */
-#define MI_FLUSH_ENABLE_PROTECTED_MEMORY (1 << 6)
-#define MI_FLUSH_DISABLE_INDIRECT_STATE_POINTERS (1 << 5)
-#define MI_FLUSH_CLEAR_GENERIC_MEDIA_STATE (1 << 3)
-#define MI_FLUSH_RESET_GLOBAL_SNAPSHOT_COUNT (1 << 3)
-#define MI_FLUSH_INHIBIT_RENDER_CACHE_FLUSH (1 << 2)
-#define MI_FLUSH_INVALIDATE_STATE_INSTRUCTION_CACHE (1 << 2)
-
-#endif
-
diff --git a/renderer.c b/renderer.c
@@ -1,11 +1,11 @@
#include "renderer.h"
-#include "intel/blt.h"
-#include "intel/mi.h"
#include <stdio.h>
#include <GLES2/gl2.h>
#include <libdrm/intel_bufmgr.h>
#include <libdrm/drm.h>
+#include <intelbatch/blt.h>
+#include <intelbatch/mi.h>
#include <xf86drm.h>
static inline uint32_t format_wayland_to_pixman(uint32_t wayland_format)
diff --git a/renderer.h b/renderer.h
@@ -4,7 +4,8 @@
#include "output.h"
#include "surface.h"
#include "drm.h"
-#include "intel/batch.h"
+
+#include <intelbatch/batch.h>
enum swc_renderer_context
{