libports: Mesa 11.2.2

OpenGL 4.5 with software and i965 rendering back ends.

issue #2488
This commit is contained in:
Sebastian Sumpf 2017-08-17 13:27:18 +02:00 committed by Christian Helmuth
parent dbff692c86
commit 66db2ee54e
60 changed files with 2989 additions and 2128 deletions

View File

@ -25,14 +25,21 @@
#endif
#define EGLAPIENTRYP EGLAPIENTRY*
typedef int EGLNativeDisplayType;
typedef long EGLNativeDisplayType;
typedef void *EGLNativePixmapType;
enum Surface_type {
WINDOW,
PIXMAP
};
struct Genode_egl_window
{
int width;
int height;
unsigned char *addr;
enum Surface_type type;
};
typedef struct Genode_egl_window *EGLNativeWindowType;

View File

@ -0,0 +1 @@
INC_DIR += $(call select_from_ports,mesa)/src/lib/mesa/include

View File

@ -0,0 +1,33 @@
SHARED_LIB = yes
LIBS = libc blit
include $(REP_DIR)/lib/mk/mesa-common.inc
SRC_C = \
main/eglsurface.c \
main/eglconfig.c \
main/eglglobals.c \
main/egldisplay.c \
main/eglfallbacks.c \
main/eglsync.c \
main/egllog.c \
main/eglarray.c \
main/eglimage.c \
main/eglcontext.c \
main/eglcurrent.c \
main/eglapi.c \
main/egldriver.c \
drivers/dri2/egl_dri2.c \
platform.c
SRC_CC = genode_interface.cc
CC_OPT += -D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_GENODE -D_EGL_BUILT_IN_DRIVER_DRI2 \
-DHAVE_GENODE_PLATFORM
INC_DIR += $(MESA_PORT_DIR)/src/egl/main \
$(MESA_PORT_DIR)/src/egl/drivers/dri2
vpath %.c $(MESA_PORT_DIR)/src/egl
vpath %.c $(LIB_DIR)/egl
vpath %.cc $(LIB_DIR)/egl

View File

@ -0,0 +1,15 @@
SHARED_LIB = yes
LIBS = libc egl i965
include $(REP_DIR)/lib/mk/mesa-common.inc
SRC_C = platform_i965.c
SRC_CC = drm_init.cc
CC_OPT += -DHAVE_GENODE_PLATFORM
INC_DIR += $(MESA_PORT_DIR)/src/egl/main \
$(MESA_PORT_DIR)/src/egl/drivers/dri2
vpath %.c $(LIB_DIR)/i965
vpath %.cc $(LIB_DIR)/i965

View File

@ -0,0 +1,13 @@
SHARED_LIB = yes
LIBS = libc egl swrast
include $(REP_DIR)/lib/mk/mesa-common.inc
SRC_C = platform_swrast.c
CC_OPT += -DHAVE_GENODE_PLATFORM
INC_DIR += $(MESA_PORT_DIR)/src/egl/main \
$(MESA_PORT_DIR)/src/egl/drivers/dri2
vpath %.c $(LIB_DIR)/swrast

View File

@ -1,51 +0,0 @@
include $(REP_DIR)/lib/mk/gallium.inc
GALLIUM_AUX_SRC_DIR = $(GALLIUM_SRC_DIR)/auxiliary
SUBDIRS = cso_cache draw indices os pipebuffer rbug rtasm tgsi translate util vl
# collect all source codes in 'SUBDIRS'
SRC_C := $(foreach subdir,$(SUBDIRS),$(wildcard $(GALLIUM_AUX_SRC_DIR)/$(subdir)/*.c))
# strip leading directories - keep only the file names
SRC_C := $(notdir $(SRC_C))
# add sources normally generated in 'indices' subdirectory
SRC_C += u_indices_gen.c u_unfilled_gen.c
# add sources normally generated in 'util' subdirectory
SRC_C += u_format_access.c u_format_table.c
# remove non-needed files from list
SRC_C := $(filter-out u_indices.c u_unfilled_indices.c u_debug_memory.c,$(SRC_C))
# dim build noise
CC_OPT_draw_vertex += -Wno-unused-but-set-variable
CC_OPT_draw_vs_varient += -Wno-enum-compare
CC_OPT_rbug_context += -Wno-unused-but-set-variable
CC_OPT_rbug_core += -Wno-unused-but-set-variable
CC_OPT_rbug_texture += -Wno-unused-but-set-variable
CC_OPT_tgsi_build += -Wno-uninitialized
CC_OPT_tgsi_build += -Wno-unused-but-set-variable
CC_OPT_u_cpu_detect += -Wno-pointer-sign
CC_OPT_u_debug_stack += -Wno-unused-but-set-variable
CC_OPT_u_format_access += -Wno-unused
CC_OPT_vl_mpeg12_mc_renderer += -Wno-enum-compare
PYTHON2 := $(VERBOSE)$(lastword $(shell which python2 python2.{4,5,6,7,8}))
u_%_gen.c: $(GALLIUM_SRC_DIR)/indices/u_%_gen.py
$(MSG_CONVERT)$@
$(PYTHON2) $< > $@
#
# To generate 'u_format_pack.h' as well, so we explicitly state that
# 'u_format_access.c' depends on it.
#
u_format_access.c: u_format_pack.h
u_format_%.c u_format_%.h: $(GALLIUM_AUX_SRC_DIR)/util/u_format_%.py
$(MSG_CONVERT)$@
$(PYTHON2) $< $(GALLIUM_AUX_SRC_DIR)/util/u_format.csv > $@
vpath %.c $(addprefix $(GALLIUM_AUX_SRC_DIR)/,$(SUBDIRS))

View File

@ -1,44 +0,0 @@
include $(REP_DIR)/lib/mk/gallium.inc
EGL_ST_SRC_DIR := $(MESA_PORT_DIR)/src/lib/mesa/src/gallium/state_trackers/egl
INC_DIR += $(EGL_ST_SRC_DIR)
INC_DIR += $(MESA_PORT_DIR)/src/lib/mesa/src/egl/main
INC_DIR += $(MESA_PORT_DIR)/src/lib/mesa/src/gallium
CC_OPT += -DRTLD_NODELETE=0
# generic driver code
SRC_C := $(notdir $(wildcard $(EGL_ST_SRC_DIR)/common/*.c))
vpath %.c $(EGL_ST_SRC_DIR)/common
# state tracker declarations for OpenGL ES1 and ES2
SRC_C += st_es1.c st_es2.c
vpath %.c $(MESA_PORT_DIR)/src/lib/mesa/src/gallium/state_trackers/es
# state tracker declarations for OpenGL
SRC_C += st_opengl.c
vpath st_opengl.c $(REP_DIR)/src/lib/egl
# Genode-specific driver code
SRC_CC += driver.cc select_driver.cc
vpath driver.cc $(REP_DIR)/src/lib/egl
vpath select_driver.cc $(REP_DIR)/src/lib/egl
LIBS += blit
# MESA state tracker code
MESA_ST_SRC_DIR := $(MESA_PORT_DIR)/src/lib/mesa/src/mesa/state_tracker
INC_DIR += $(MESA_ST_SRC_DIR)
INC_DIR += $(MESA_PORT_DIR)/src/lib/mesa/src/mesa/main
INC_DIR += $(MESA_PORT_DIR)/src/lib/mesa/src/mesa
SRC_C += $(notdir $(wildcard $(MESA_ST_SRC_DIR)/*.c))
vpath %.c $(MESA_ST_SRC_DIR)
# dim warning noise
CC_OPT_st_atom_pixeltransfer += -Wno-unused-but-set-variable
CC_OPT_st_cb_drawpixels += -Wno-unused-but-set-variable
CC_OPT_st_cb_texture += -Wno-strict-aliasing
CC_OPT_st_cb_texture += -Wno-unused-but-set-variable
CC_OPT_st_framebuffer += -Wno-strict-aliasing
CC_OPT_st_program += -Wno-unused-but-set-variable
CC_OPT_st_texture += -Wno-unused-but-set-variable

View File

@ -1,5 +0,0 @@
include $(REP_DIR)/lib/mk/gallium.inc
SRC_C := $(notdir $(wildcard $(GALLIUM_SRC_DIR)/drivers/failover/*.c))
vpath %.c $(GALLIUM_SRC_DIR)/drivers/failover

View File

@ -1,32 +0,0 @@
#
# Gallium driver for i915, loaded as needed at runtime (via 'dlopen')
#
REQUIRES += i915
include $(REP_DIR)/lib/mk/gallium.inc
# i915 driver
SRC_C := $(notdir $(wildcard $(GALLIUM_SRC_DIR)/drivers/i915/*.c))
vpath %.c $(GALLIUM_SRC_DIR)/drivers/i915
# dummy stub for trace driver
SRC_C += dummy_trace.c
vpath dummy_trace.c $(REP_DIR)/src/lib/gallium
INC_DIR += $(GALLIUM_SRC_DIR)/drivers/trace
SRC_CC += query_device_id.cc
vpath query_device_id.cc $(REP_DIR)/src/lib/gallium/i915
# libdrm includes
LIBDRM_DIR := $(call select_from_ports,libdrm)/src/lib/libdrm
INC_DIR += $(LIBDRM_DIR)/include/drm $(LIBDRM_DIR)/intel
# interface to i915 drm device
SRC_C += $(notdir $(wildcard $(GALLIUM_SRC_DIR)/winsys/drm/intel/gem/*.c))
vpath %.c $(GALLIUM_SRC_DIR)/winsys/drm/intel/gem
LIBS += libdrm
LIBS += gpu_i915_drv
SHARED_LIB = yes

View File

@ -1,5 +0,0 @@
include $(REP_DIR)/lib/mk/gallium.inc
SRC_C := $(notdir $(wildcard $(GALLIUM_SRC_DIR)/drivers/identity/*.c))
vpath %.c $(GALLIUM_SRC_DIR)/drivers/identity

View File

@ -1,5 +0,0 @@
include $(REP_DIR)/lib/mk/gallium.inc
SRC_C := $(notdir $(wildcard $(GALLIUM_SRC_DIR)/drivers/softpipe/*.c))
vpath %.c $(GALLIUM_SRC_DIR)/drivers/softpipe

View File

@ -1,5 +0,0 @@
include $(REP_DIR)/lib/mk/gallium.inc
SRC_C := $(notdir $(wildcard $(GALLIUM_SRC_DIR)/drivers/trace/*.c))
vpath %.c $(GALLIUM_SRC_DIR)/drivers/trace

View File

@ -1,20 +0,0 @@
MESA_PORT_DIR := $(call select_from_ports,mesa)
GALLIUM_SRC_DIR := $(MESA_PORT_DIR)/src/lib/mesa/src/gallium
LIBS += libc libm mesa_host_tools
INC_DIR += $(GALLIUM_SRC_DIR)/include \
$(GALLIUM_SRC_DIR)/auxiliary \
$(GALLIUM_SRC_DIR)/auxiliary/util \
$(GALLIUM_SRC_DIR)/drivers \
$(MESA_PORT_DIR)/include
CC_OPT += -U__linux__
#
# Prevent double definition of 'ushort' and 'uint' in 'pipe/p_compiler.h' and
# 'libc/sys/types.h'. By defining '__USE_MISC', we suppress the first one.
# However, because the libc headers are not included by all gallium sources
# that include 'p_compiler.h', we unconditionally include 'sys/types.h'.
#
CC_OPT += -D__USE_MISC -include sys/types.h

View File

@ -1,8 +0,0 @@
#
# Aggregate all libraries needed to build a gallium-based GL application
#
LIBS = libc libm pthread mesa mesa-egl gallium-aux gallium-egl gallium-softpipe
SHARED_LIB = yes
include $(REP_DIR)/lib/mk/gallium.inc

View File

@ -0,0 +1,16 @@
SHARED_LIB = yes
LIBS = libc
include $(REP_DIR)/lib/mk/mesa-common.inc
SRC_C = mapi/entry.c \
mapi/mapi_glapi.c \
mapi/stub.c \
mapi/table.c \
mapi/u_current.c \
mapi/u_execmem.c
CC_OPT += -DMAPI_ABI_HEADER=\"shared-glapi/glapi_mapi_tmp.h\" -DMAPI_MODE_GLAPI
vpath %.c $(MESA_PORT_DIR)/src

View File

@ -0,0 +1,228 @@
LIBS = libc drm
include $(REP_DIR)/lib/mk/mesa-common.inc
I965_COMPILER_FILES = \
brw_compiler.c \
brw_device_info.c \
brw_disasm.c \
brw_eu.c \
brw_eu_compact.c \
brw_eu_emit.c \
brw_eu_util.c \
brw_eu_validate.c \
brw_interpolation_map.c \
brw_nir.c \
brw_nir_analyze_boolean_resolves.c \
brw_nir_attribute_workarounds.c \
brw_nir_opt_peephole_ffma.c \
brw_packed_float.c \
brw_surface_formats.c \
brw_util.c \
brw_vue_map.c \
intel_asm_annotation.c \
intel_debug.c \
intel_resolve_map.c
I965_COMPILER_FILES_CXX = \
brw_cfg.cpp \
brw_dead_control_flow.cpp \
brw_fs_cmod_propagation.cpp \
brw_fs_combine_constants.cpp \
brw_fs_copy_propagation.cpp \
brw_fs.cpp \
brw_fs_cse.cpp \
brw_fs_dead_code_eliminate.cpp \
brw_fs_generator.cpp \
brw_fs_live_variables.cpp \
brw_fs_nir.cpp \
brw_fs_reg_allocate.cpp \
brw_fs_register_coalesce.cpp \
brw_fs_saturate_propagation.cpp \
brw_fs_sel_peephole.cpp \
brw_fs_surface_builder.cpp \
brw_fs_validate.cpp \
brw_fs_visitor.cpp \
brw_nir_uniforms.cpp \
brw_predicated_break.cpp \
brw_schedule_instructions.cpp \
brw_shader.cpp \
brw_vec4_cmod_propagation.cpp \
brw_vec4_copy_propagation.cpp \
brw_vec4.cpp \
brw_vec4_cse.cpp \
brw_vec4_dead_code_eliminate.cpp \
brw_vec4_generator.cpp \
brw_vec4_gs_visitor.cpp \
brw_vec4_live_variables.cpp \
brw_vec4_nir.cpp \
brw_vec4_gs_nir.cpp \
brw_vec4_reg_allocate.cpp \
brw_vec4_surface_builder.cpp \
brw_vec4_tcs.cpp \
brw_vec4_tes.cpp \
brw_vec4_visitor.cpp \
brw_vec4_vs_visitor.cpp \
brw_wm_iz.cpp \
gen6_gs_visitor.cpp
I965_FILES = \
brw_binding_tables.c \
brw_cc.c \
brw_clear.c \
brw_clip.c \
brw_clip_line.c \
brw_clip_point.c \
brw_clip_state.c \
brw_clip_tri.c \
brw_clip_unfilled.c \
brw_clip_util.c \
brw_compute.c \
brw_conditional_render.c \
brw_context.c \
brw_cs.c \
brw_curbe.c \
brw_draw.c \
brw_draw_upload.c \
brw_ff_gs.c \
brw_ff_gs_emit.c \
brw_gs.c \
brw_gs_state.c \
brw_gs_surface_state.c \
brw_meta_fast_clear.c \
brw_meta_stencil_blit.c \
brw_meta_updownsample.c \
brw_meta_util.c \
brw_misc_state.c \
brw_object_purgeable.c \
brw_performance_monitor.c \
brw_pipe_control.c \
brw_program.c \
brw_primitive_restart.c \
brw_queryobj.c \
brw_reset.c \
brw_sampler_state.c \
brw_sf.c \
brw_sf_emit.c \
brw_sf_state.c \
brw_state_batch.c \
brw_state_cache.c \
brw_state_dump.c \
brw_state_upload.c \
brw_tcs.c \
brw_tcs_surface_state.c \
brw_tes.c \
brw_tes_surface_state.c \
brw_tex.c \
brw_tex_layout.c \
brw_urb.c \
brw_vs.c \
brw_vs_state.c \
brw_vs_surface_state.c \
brw_wm.c \
brw_wm_state.c \
brw_wm_surface_state.c \
gen6_cc.c \
gen6_clip_state.c \
gen6_constant_state.c \
gen6_depth_state.c \
gen6_depthstencil.c \
gen6_gs_state.c \
gen6_multisample_state.c \
gen6_queryobj.c \
gen6_sampler_state.c \
gen6_scissor_state.c \
gen6_sf_state.c \
gen6_sol.c \
gen6_surface_state.c \
gen6_urb.c \
gen6_viewport_state.c \
gen6_vs_state.c \
gen6_wm_state.c \
gen7_cs_state.c \
gen7_ds_state.c \
gen7_gs_state.c \
gen7_hs_state.c \
gen7_l3_state.c \
gen7_misc_state.c \
gen7_sf_state.c \
gen7_sol_state.c \
gen7_te_state.c \
gen7_urb.c \
gen7_viewport_state.c \
gen7_vs_state.c \
gen7_wm_state.c \
gen7_wm_surface_state.c \
gen8_blend_state.c \
gen8_depth_state.c \
gen8_disable.c \
gen8_draw_upload.c \
gen8_ds_state.c \
gen8_gs_state.c \
gen8_hs_state.c \
gen8_misc_state.c \
gen8_multisample_state.c \
gen8_ps_state.c \
gen8_sf_state.c \
gen8_sol_state.c \
gen8_surface_state.c \
gen8_viewport_state.c \
gen8_vs_state.c \
gen8_wm_depth_stencil.c \
intel_batchbuffer.c \
intel_blit.c \
intel_buffer_objects.c \
intel_buffers.c \
intel_copy_image.c \
intel_extensions.c \
intel_fbo.c \
intel_mipmap_tree.c \
intel_pixel_bitmap.c \
intel_pixel.c \
intel_pixel_copy.c \
intel_pixel_draw.c \
intel_pixel_read.c \
intel_screen.c \
intel_state.c \
intel_syncobj.c \
intel_tex.c \
intel_tex_copy.c \
intel_tex_image.c \
intel_tex_subimage.c \
intel_tex_validate.c \
intel_tiled_memcpy.c \
intel_upload.c
I965_FILES_CXX = \
brw_blorp_blit.cpp \
brw_blorp_blit_eu.cpp \
brw_blorp.cpp \
brw_cubemap_normalize.cpp \
brw_fs_channel_expressions.cpp \
brw_fs_vector_splitting.cpp \
brw_link.cpp \
brw_lower_texture_gradients.cpp \
brw_lower_unnormalized_offset.cpp \
gen6_blorp.cpp \
gen7_blorp.cpp
INC_DIR += $(MESA_SRC_DIR)/drivers/dri/common
SRC_C = $(addprefix drivers/dri/i965/,$(I965_COMPILER_FILES) $(I965_FILES))
SRC_CC = $(addprefix drivers/dri/i965/,$(I965_COMPILER_FILES_CXX) $(I965_FILES_CXX))
SRC_C += bo_map.c
CC_OPT = -DHAVE_PTHREAD -DFFS_DEFINED=1
CC_C_OPT = -std=c99
CC_CXX_OPT += -D__STDC_LIMIT_MACROS
#
# special flags
#
CC_OPT_drivers/dri/i965/brw_fs_combine_constants = -D__BSD_VISIBLE
vpath %.c $(REP_DIR)/src/lib/mesa/i965
vpath %.c $(MESA_SRC_DIR)
vpath %.cpp $(MESA_SRC_DIR)

View File

@ -1,11 +0,0 @@
SRC_C = intel_bufmgr_gem.c intel_bufmgr.c ioctl.cc
LIBDRM_DIR := $(call select_from_ports,libdrm)/src/lib/libdrm
INC_DIR += $(LIBDRM_DIR) $(LIBDRM_DIR)/include/drm $(LIBDRM_DIR)/intel
LIBS += libc
CC_OPT += -U__linux__
CC_OPT += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
vpath %.c $(LIBDRM_DIR)/intel
vpath ioctl.cc $(REP_DIR)/src/lib/libdrm

View File

@ -0,0 +1,22 @@
MESA_PORT_DIR := $(call select_from_ports,mesa)/src/lib/mesa
MESA_SRC_DIR := $(MESA_PORT_DIR)/src/mesa
LIB_DIR := $(REP_DIR)/src/lib/mesa
INC_DIR += $(MESA_SRC_DIR) \
$(MESA_SRC_DIR)/main \
$(MESA_SRC_DIR)/x86 \
$(MESA_PORT_DIR) \
$(MESA_PORT_DIR)/include \
$(MESA_PORT_DIR)/src \
$(MESA_PORT_DIR)/src/mapi \
$(MESA_PORT_DIR)/src/gallium/auxiliary \
$(MESA_PORT_DIR)/src/gallium/include \
$(LIB_DIR)/include
CC_OPT += -DHAVE_PTHREAD -D_XOPEN_SOURCE=600 -DDEFAULT_DRIVER_DIR=\"\ \"
CC_WARN += -Wno-return-type
CC_C_OPT +=-Wno-implicit-function-declaration
# vi: set ft=make :

View File

@ -1,13 +0,0 @@
include $(REP_DIR)/lib/mk/mesa.inc
SRC_C := $(notdir $(wildcard $(MESA_PORT_DIR)/src/lib/mesa/src/egl/main/*.c))
CC_OPT += -D_EGL_DRIVER_SEARCH_DIR=\"\"
CC_OPT += -D_EGL_DEFAULT_DISPLAY=\"\"
CC_OPT += -U__unix__ -U__unix
# dim warning noise
CC_OPT_eglconfig += -Wno-uninitialized
vpath %.c $(MESA_PORT_DIR)/src/lib/mesa/src/egl/main

View File

@ -1,17 +1,482 @@
MESA_PORT_DIR := $(call select_from_ports,mesa)
MESA_SRC_DIR := $(MESA_PORT_DIR)/src/lib/mesa/src/mesa
SHARED_LIB = yes
LIBS = libc stdcxx expat glapi pthread
LIBS += libc libm mesa_host_tools
include $(REP_DIR)/lib/mk/mesa-common.inc
MAIN_ES_FILES = \
main/es1_conversion.c
MAIN_FILES = \
main/accum.c \
main/api_arrayelt.c \
main/api_exec.c \
main/api_loopback.c \
main/api_validate.c \
main/arbprogram.c \
main/arrayobj.c \
main/atifragshader.c \
main/attrib.c \
main/blend.c \
main/blit.c \
main/bufferobj.c \
main/buffers.c \
main/clear.c \
main/clip.c \
main/colortab.c \
main/compute.c \
main/condrender.c \
main/context.c \
main/convolve.c \
main/copyimage.c \
main/cpuinfo.c \
main/debug.c \
main/debug_output.c \
main/depth.c \
main/dlist.c \
main/drawpix.c \
main/drawtex.c \
main/enable.c \
main/enums.c \
main/errors.c \
main/eval.c \
main/execmem.c \
main/extensions.c \
main/fbobject.c \
main/feedback.c \
main/ffvertex_prog.c \
main/fog.c \
main/format_pack.c \
main/format_unpack.c \
main/formatquery.c \
main/formats.c \
main/format_utils.c \
main/framebuffer.c \
main/get.c \
main/genmipmap.c \
main/getstring.c \
main/glformats.c \
main/hash.c \
main/hint.c \
main/histogram.c \
main/image.c \
main/imports.c \
main/light.c \
main/lines.c \
main/matrix.c \
main/mipmap.c \
main/mm.c \
main/multisample.c \
main/objectlabel.c \
main/objectpurge.c \
main/pack.c \
main/pbo.c \
main/performance_monitor.c \
main/pipelineobj.c \
main/pixel.c \
main/pixelstore.c \
main/pixeltransfer.c \
main/points.c \
main/polygon.c \
main/program_resource.c \
main/querymatrix.c \
main/queryobj.c \
main/rastpos.c \
main/readpix.c \
main/remap.c \
main/renderbuffer.c \
main/samplerobj.c \
main/scissor.c \
main/shaderapi.c \
main/shaderimage.c \
main/shaderobj.c \
main/shared.c \
main/state.c \
main/stencil.c \
main/syncobj.c \
main/texcompress.c \
main/texcompress_bptc.c \
main/texcompress_cpal.c \
main/texcompress_etc.c \
main/texcompress_fxt1.c \
main/texcompress_rgtc.c \
main/texcompress_s3tc.c \
main/texenv.c \
main/texformat.c \
main/texgen.c \
main/texgetimage.c \
main/teximage.c \
main/texobj.c \
main/texparam.c \
main/texstate.c \
main/texstorage.c \
main/texstore.c \
main/textureview.c \
main/texturebarrier.c \
main/transformfeedback.c \
main/uniforms.c \
main/varray.c \
main/vdpau.c \
main/version.c \
main/viewport.c \
main/vtxfmt.c
MAIN_FILES_CC = \
main/ff_fragment_shader.cpp \
main/shader_query.cpp \
main/uniform_query.cpp \
MATH_FILES = \
math/m_debug_clip.c \
math/m_debug_norm.c \
math/m_debug_xform.c \
math/m_eval.c \
math/m_matrix.c \
math/m_translate.c \
math/m_vector.c \
MATH_XFORM_FILES = \
math/m_xform.c \
VBO_FILES = \
vbo/vbo_context.c \
vbo/vbo_exec_api.c \
vbo/vbo_exec_array.c \
vbo/vbo_exec.c \
vbo/vbo_exec_draw.c \
vbo/vbo_exec_eval.c \
vbo/vbo_minmax_index.c \
vbo/vbo_noop.c \
vbo/vbo_primitive_restart.c \
vbo/vbo_rebase.c \
vbo/vbo_save_api.c \
vbo/vbo_save.c \
vbo/vbo_save_draw.c \
vbo/vbo_save_loopback.c \
vbo/vbo_split.c \
vbo/vbo_split_copy.c \
vbo/vbo_split_inplace.c
TNL_FILES = \
tnl/t_context.c \
tnl/t_draw.c \
tnl/t_pipeline.c \
tnl/t_vb_fog.c \
tnl/t_vb_light.c \
tnl/t_vb_normals.c \
tnl/t_vb_points.c \
tnl/t_vb_program.c \
tnl/t_vb_render.c \
tnl/t_vb_texgen.c \
tnl/t_vb_texmat.c \
tnl/t_vb_vertex.c \
tnl/t_vertex.c \
tnl/t_vertex_generic.c \
tnl/t_vertex_sse.c \
tnl/t_vp_build.c \
SWRAST_FILES = \
swrast/s_aaline.c \
swrast/s_aatriangle.c \
swrast/s_alpha.c \
swrast/s_atifragshader.c \
swrast/s_bitmap.c \
swrast/s_blend.c \
swrast/s_blit.c \
swrast/s_clear.c \
swrast/s_context.c \
swrast/s_copypix.c \
swrast/s_depth.c \
swrast/s_drawpix.c \
swrast/s_feedback.c \
swrast/s_fog.c \
swrast/s_fragprog.c \
swrast/s_lines.c \
swrast/s_logic.c \
swrast/s_masking.c \
swrast/s_points.c \
swrast/s_renderbuffer.c \
swrast/s_span.c \
swrast/s_stencil.c \
swrast/s_texcombine.c \
swrast/s_texfetch.c \
swrast/s_texfilter.c \
swrast/s_texrender.c \
swrast/s_texture.c \
swrast/s_triangle.c \
swrast/s_zoom.c \
SWRAST_SETUP_FILES = \
swrast_setup/ss_context.c \
swrast_setup/ss_triangle.c \
COMMON_DRIVER_FILES = \
drivers/common/driverfuncs.c \
drivers/common/meta_blit.c \
drivers/common/meta_copy_image.c \
drivers/common/meta_generate_mipmap.c \
drivers/common/meta_tex_subimage.c \
drivers/common/meta.c \
ASM_C_FILES += \
x86/common_x86.c \
x86/x86_xform.c \
x86/sse.c \
x86/rtasm/x86sse.c \
sparc/sparc.c \
PROGRAM = \
program/arbprogparse.c \
program/lex.yy.c \
program/prog_cache.c \
program/prog_execute.c \
program/prog_hash_table.c \
program/prog_instruction.c \
program/prog_noise.c \
program/prog_opt_constant_fold.c \
program/prog_optimize.c \
program/prog_parameter.c \
program/prog_parameter_layout.c \
program/prog_print.c \
program/prog_statevars.c \
program/prog_to_nir.c \
program/program.c \
program/programopt.c \
program/program_parse.tab.c \
program/program_parse_extra.c \
program/symbol_table.c
PROGRAM_CXX = \
program/ir_to_mesa.cpp \
program/string_to_uint_map.cpp
MAPI_FILES = \
mapi/entry.c
UTIL = \
util/debug.c \
util/format_srgb.c \
util/half_float.c \
util/hash_table.c \
util/ralloc.c \
util/register_allocate.c \
util/rgtc.c \
util/set.c \
util/strtod.c
GLSL = \
glsl/blob.c \
glsl/glcpp/glcpp-lex.c \
glsl/glcpp/glcpp-parse.c \
glsl/glcpp/pp.c
GLSL_CXX = \
glsl/ast_array_index.cpp \
glsl/ast_expr.cpp \
glsl/ast_function.cpp \
glsl/ast_to_hir.cpp \
glsl/ast_type.cpp \
glsl/builtin_functions.cpp \
glsl/builtin_types.cpp \
glsl/builtin_variables.cpp \
glsl/glsl_lexer.cpp \
glsl/glsl_parser.cpp \
glsl/glsl_parser_extras.cpp \
glsl/glsl_symbol_table.cpp \
glsl/hir_field_selection.cpp \
glsl/ir_basic_block.cpp \
glsl/ir_builder.cpp \
glsl/ir_clone.cpp \
glsl/ir_constant_expression.cpp \
glsl/ir.cpp \
glsl/ir_equals.cpp \
glsl/ir_expression_flattening.cpp \
glsl/ir_function_can_inline.cpp \
glsl/ir_function_detect_recursion.cpp \
glsl/ir_function.cpp \
glsl/ir_hierarchical_visitor.cpp \
glsl/ir_hv_accept.cpp \
glsl/ir_import_prototypes.cpp \
glsl/ir_print_visitor.cpp \
glsl/ir_reader.cpp \
glsl/ir_rvalue_visitor.cpp \
glsl/ir_set_program_inouts.cpp \
glsl/ir_validate.cpp \
glsl/ir_variable_refcount.cpp \
glsl/linker.cpp \
glsl/link_atomics.cpp \
glsl/link_functions.cpp \
glsl/link_interface_blocks.cpp \
glsl/link_uniforms.cpp \
glsl/link_uniform_initializers.cpp \
glsl/link_uniform_block_active_visitor.cpp \
glsl/link_uniform_blocks.cpp \
glsl/link_varyings.cpp \
glsl/loop_analysis.cpp \
glsl/loop_controls.cpp \
glsl/loop_unroll.cpp \
glsl/lower_buffer_access.cpp \
glsl/lower_clip_distance.cpp \
glsl/lower_const_arrays_to_uniforms.cpp \
glsl/lower_discard.cpp \
glsl/lower_discard_flow.cpp \
glsl/lower_if_to_cond_assign.cpp \
glsl/lower_instructions.cpp \
glsl/lower_jumps.cpp \
glsl/lower_mat_op_to_vec.cpp \
glsl/lower_noise.cpp \
glsl/lower_offset_array.cpp \
glsl/lower_packed_varyings.cpp \
glsl/lower_named_interface_blocks.cpp \
glsl/lower_packing_builtins.cpp \
glsl/lower_subroutine.cpp \
glsl/lower_tess_level.cpp \
glsl/lower_texture_projection.cpp \
glsl/lower_variable_index_to_cond_assign.cpp \
glsl/lower_vec_index_to_cond_assign.cpp \
glsl/lower_vec_index_to_swizzle.cpp \
glsl/lower_vector.cpp \
glsl/lower_vector_derefs.cpp \
glsl/lower_vector_insert.cpp \
glsl/lower_vertex_id.cpp \
glsl/lower_output_reads.cpp \
glsl/lower_shared_reference.cpp \
glsl/lower_ubo_reference.cpp \
glsl/opt_algebraic.cpp \
glsl/opt_array_splitting.cpp \
glsl/opt_conditional_discard.cpp \
glsl/opt_constant_folding.cpp \
glsl/opt_constant_propagation.cpp \
glsl/opt_constant_variable.cpp \
glsl/opt_copy_propagation.cpp \
glsl/opt_copy_propagation_elements.cpp \
glsl/opt_dead_builtin_variables.cpp \
glsl/opt_dead_builtin_varyings.cpp \
glsl/opt_dead_code.cpp \
glsl/opt_dead_code_local.cpp \
glsl/opt_dead_functions.cpp \
glsl/opt_flatten_nested_if_blocks.cpp \
glsl/opt_flip_matrices.cpp \
glsl/opt_function_inlining.cpp \
glsl/opt_if_simplification.cpp \
glsl/opt_minmax.cpp \
glsl/opt_noop_swizzle.cpp \
glsl/opt_rebalance_tree.cpp \
glsl/opt_redundant_jumps.cpp \
glsl/opt_structure_splitting.cpp \
glsl/opt_swizzle_swizzle.cpp \
glsl/opt_tree_grafting.cpp \
glsl/opt_vectorize.cpp \
glsl/s_expression.cpp
LIBCOMPILER_CXX = \
glsl_types.cpp \
nir_types.cpp
LIBCOMPILER = \
shader_enums.c
DRI = \
drivers/dri/common/dri_util.c \
drivers/dri/common/megadriver_stub.c \
drivers/dri/common/utils.c \
drivers/dri/common/xmlconfig.c
NIR = \
compiler/nir/nir.c \
compiler/nir/nir_clone.c \
compiler/nir/nir_constant_expressions.c \
compiler/nir/nir_control_flow.c \
compiler/nir/nir_dominance.c \
compiler/nir/nir_from_ssa.c \
compiler/nir/nir_instr_set.c \
compiler/nir/nir_intrinsics.c \
compiler/nir/nir_gs_count_vertices.c \
compiler/nir/nir_liveness.c \
compiler/nir/nir_lower_alu_to_scalar.c \
compiler/nir/nir_lower_atomics.c \
compiler/nir/nir_lower_global_vars_to_local.c \
compiler/nir/nir_lower_gs_intrinsics.c \
compiler/nir/nir_lower_io.c \
compiler/nir/nir_lower_load_const_to_scalar.c \
compiler/nir/nir_lower_locals_to_regs.c \
compiler/nir/nir_lower_outputs_to_temporaries.c \
compiler/nir/nir_lower_phis_to_scalar.c \
compiler/nir/nir_lower_samplers.c \
compiler/nir/nir_lower_system_values.c \
compiler/nir/nir_lower_to_source_mods.c \
compiler/nir/nir_lower_tex.c \
compiler/nir/nir_lower_vars_to_ssa.c \
compiler/nir/nir_lower_var_copies.c \
compiler/nir/nir_lower_vec_to_movs.c \
compiler/nir/nir_metadata.c \
compiler/nir/nir_move_vec_src_uses_to_dest.c \
compiler/nir/nir_normalize_cubemap_coords.c \
compiler/nir/nir_opcodes.c \
compiler/nir/nir_opt_algebraic.c \
compiler/nir/nir_opt_constant_folding.c \
compiler/nir/nir_opt_copy_propagate.c \
compiler/nir/nir_opt_cse.c \
compiler/nir/nir_opt_dce.c \
compiler/nir/nir_opt_dead_cf.c \
compiler/nir/nir_opt_peephole_select.c \
compiler/nir/nir_opt_remove_phis.c \
compiler/nir/nir_opt_undef.c \
compiler/nir/nir_print.c \
compiler/nir/nir_remove_dead_variables.c \
compiler/nir/nir_search.c \
compiler/nir/nir_split_var_copies.c \
compiler/nir/nir_sweep.c \
compiler/nir/nir_to_ssa.c \
compiler/nir/nir_worklist.c
NIR_CXX = \
nir/glsl_to_nir.cpp
SRC_C = \
$(MAIN_ES_FILES) \
$(MAIN_FILES) \
$(MATH_FILES) \
$(MAPI_FILES) \
$(MATH_XFORM_FILES) \
$(VBO_FILES) \
$(TNL_FILES) \
$(SWRAST_FILES) \
$(SWRAST_SETUP_FILES) \
$(COMMON_DRIVER_FILES) \
$(ASM_C_FILES) \
$(PROGRAM) \
$(UTIL) \
$(GLSL) \
$(LIBCOMPILER) \
$(DRI) \
$(NIR)
SRC_CC = $(MAIN_FILES_CC) $(GLSL_CXX) $(LIBCOMPILER_CXX) $(PROGRAM_CXX) $(NIR_CXX)
CC_OPT += -DPACKAGE_VERSION=\"11.2.2\" \
-DPACKAGE_BUGREPORT=\"https://bugs.freedesktop.org/enter_bug.cgi\?product=Mesa\" \
-DMAPI_ABI_HEADER=\"glapi/glapi_mapi_tmp.h\" \
-DMAPI_MODE_BRIDGE
#XXX: for debugging
CC_OPT += -gdwarf-2
CC_C_OPT += -std=c99
CC_CXX_OPT += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
#
# Prevent warning about non-existing 'fpu_control.h' included
# by 'mesa/main/compiler.h' if '__linux__' is defined.
# special flags
#
CC_OPT += -U__linux__
CC_OPT_glsl/linker = -D__BSD_VISIBLE
CC_OPT_compiler/nir/nir_from_ssa = -D__BSD_VISIBLE -DFFS_DEFINED=1
CC_OPT_compiler/nir/nir_instr_set = -D__BSD_VISIBLE -DFFS_DEFINED=1
CC_OPT_compiler/nir/nir_liveness = -D__BSD_VISIBLE -DFFS_DEFINED=1
CC_OPT_compiler/nir/nir_lower_vars_to_ssa = -D__BSD_VISIBLE -DFFS_DEFINED=1
INC_DIR += $(MESA_PORT_DIR)/src/lib/mesa/src/mesa \
$(MESA_PORT_DIR)/src/lib/mesa/src/gallium/include \
$(MESA_PORT_DIR)/src/lib/mesa/src/gallium/auxiliary \
$(MESA_PORT_DIR)/include
vpath %.c $(MESA_SRC_DIR)
vpath %.cpp $(MESA_SRC_DIR)
vpath %.c $(MESA_PORT_DIR)/src
vpath %.cpp $(MESA_PORT_DIR)/src/compiler
vpath %.c $(MESA_PORT_DIR)/src/compiler
#SHARED_LIB = yes
# vi: set ft=make :

View File

@ -1,65 +0,0 @@
include $(REP_DIR)/lib/mk/mesa.inc
MESA_SUBDIRS = main math vbo shader shader/slang glapi
# collect all source codes in 'MESA_SUBDIRS'
SRC_C := $(foreach subdir,$(MESA_SUBDIRS),$(wildcard $(MESA_SRC_DIR)/$(subdir)/*.c))
# prevent definition conflicts in lex.yy.c with libc
CC_OPT_lex_yy += -DFLEXINT_H -include inttypes.h -Dflex_int32_t=int32_t -Dflex_int16_t=int16_t
# dim warning noise for compiling contrib code
CC_OPT_bufferobj += -Wno-unused-but-set-variable
CC_OPT_dlist += -Wno-unused-but-set-variable
CC_OPT_glapi += -Wno-strict-aliasing
CC_OPT_lex_yy += -Wno-unused-function
CC_OPT_prog_print += -Wno-format
CC_OPT_program += -Wno-enum-compare
CC_OPT_shader_api += -Wno-unused-but-set-variable
CC_OPT_slang_emit += -Wno-unused-but-set-variable
CC_OPT_st_cb_texture += -Wno-strict-aliasing
CC_OPT_texcompress_s3tc += -Wno-unused-but-set-variable
CC_OPT_varray += -Wno-format
# glsl library
GLSL_SRC_DIR = $(MESA_PORT_DIR)/src/lib/mesa/src/glsl
GLSL_SUBDIRS = pp cl
SRC_C += $(foreach subdir,$(GLSL_SUBDIRS),$(wildcard $(GLSL_SRC_DIR)/$(subdir)/*.c))
# strip leading directories - keep only the file names
SRC_C := $(notdir $(SRC_C))
# remove non-needed files from list
SRC_C := $(filter-out vsnprintf.c,$(SRC_C))
vpath %.c $(addprefix $(MESA_SRC_DIR)/,$(MESA_SUBDIRS))
vpath %.c $(addprefix $(GLSL_SRC_DIR)/,$(GLSL_SUBDIRS))
#
# Compile built-in fragment and vertex shaders
#
# The shader programs are compiled to header files in a
# 'library/' subdirectory, which are then included by mesa's
# 'shader/slang' module.
#
SRC_GC := $(wildcard $(MESA_SRC_DIR)/shader/slang/library/*.gc)
GEN_GC_H := $(notdir $(SRC_GC:.gc=_gc.h))
# make sure that the shaders are compiled prior the mesa source codes
$(SRC_C:.c=.o): $(addprefix library/,$(GEN_GC_H))
$(addprefix library/,$(GEN_GC_H)): library
library:
$(VERBOSE)mkdir -p $@
library/%_gc.h: %.gc
$(MSG_CONVERT)$@
$(VERBOSE)$(BUILD_BASE_DIR)/tool/mesa/glsl/compiler fragment $< $@
library/slang_vertex_builtin_gc.h: slang_vertex_builtin.gc
$(MSG_CONVERT)$@
$(VERBOSE)$(BUILD_BASE_DIR)/tool/mesa/glsl/compiler vertex $< $@
vpath %.gc $(MESA_SRC_DIR)/shader/slang/library

View File

@ -1,21 +0,0 @@
#
# Build shader compiler as host tool
#
MESA_PORT_DIR := $(call select_from_ports,mesa)
GLSL_COMPILER := $(BUILD_BASE_DIR)/tool/mesa/glsl/compiler
HOST_TOOLS += $(GLSL_COMPILER)
GLSL_SRC_C := $(wildcard $(MESA_PORT_DIR)/src/lib/mesa/src/glsl/pp/*.c) \
$(wildcard $(MESA_PORT_DIR)/src/lib/mesa/src/glsl/cl/*.c) \
$(MESA_PORT_DIR)/src/lib/mesa/src/glsl/apps/compile.c
GLSL_CFLAGS = -I$(MESA_PORT_DIR)/src/lib/mesa/src/glsl/pp \
-I$(MESA_PORT_DIR)/src/lib/mesa/src/glsl/cl
$(GLSL_COMPILER): $(GLSL_SRC_C)
$(MSG_BUILD)tool/mesa/glsl/compiler
$(VERBOSE)mkdir -p $(dir $@)
$(VERBOSE)$(HOST_CC) $(GLSL_CFLAGS) $(GLSL_SRC_C) -o $@

View File

@ -32,7 +32,7 @@ INC_DIR += $(QT5_CONTRIB_DIR)/qtbase/src/platformsupport/eventdispatchers \
$(QT5_CONTRIB_DIR)/qtbase/include/QtCore/$(QT_VERSION) \
$(QT5_CONTRIB_DIR)/qtbase/include/QtCore/$(QT_VERSION)/QtCore
LIBS += qt5_xml qt5_gui qt5_core libm freetype gallium qoost
LIBS += qt5_xml qt5_gui qt5_core libm freetype mesa egl qoost
vpath % $(QT5_CONTRIB_DIR)/qtbase/src/platformsupport/eventdispatchers
vpath % $(QT5_CONTRIB_DIR)/qtbase/src/platformsupport/input/evdevkeyboard

View File

@ -0,0 +1 @@
include $(REP_DIR)/lib/mk/mesa.inc

View File

@ -0,0 +1 @@
include $(REP_DIR)/lib/mk/mesa.inc

View File

@ -0,0 +1,5 @@
include $(REP_DIR)/lib/mk/mesa.inc
ASM_C_FILES += x86-64/x86-64.c
INC_DIR += $(MESA_SRC_DIR)/x86_64

View File

@ -0,0 +1,8 @@
LIBS = libc
include $(REP_DIR)/lib/mk/mesa-common.inc
SRC_C = drivers/dri/swrast/swrast.c
INC_DIR += $(MESA_SRC_DIR)/drivers/dri/common
vpath %.c $(MESA_SRC_DIR)

View File

@ -1 +1 @@
abe06d02df59ba0624e97c92a91ab2d9806d4889
d82577300e8dcb9b7ce5a5a8c16c5121e9f67cfc

View File

@ -1,15 +1,70 @@
LICENSE := GPLv2
VERSION := 7.8.1
VERSION := 11.2.2
DOWNLOADS := mesa.archive
URL(mesa) := ftp://ftp.freedesktop.org/pub/mesa/older-versions/7.x/$(VERSION)/MesaLib-$(VERSION).tar.gz
SHA(mesa) := 74e72b56c7ae779649c18867fe9e0865f3bfc057
DIR(mesa) := src/lib/mesa
URL_BASE := https://mesa.freedesktop.org/archive/older-versions
URL(mesa) := $(URL_BASE)/11.x/$(VERSION)/mesa-$(VERSION).tar.gz
SHA(mesa) := af95222c289615638b3ab2c35564877a57c0c5db
PATCHES := src/lib/gallium/p_state_config.patch \
src/lib/egl/opengl_precision.patch
DIR(mesa) := src/lib/mesa
TAR_OPT(mesa) := --strip-components=1 --files-from $(REP_DIR)/src/lib/mesa/files.list
HASH_INPUT += $(REP_DIR)/src/lib/mesa/files.list
DIRS := include include/EGL
DIR_CONTENT(include) := $(addprefix src/lib/mesa/include/,GL KHR)
DIR_CONTENT(include/EGL) := $(addprefix src/lib/mesa/include/EGL/,egl.h eglext.h)
PATCHES := src/lib/mesa/patches/egl.patch
PATCH_OPT := -p1
#
# Check for tools
#
$(call check_tool,bison)
$(call check_tool,flex)
$(call check_tool,python)
#
# Generate files
#
generated_files = src/lib/mesa/src/compiler/glsl/glsl_parser.cpp \
src/lib/mesa/src/compiler/glsl/glsl_lexer.cpp \
src/lib/mesa/src/compiler/glsl/glcpp/glcpp-parse.c \
src/lib/mesa/src/compiler/glsl/glcpp/glcpp-lex.c \
src/lib/mesa/src/mesa/program/program_parse.tab.c \
src/lib/mesa/src/mesa/program/lex.yy.c \
src/lib/mesa/src/mapi/shared-glapi/glapi_mapi_tmp.h \
src/lib/mesa/src/compiler/glsl/glsl_parser.cpp:
@$(MSG_GENERATE)$(notdir $@)
$(VERBOSE)bison -o $@ -p "_mesa_glsl_" \
--defines=$(@D)/glsl_parser.h $(@D)/glsl_parser.yy
src/lib/mesa/src/compiler/glsl/glsl_lexer.cpp:
@$(MSG_GENERATE)$(notdir $@)
$(VERBOSE)flex -o $@ $(@D)/glsl_lexer.ll
src/lib/mesa/src/compiler/glsl/glcpp/glcpp-parse.c:
@$(MSG_GENERATE)$(notdir $@)
$(VERBOSE)bison -o $@ -p "glcpp_parser_" --defines=$(@D)/glcpp-parse.h \
$(@D)/glcpp-parse.y
src/lib/mesa/src/compiler/glsl/glcpp/glcpp-lex.c:
@$(MSG_GENERATE)$(notdir $@)
$(VERBOSE)flex -o $@ $(@D)/glcpp-lex.l
src/lib/mesa/src/mesa/program/program_parse.tab.c:
@$(MSG_GENERATE)$(notdir $@)
$(VERBOSE)bison -o $@ -p "_mesa_program_" --defines=$(@D)/program_parse.tab.h \
$(@D)/program_parse.y
src/lib/mesa/src/mesa/program/lex.yy.c:
@$(MSG_GENERATE)$(notdir $@)
$(VERBOSE)flex -o $@ $(@D)/program_lexer.l
src/lib/mesa/src/mapi/shared-glapi/glapi_mapi_tmp.h:
@$(MSG_GENERATE)$(notdir $@)
$(VERBOSE)mkdir -p $(@D)
$(VERBOSE)python $(@D)/../mapi_abi.py --mode lib --printer shared-glapi \
$(@D)/../glapi/gen/gl_and_es_API.xml > $@
default: $(DOWNLOADS) $(generated_files)
# vi: set ft=make :

View File

@ -1,422 +0,0 @@
/*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* 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
* BRIAN PAUL 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.
*/
/*
* This is a port of the infamous "glxgears" demo to straight EGL
* Port by Dane Rushton 10 July 2005
*
* Slightly modified by Norman Feske in July 2010
*/
#define EGL_EGLEXT_PROTOTYPES
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GL/gl.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#define MAX_CONFIGS 10
#define MAX_MODES 100
#ifndef M_PI
#define M_PI 3.14159265
#endif
static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
static GLint gear1, gear2, gear3;
static GLfloat angle = 0.0;
#if 0
static GLfloat eyesep = 5.0; /* Eye separation. */
static GLfloat fix_point = 40.0; /* Fixation point distance. */
static GLfloat left, right, asp; /* Stereo frustum params. */
#endif
/*
*
* Draw a gear wheel. You'll probably want to call this function when
* building a display list since we do a lot of trig here.
*
* Input: inner_radius - radius of hole at center
* outer_radius - radius at center of teeth
* width - width of gear
* teeth - number of teeth
* tooth_depth - depth of tooth
*/
static void
gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
GLint teeth, GLfloat tooth_depth)
{
GLint i;
GLfloat r0, r1, r2;
GLfloat angle, da;
GLfloat u, v, len;
r0 = inner_radius;
r1 = outer_radius - tooth_depth / 2.0;
r2 = outer_radius + tooth_depth / 2.0;
da = 2.0 * M_PI / teeth / 4.0;
glShadeModel(GL_FLAT);
glNormal3f(0.0, 0.0, 1.0);
/* draw front face */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
if (i < teeth) {
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
}
}
glEnd();
/* draw front sides of teeth */
glBegin(GL_QUADS);
da = 2.0 * M_PI / teeth / 4.0;
for (i = 0; i < teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5);
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
}
glEnd();
glNormal3f(0.0, 0.0, -1.0);
/* draw back face */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
if (i < teeth) {
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
}
}
glEnd();
/* draw back sides of teeth */
glBegin(GL_QUADS);
da = 2.0 * M_PI / teeth / 4.0;
for (i = 0; i < teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5);
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
}
glEnd();
/* draw outward faces of teeth */
glBegin(GL_QUAD_STRIP);
for (i = 0; i < teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
u = r2 * cos(angle + da) - r1 * cos(angle);
v = r2 * sin(angle + da) - r1 * sin(angle);
len = sqrt(u * u + v * v);
u /= len;
v /= len;
glNormal3f(v, -u, 0.0);
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
glNormal3f(cos(angle), sin(angle), 0.0);
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5);
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5);
u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
glNormal3f(v, -u, 0.0);
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
glNormal3f(cos(angle), sin(angle), 0.0);
}
glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
glEnd();
glShadeModel(GL_SMOOTH);
/* draw inside radius cylinder */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glNormal3f(-cos(angle), -sin(angle), 0.0);
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
}
glEnd();
}
static void
draw(void)
{
GLfloat a;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(view_rotx, 1.0, 0.0, 0.0);
glRotatef(view_roty, 0.0, 1.0, 0.0);
glRotatef(view_rotz, 0.0, 0.0, 1.0);
glPushMatrix();
glTranslatef(-3.0, -2.0, 0.0);
glRotatef(angle, 0.0, 0.0, 1.0);
glCallList(gear1);
glPopMatrix();
glPushMatrix();
glTranslatef(3.1, -2.0, 0.0);
a = -2.0*angle - 9.0;
while (a < 0) a += 360;
glRotatef(a, 0.0, 0.0, 1.0);
glCallList(gear2);
glPopMatrix();
glPushMatrix();
glTranslatef(-3.1, 4.2, 0.0);
a = -2.0*angle - 25.0;
while (a < 0) a += 360;
glRotatef(a, 0.0, 0.0, 1.0);
glCallList(gear3);
glPopMatrix();
glPopMatrix();
}
/* new window size or exposure */
static void
reshape(int width, int height)
{
GLfloat h = (GLfloat) height / (GLfloat) width;
glViewport(0, 0, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -40.0);
}
static void
init(void)
{
static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 };
static GLfloat red[4] = { 1.5*0.8, 0.1, 0.0, 0.5 };
static GLfloat green[4] = { 0.0, 1.5*0.8, 0.2, 0.5 };
static GLfloat blue[4] = { 0.2, 0.2, 1.5*1.0, 0.5 };
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
/* make the gears */
gear1 = glGenLists(1);
glNewList(gear1, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
gear(1.0, 4.0, 1.0, 20, 0.7);
glEndList();
gear2 = glGenLists(1);
glNewList(gear2, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
gear(0.5, 2.0, 2.0, 10, 0.7);
glEndList();
gear3 = glGenLists(1);
glNewList(gear3, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
gear(1.3, 2.0, 0.5, 10, 0.7);
glEndList();
glEnable(GL_NORMALIZE);
}
static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
{
while (1)
{
/* advance rotation for next frame */
angle += 3;
if (angle > 360)
angle -= 360;
view_rotx += 2;
if (view_rotx > 360)
view_rotx -= 360;
view_roty += 1.1;
if (view_roty > 360)
view_roty -= 360;
view_rotz += 0.77;
if (view_rotz > 360)
view_rotz -= 360;
draw();
eglSwapBuffers(dpy, surf);
}
}
int
main(int argc, char *argv[])
{
int maj, min;
EGLContext ctx;
EGLSurface screen_surf;
EGLConfig configs[MAX_CONFIGS];
EGLint numConfigs, i;
EGLBoolean b;
EGLDisplay d;
EGLint screenAttribs[10];
EGLModeMESA mode[MAX_MODES];
EGLScreenMESA screen;
EGLint count;
EGLint chosenMode = 0;
GLboolean printInfo = GL_FALSE;
EGLint width = 0, height = 0;
/* DBR : Create EGL context/surface etc */
d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
assert(d);
if (!eglInitialize(d, &maj, &min)) {
printf("eglgears: eglInitialize failed\n");
exit(1);
}
printf("eglgears: EGL version = %d.%d\n", maj, min);
printf("eglgears: EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
/* XXX use ChooseConfig */
eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);
eglGetScreensMESA(d, &screen, 1, &count);
if (!eglGetModesMESA(d, screen, mode, MAX_MODES, &count) || count == 0) {
printf("eglgears: eglGetModesMESA failed!\n");
return 0;
}
/* Print list of modes, and find the one to use */
printf("eglgears: Found %d modes:\n", count);
for (i = 0; i < count; i++) {
EGLint w, h;
eglGetModeAttribMESA(d, mode[i], EGL_WIDTH, &w);
eglGetModeAttribMESA(d, mode[i], EGL_HEIGHT, &h);
printf("%3d: %d x %d\n", i, w, h);
if (w > width && h > height) {
width = w;
height = h;
chosenMode = i;
}
}
printf("eglgears: Using screen mode/size %d: %d x %d\n", chosenMode, width, height);
eglBindAPI(EGL_OPENGL_API);
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
if (ctx == EGL_NO_CONTEXT) {
printf("eglgears: failed to create context\n");
return 0;
}
/* build up screenAttribs array */
i = 0;
screenAttribs[i++] = EGL_WIDTH;
screenAttribs[i++] = width;
screenAttribs[i++] = EGL_HEIGHT;
screenAttribs[i++] = height;
screenAttribs[i++] = EGL_NONE;
screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
if (screen_surf == EGL_NO_SURFACE) {
printf("eglgears: failed to create screen surface\n");
return 0;
}
printf("eglgears: returned from eglCreateScreenSurfaceMESA\n");
b = eglShowScreenSurfaceMESA(d, screen, screen_surf, mode[chosenMode]);
if (!b) {
printf("eglgears: show surface failed\n");
return 0;
}
printf("eglgears: returned from eglShowScreenSurfaceMESA\n");
b = eglMakeCurrent(d, screen_surf, screen_surf, ctx);
if (!b) {
printf("eglgears: make current failed\n");
return 0;
}
printf("eglgears: returned from eglMakeCurrent\n");
if (printInfo)
{
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
}
init();
reshape(width, height);
glDrawBuffer( GL_BACK );
run_gears(d, screen_surf, 5.0);
eglDestroySurface(d, screen_surf);
eglDestroyContext(d, ctx);
eglTerminate(d);
return 0;
}

View File

@ -1,3 +0,0 @@
TARGET = eglgears
SRC_C = eglgears.c
LIBS = posix gallium

View File

@ -1,824 +0,0 @@
/*
* \brief Gallium EGL driver for Genode
* \author Norman Feske
* \date 2010-07-05
*/
/*
* Copyright (C) 2010-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* Genode includes */
#include <base/log.h>
#include <base/snprintf.h>
#include <base/env.h>
#include <util/misc_math.h> /* for 'max' */
#include <framebuffer_session/connection.h>
#include <timer_session/connection.h>
#include <blit/blit.h>
/* libc includes */
#include <dlfcn.h> /* for 'dlopen', 'dlsym', and the like */
#include <fcntl.h> /* for 'open' */
/* includes from 'egl/main' */
extern "C" {
#include <egllog.h>
}
/* includes from 'gallium/state_trackers/egl' */
extern "C" {
#include <common/native.h>
#include <common/native_modeset.h>
}
/* Gallium includes */
extern "C" {
#include <auxiliary/util/u_simple_screen.h> /* for 'struct pipe_winsys' */
#include <auxiliary/util/u_inlines.h> /* for 'pipe_reference_init' */
#include <auxiliary/util/u_memory.h> /* for 'align_malloc' */
#include <auxiliary/util/u_format.h> /* for 'util_format_get_nblocksy' */
#include <auxiliary/util/u_math.h> /* for 'align' */
#include <drivers/softpipe/sp_winsys.h> /* for 'softpipe_create_screen' */
#include <state_tracker/drm_api.h> /* for 'drm_api_create' */
}
/* local includes */
#include "select_driver.h"
static bool do_clflush = true;
/********************************
** Genode framebuffer backend **
********************************/
class Genode_framebuffer
{
private:
Framebuffer::Connection _framebuffer;
Framebuffer::Mode const _mode;
Genode::Dataspace_capability const _ds_cap;
void * const _local_addr;
public:
Genode_framebuffer()
:
_mode(_framebuffer.mode()),
_ds_cap(_framebuffer.dataspace()),
_local_addr(Genode::env()->rm_session()->attach(_ds_cap))
{ }
~Genode_framebuffer()
{
Genode::env()->rm_session()->detach(_local_addr);
}
void *local_addr() const { return _local_addr; }
void flush()
{
_framebuffer.refresh(0, 0, _mode.width(), _mode.height());
}
int width() const { return _mode.width(); }
int height() const { return _mode.height(); }
};
static Genode_framebuffer *genode_framebuffer()
{
static Genode_framebuffer genode_framebuffer_inst;
return &genode_framebuffer_inst;
}
/************
** Winsys **
************/
class Pipe_buffer : public pipe_buffer
{
void *_data;
public:
/**
* Constructor
*/
Pipe_buffer(unsigned alignment,
unsigned usage,
unsigned size)
{
pipe_reference_init(&reference, 1);
pipe_buffer::alignment = alignment;
pipe_buffer::usage = usage;
pipe_buffer::size = size;
/* align to 16-byte multiple for Cell */
_data = align_malloc(size, Genode::max(alignment, 16U));
}
/**
* Destructor
*/
~Pipe_buffer() { align_free(_data); }
void *data() const { return _data; }
};
class Winsys : public pipe_winsys
{
/*
* For documentation of the winsys functions, refer to
* 'auxiliary/util/u_simple_screen.h'.
*/
static void
_destroy(struct pipe_winsys *ws)
{
Genode::destroy(Genode::env()->heap(), static_cast<Winsys *>(ws));
}
static const char *
_get_name(struct pipe_winsys *ws)
{
return "Genode-winsys";
}
static void
_update_buffer(struct pipe_winsys *ws,
void *context_private)
{
Genode::warning(__func__, " not implemented");
}
static void
_flush_frontbuffer(struct pipe_winsys *ws,
struct pipe_surface *surf,
void *context_private)
{
genode_framebuffer()->flush();
}
static struct pipe_buffer *
_buffer_create(struct pipe_winsys *ws,
unsigned alignment,
unsigned usage,
unsigned size)
{
return new (Genode::env()->heap()) Pipe_buffer(alignment, usage, size);
}
static struct pipe_buffer *
_user_buffer_create(struct pipe_winsys *ws,
void *ptr,
unsigned bytes)
{
Pipe_buffer *buf =
new (Genode::env()->heap()) Pipe_buffer(64, 0, bytes);
Genode::memcpy(buf->data(), ptr, bytes);
return buf;
}
/*
* Called when using the softpipe driver
*/
static struct pipe_buffer *
_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
enum pipe_format format,
unsigned usage,
unsigned tex_usage,
unsigned *stride)
{
Genode::log("Winsys::_surface_buffer_create: "
"format=", (int)format, ", "
"stride=", *stride, ", "
"usage=", usage, ", "
"tex_usage=", Genode::Hex(tex_usage));
unsigned nblocksy = util_format_get_nblocksy(format, height);
enum { ALIGNMENT = 64 };
*stride = align(util_format_get_stride(format, width), ALIGNMENT);
return new (Genode::env()->heap()) Pipe_buffer(ALIGNMENT, usage, *stride * nblocksy);
}
static void *
_buffer_map(struct pipe_winsys *ws,
struct pipe_buffer *buf,
unsigned usage)
{
return buf ? static_cast<Pipe_buffer *>(buf)->data() : 0;
}
static void
_buffer_unmap(struct pipe_winsys *ws,
struct pipe_buffer *buf)
{
}
static void
_buffer_destroy(struct pipe_buffer *buf)
{
Genode::destroy(Genode::env()->heap(), static_cast<Pipe_buffer *>(buf));
}
static void
_fence_reference(struct pipe_winsys *ws,
struct pipe_fence_handle **ptr,
struct pipe_fence_handle *fence)
{
Genode::warning(__func__, " not implemented");
}
static int
_fence_signalled(struct pipe_winsys *ws,
struct pipe_fence_handle *fence,
unsigned flag )
{
Genode::warning(__func__, " not implemented"); return 0;
}
static int
_fence_finish(struct pipe_winsys *ws,
struct pipe_fence_handle *fence,
unsigned flag )
{
Genode::warning(__func__, " not implemented"); return 0;
}
public:
/**
* Constructor
*/
Winsys()
{
/* initialize members of 'struct pipe_winsys' */
destroy = _destroy;
get_name = _get_name;
update_buffer = _update_buffer;
flush_frontbuffer = _flush_frontbuffer;
buffer_create = _buffer_create;
user_buffer_create = _user_buffer_create;
surface_buffer_create = _surface_buffer_create;
buffer_map = _buffer_map;
buffer_unmap = _buffer_unmap;
buffer_destroy = _buffer_destroy;
fence_reference = _fence_reference;
fence_signalled = _fence_signalled;
fence_finish = _fence_finish;
}
};
/**************************
** EGL driver functions **
**************************/
using namespace Genode;
/*
* For documentation of the 'native_surface' and 'native_display' functions,
* refer to 'gallium/state_trackers/egl/common/native.h'.
* For documentation of the 'native_display_modeset' functions, refer to
* 'gallium/state_trackers/egl/common/native_modeset.h'.
*/
class Display;
class Surface : public native_surface
{
public:
enum Surface_type { TYPE_SCANOUT, TYPE_WINDOW };
private:
enum pipe_format _color_format;
native_display *_display;
Surface_type _type;
const native_config *_config;
int _width, _height;
unsigned char *_addr; /* only used for TYPE_WINDOW */
struct pipe_texture *_textures[NUM_NATIVE_ATTACHMENTS];
unsigned int _sequence_number;
static void
_destroy(struct native_surface *nsurf)
{
Genode::destroy(Genode::env()->heap(), static_cast<Surface *>(nsurf));
}
static boolean
_swap_buffers(struct native_surface *nsurf);
static boolean
_flush_frontbuffer(struct native_surface *nsurf)
{
Genode::warning(__func__, " not implemented"); return 0;
}
static boolean
_validate(struct native_surface *nsurf, uint attachment_mask,
unsigned int *seq_num, struct pipe_texture **textures,
int *width, int *height)
{
Surface *this_surface = static_cast<Surface *>(nsurf);
struct pipe_texture templ;
if (attachment_mask) {
::memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_2D;
templ.last_level = 0;
templ.width0 = this_surface->_width;
templ.height0 = this_surface->_height;
templ.depth0 = 1;
templ.format = this_surface->_color_format;
templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
if (this_surface->_type == TYPE_SCANOUT)
templ.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY;
}
/* create textures */
for (int i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) {
/* delay the allocation */
if (!native_attachment_mask_test(attachment_mask, (native_attachment)i))
continue;
struct pipe_texture *ptex = this_surface->_textures[i];
if (!ptex) {
struct pipe_screen *screen = this_surface->_display->screen;
/*
* The softpipe driver implements 'texture_create' by
* calling 'surface_buffer_create' if the
* 'PIPE_TEXTURE_USAGE_PRIMARY' bit in tex_usage is set (see
* 'softpipe_texture_create').
* The call then ends up in 'Winsys::_surface_buffer_create'.
*
* The i915 driver, however, translates 'PIPE_TEXTURE_USAGE_PRIMARY'
* to an 'INTEL_NEW_SCANOUT' argument passed to 'buffer_create'
* (ending up in 'intel_drm_buffer_create'.
*/
ptex = screen->texture_create(screen, &templ);
this_surface->_textures[i] = ptex;
}
if (textures) {
textures[i] = 0;
pipe_texture_reference(&textures[i], ptex);
}
}
if (seq_num) *seq_num = this_surface->_sequence_number;
if (width) *width = this_surface->_width;
if (height) *height = this_surface->_height;
return TRUE;
}
static void
_wait(struct native_surface *nsurf)
{
Genode::warning(__func__, " not implemented");
}
public:
Surface(native_display *display, Surface_type t, const native_config *config,
int width, int height, unsigned char *addr = 0)
:
_color_format(config->color_format), _display(display), _type(t),
_config(config), _width(width), _height(height), _addr(addr),
_sequence_number(0)
{
for (int i = 0; i < NUM_NATIVE_ATTACHMENTS; i++)
_textures[i] = 0;
/* setup members of 'struct native_surface' */
destroy = _destroy;
swap_buffers = _swap_buffers;
flush_frontbuffer = _flush_frontbuffer;
validate = _validate;
wait = _wait;
}
~Surface()
{
for (int i = 0; i < NUM_NATIVE_ATTACHMENTS; i++)
if (_textures[i])
pipe_texture_reference(&_textures[i], 0);
}
/**
* Return texture used as backing store for the surface
*/
pipe_texture *texture()
{
for (int i = 0; i < NUM_NATIVE_ATTACHMENTS; i++)
if (_textures[i])
return _textures[i];
return 0;
}
int width() const { return _width; }
int height() const { return _height; }
};
class Display : public native_display
{
drm_api *_api;
Winsys _winsys;
enum { NUM_MODES = 1 };
struct native_mode _mode;
const struct native_mode *_mode_list[NUM_MODES];
native_display_modeset _modeset;
/*
* We only support one configuration.
*/
struct native_config _native_config;
boolean
_is_format_supported(enum pipe_format fmt, boolean is_color)
{
return screen->is_format_supported(screen,
fmt, PIPE_TEXTURE_2D,
(is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET :
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
}
/***********************
** Modeset functions **
***********************/
static const struct native_connector **
_get_connectors(struct native_display *ndpy,
int *num_connectors, int *num_crtcs)
{
static native_connector conn;
const native_connector **conn_list =
(const native_connector **)malloc(sizeof(native_connector **));
conn_list[0] = &conn;
Genode::log("called, return 1 connector");
if (num_connectors) *num_connectors = 1;
if (num_crtcs) *num_crtcs = 1;
return conn_list;
}
static const struct native_mode **
_get_modes(struct native_display *ndpy,
const struct native_connector *nconn,
int *num_modes)
{
*num_modes = 1;
return static_cast<Display *>(ndpy)->_mode_list;
}
static struct native_surface *
_create_scanout_surface(struct native_display *ndpy,
const struct native_config *nconf,
uint width, uint height)
{
return new (Genode::env()->heap())
Surface(ndpy,
Surface::TYPE_SCANOUT, nconf,
width, height);
}
static boolean
_program(struct native_display *ndpy, int crtc_idx,
struct native_surface *nsurf, uint x, uint y,
const struct native_connector **nconns, int num_nconns,
const struct native_mode *nmode)
{
return TRUE;
}
/***********************
** Display functions **
***********************/
static void
_destroy(struct native_display *ndpy)
{
Genode::destroy(Genode::env()->heap(), static_cast<Display *>(ndpy));
}
static int
_get_param(struct native_display *ndpy, enum native_param_type param)
{
switch (param) {
case NATIVE_PARAM_USE_NATIVE_BUFFER:
return TRUE;
break;
default:
return FALSE;
break;
}
}
static const struct native_config **
_get_configs(struct native_display *ndpy, int *num_configs)
{
Display *display = static_cast<Display *>(ndpy);
enum { NUM_CONFIGS = 1 };
const struct native_config **configs =
(const struct native_config **)calloc(1, sizeof(struct native_config *));
configs[0] = &display->_native_config;
struct native_config *config = &display->_native_config;
config->mode.drawableType = GLX_PBUFFER_BIT | GLX_WINDOW_BIT;
int r = 5, g = 6, b = 5, a = 0;
config->mode.swapMethod = GLX_SWAP_EXCHANGE_OML;
config->mode.visualID = 0;
config->mode.visualType = EGL_NONE;
config->mode.renderType = GLX_RGBA_BIT;
config->mode.rgbMode = TRUE;
config->mode.xRenderable = FALSE;
config->mode.maxPbufferWidth = 4096;
config->mode.maxPbufferHeight = 4096;
config->mode.maxPbufferPixels = 4096*4096/256+3;
config->mode.doubleBufferMode = TRUE;
config->mode.rgbBits = r + g + b + a;
config->mode.redBits = r;
config->mode.greenBits = g;
config->mode.blueBits = b;
config->mode.alphaBits = a;
config->depth_format = PIPE_FORMAT_NONE;
config->stencil_format = PIPE_FORMAT_NONE;
enum pipe_format format = PIPE_FORMAT_Z24S8_UNORM;
if (!display->_is_format_supported(format, FALSE)) {
format = PIPE_FORMAT_S8Z24_UNORM;
if (!display->_is_format_supported(format, FALSE))
format = PIPE_FORMAT_NONE;
}
if (format != PIPE_FORMAT_NONE) {
Genode::log("support depth and stencil buffer");
config->depth_format = format;
config->stencil_format = format;
config->mode.depthBits = 24;
config->mode.stencilBits = 8;
config->mode.haveDepthBuffer = TRUE;
config->mode.haveStencilBuffer = TRUE;
}
config->color_format = PIPE_FORMAT_B8G8R8A8_UNORM;
config->color_format = PIPE_FORMAT_B5G6R5_UNORM;
config->scanout_bit = TRUE;
Genode::log("returning 1 config at ", config);
*num_configs = NUM_CONFIGS;
return configs;
}
static boolean
_is_pixmap_supported(struct native_display *ndpy,
EGLNativePixmapType pix,
const struct native_config *nconf)
{
Genode::warning(__func__, " not implemented"); return 0;
}
static struct native_surface *
_create_window_surface(struct native_display *ndpy,
EGLNativeWindowType win,
const struct native_config *nconf)
{
return new (Genode::env()->heap())
Surface(ndpy,
Surface::TYPE_WINDOW, nconf,
win->width, win->height, win->addr);
}
static struct native_surface *
_create_pixmap_surface(struct native_display *ndpy,
EGLNativePixmapType pix,
const struct native_config *nconf)
{
Genode::warning(__func__, " not implemented"); return 0;
}
static struct native_surface *
_create_pbuffer_surface(struct native_display *ndpy,
const struct native_config *nconf,
uint width, uint height)
{
Genode::warning(__func__, " not implemented"); return 0;
}
public:
/**
* Constructor
*/
Display(drm_api *api) : _api(api)
{
::memset(&_mode, 0, sizeof(_mode));
::memset(&_modeset, 0, sizeof(_modeset));
::memset(&_native_config, 0, sizeof(_native_config));
/* setup mode list */
_mode.desc = "Mode-genode";
try {
_mode.width = genode_framebuffer()->width();
_mode.height = genode_framebuffer()->height();
}
catch (Genode::Service_denied) {
Genode::warning("EGL driver: could not create a Framebuffer session. "
"Screen surfaces cannot be used.");
_mode.width = 1;
_mode.height = 1;
}
_mode.refresh_rate = 100;
_mode_list[0] = &_mode;
/* setup members of 'struct native_display_modeset' */
_modeset.get_connectors = _get_connectors;
_modeset.get_modes = _get_modes;
_modeset.create_scanout_surface = _create_scanout_surface;
_modeset.program = _program;
/* setup members of 'struct native_display' */
if (api) {
struct drm_create_screen_arg arg;
::memset(&arg, 0, sizeof(arg));
arg.mode = DRM_CREATE_NORMAL;
int drm_fd = open("/dev/drm", O_RDWR);
screen = api->create_screen(api, drm_fd, &arg);
} else {
screen = softpipe_create_screen(&_winsys);
}
Genode::warning("returned from init display->screen");
destroy = _destroy;
get_param = _get_param;
get_configs = _get_configs;
is_pixmap_supported = _is_pixmap_supported;
create_window_surface = _create_window_surface;
create_pixmap_surface = _create_pixmap_surface;
create_pbuffer_surface = _create_pbuffer_surface;
modeset = &_modeset;
}
};
boolean Surface::_swap_buffers(struct native_surface *nsurf)
{
Surface *this_surface = static_cast<Surface *>(nsurf);
Display *display = static_cast<Display *>(this_surface->_display);
pipe_screen *screen = display->screen;
pipe_texture *texture = this_surface->texture();
pipe_transfer *transfer = 0;
static Timer::Connection timer;
timer.msleep(5);
if (!texture) {
Genode::error("surface has no texture");
return FALSE;
}
enum { FACE = 0, LEVEL = 0, ZSLICE = 0 };
transfer = screen->get_tex_transfer(screen, texture, FACE, LEVEL, ZSLICE,
PIPE_TRANSFER_READ, 0, 0,
this_surface->width(),
this_surface->height());
if (!transfer) {
Genode::error("could not create transfer object");
return FALSE;
}
void *data = screen->transfer_map(screen, transfer);
if (!data) {
Genode::error("transfer failed");
screen->tex_transfer_destroy(transfer);
return FALSE;
}
#ifdef __i386__
/* flush cache */
if (do_clflush) {
volatile char *virt_addr = (volatile char *)data;
long num_bytes = transfer->stride*transfer->height;
asm volatile ("": : :"memory");
enum { CACHE_LINE_SIZE = 16 /* hard-coded for now */ };
for (long i = 0; i < num_bytes; i += CACHE_LINE_SIZE, virt_addr += CACHE_LINE_SIZE)
asm volatile("clflush %0" : "+m" (*((volatile char *)virt_addr)));
asm volatile ("": : :"memory");
}
#endif
if (this_surface->_type == TYPE_SCANOUT)
blit(data, transfer->stride, genode_framebuffer()->local_addr(),
transfer->stride, transfer->stride, transfer->height);
else if (this_surface->_type == TYPE_WINDOW)
blit(data, transfer->stride, this_surface->_addr,
transfer->stride, transfer->stride, transfer->height);
screen->transfer_unmap(screen, transfer);
screen->tex_transfer_destroy(transfer);
this_surface->_sequence_number++;
if (this_surface->_type == TYPE_SCANOUT)
genode_framebuffer()->flush();
return TRUE;
}
extern "C" const char *native_get_name(void)
{
/*
* Among the 'native_' functions, this one is called first - a good
* opportunity to define the 'eglLog' debug level. For maximum verbosity,
* use '_EGL_DEBUG'.
*/
_eglSetLogLevel(_EGL_DEBUG);
return "Genode-EGL";
}
extern "C" struct native_probe *
native_create_probe(EGLNativeDisplayType dpy)
{
Genode::warning(__func__, " not yet implemented dpy=", dpy);
return 0;
}
extern "C" enum native_probe_result
native_get_probe_result(struct native_probe *nprobe)
{
Genode::warning(__func__, " not yet implemented");
return NATIVE_PROBE_UNKNOWN;
}
extern "C" struct native_display *
native_create_display(EGLNativeDisplayType dpy,
struct native_event_handler *event_handler)
{
/*
* Request API by dynamically loading the driver module. Each driver
* module has an entry-point function called 'drm_api_create'. For the
* i915 driver, this function resides in
* 'gallium/winsys/drm/intel/gem/intel_drm_api.c'.
*/
drm_api *api = 0;
const char *driver_filename = probe_gpu_and_select_driver();
void *driver_so_handle = driver_filename ? dlopen(driver_filename, 0) : 0;
if (driver_so_handle) {
/* query entry point into driver module */
drm_api *(*drm_api_create) (void) = 0;
drm_api_create = (drm_api *(*)(void))dlsym(driver_so_handle, "drm_api_create");
if (drm_api_create)
api = drm_api_create();
else
Genode::warning("could not obtain symbol \"drm_api_create\" in driver ",
"'", driver_filename, "'");
}
if (!api) {
Genode::warning("falling back to softpipe driver");
/*
* Performing clflush is not needed when using software rendering.
* Furthermore, on qemu with the default cpu, 'cflush' is an illegal
* instruction.
*/
do_clflush = false;
}
return new (env()->heap()) Display(api);
}

View File

@ -1,23 +0,0 @@
Allow OpenGL precision qualifiers for Qt5
From: Christian Prochaska <christian.prochaska@genode-labs.com>
Qt5 creates shader programs which use precision qualifiers. When these
programs get compiled for desktop OpenGL, a compile error occurs, because
a version number is too low. Lowering the version requirement avoids
the compile errors and didn't seem to cause any problems so far.
---
src/mesa/shader/slang/slang_compile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- src/lib/mesa/src/mesa/shader/slang/slang_compile.c
--- src/lib/mesa/src/mesa/shader/slang/slang_compile.c
@@ -2571,7 +2571,7 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit,
#if FEATURE_es2_glsl
o.allow_precision = GL_TRUE;
#else
- o.allow_precision = (C->version >= 120) ? GL_TRUE : GL_FALSE;
+ o.allow_precision = (C->version >= 110) ? GL_TRUE : GL_FALSE;
#endif
init_default_precision(&o, unit->type);

View File

@ -1,22 +0,0 @@
/*
* \brief Probe GPU device to select the proper Gallium3D driver
* \author Norman Feske
* \date 2010-09-23
*/
/*
* Copyright (C) 2010-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* local includes */
#include "select_driver.h"
const char *probe_gpu_and_select_driver()
{
const char *result = 0;
/* no support, currently we have no driver available */
return result;
}

View File

@ -1,25 +0,0 @@
/*
* \brief Probe GPU device to select the proper Gallium3D driver
* \author Norman Feske
* \date 2010-09-23
*/
/*
* Copyright (C) 2010-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _SELECT_DRIVER_H_
#define _SELECT_DRIVER_H_
/**
* Probe GPU and determine the shared object name of the Gallium3D driver
*
* \return ASCII string with the name of the Gallium3D driver, or
* 0 if detection failed
*/
const char *probe_gpu_and_select_driver();
#endif /* _SELECT_DRIVER_H_ */

View File

@ -1,20 +0,0 @@
/*
* \brief Advertise OpenGL support
* \author Norman Feske
* \date 2010-07-08
*
* The supported APIs are determined at runtime by querying symbols called
* 'st_api_<API>' via 'dlopen'. The OpenGL API is supported by the Mesa state
* tracker. To use it, we only need to make the corresponding symbol appear
* in our Gallium EGL driver.
*/
/*
* Copyright (C) 2010-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
const int st_api_OpenGL = 1;

View File

@ -1,7 +0,0 @@
This directory contains pseudo targets for building Gallium drivers. These
drivers are not directly linked against applications. Instead, they are loaded
as needed by using 'dlopen'. Because no application directly depends on any
driver library, none of these libraries is built by default. To enforce
building a driver library, we introduce a dummy program, which depends on the
respective library. The program itself is worthless, but as a side effect,
the driver library gets built.

View File

@ -1,26 +0,0 @@
/*
* \brief Dummy stub for trace driver
* \author Norman
* \date 2010-07-12
*
* The Intel driver contains a hard-coded initialization of the trace driver.
* With the dummy stub, we avoid having to use the trace driver. Using the
* trace driver would implicate the need for a working pthreads implementation,
* which we don't have yet.
*/
/*
* Copyright (C) 2010-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* includes from 'gallium/drivers/trace' */
#include <tr_drm.h>
struct drm_api *trace_drm_create(struct drm_api *api)
{
return api;
}

View File

@ -1,115 +0,0 @@
/*
* \brief Support code for i915 driver
* \author Norman Feske
* \date 2010-07-13
*
* Upon startup, the Gallium i915 driver opens the file
* "/sys/class/drm/card0/device/device" ('intel_drm_create_screen' ->
* 'intel_drm_get_device_id'). This file contains the device ID of the GPU.
* On Genode, there is no such file. Instead we determine the PCI device ID
* differently, but pass it to the Gallium driver through the normal libc file
* interface. This is achieved by adding a special libc plugin for handling´
* this specific filename.
*/
/*
* Copyright (C) 2010-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* Genode includes */
#include <base/printf.h>
#include <base/snprintf.h>
#include <util/string.h>
#include <util/misc_math.h>
#include <base/env.h>
/* libc plugin interface */
#include <libc-plugin/plugin.h>
#include <libc-plugin/fd_alloc.h>
/* GPU device driver interface */
#include <gpu/driver.h>
namespace {
struct Plugin_context : Libc::Plugin_context
{
Genode::size_t position;
Plugin_context() : position(0) { }
};
static inline Plugin_context *context(Libc::File_descriptor *fd)
{
return static_cast<Plugin_context *>(fd->context);
}
class Plugin : public Libc::Plugin
{
public:
bool supports_open(const char *pathname, int flags)
{
return (Genode::strcmp(pathname,
"/sys/class/drm/card0/device/device") == 0);
}
Libc::File_descriptor *open(const char *pathname, int flags)
{
Plugin_context *context = new (Genode::env()->heap()) Plugin_context();
return Libc::file_descriptor_allocator()->alloc(this, context);
}
int close(Libc::File_descriptor *fd)
{
Genode::destroy(Genode::env()->heap(), context(fd));
Libc::file_descriptor_allocator()->free(fd);
return 0;
}
ssize_t read(Libc::File_descriptor *fd, void *buf, ::size_t count)
{
/* query device ID from GPU driver */
char device_id_string[32];
Genode::snprintf(device_id_string, sizeof(device_id_string),
"0x%x", gpu_driver()->device_id());
if (context(fd)->position >= Genode::strlen(device_id_string))
return 0;
count = Genode::min(count,
Genode::strlen(device_id_string -
context(fd)->position) + 1);
Genode::strncpy((char *)buf,
device_id_string + context(fd)->position, count);
context(fd)->position += count;
return count;
}
bool supports_stat(const char *path)
{
return (Genode::strcmp(path, "/sys") == 0) ||
(Genode::strcmp(path, "/sys/class") == 0) ||
(Genode::strcmp(path, "/sys/class/drm") == 0) ||
(Genode::strcmp(path, "/sys/class/drm/card0") == 0) ||
(Genode::strcmp(path, "/sys/class/drm/card0/device") == 0) ||
(Genode::strcmp(path, "/sys/class/drm/card0/device/device") == 0);
}
int stat(const char *path, struct stat *buf)
{
if (buf)
buf->st_mode = S_IFDIR;
return 0;
}
};
}
void __attribute__((constructor)) init_query_device_id_plugin()
{
static Plugin plugin;
}

View File

@ -1,6 +0,0 @@
TARGET = gallium-i915
REQUIRES = i915
LIBS = base gallium-aux gallium-i915
SRC_CC = main.cc
vpath main.cc $(PRG_DIR)/..

View File

@ -1,14 +0,0 @@
/*
* \brief Dummy main function
* \author Norman Feske
* \date 2010-07-13
*/
/*
* Copyright (C) 2010-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
int main(int, char **) { return 0; }

View File

@ -1,20 +0,0 @@
Reduce memory allocated in 'sp_context.c' used for caching. By default,
more than 100 MB of memory gets allocated via malloc. We override the
definitions in 'gallium/include/pipe/p_state.h' to reduce the footprint.
--- src/lib/mesa/src/gallium/include/pipe/p_state.h
--- src/lib/mesa/src/gallium/include/pipe/p_state.h
@@ -56,10 +56,10 @@
*/
#define PIPE_MAX_ATTRIBS 32
#define PIPE_MAX_CLIP_PLANES 6
-#define PIPE_MAX_COLOR_BUFS 8
+#define PIPE_MAX_COLOR_BUFS 1 /* original value was 8 */
#define PIPE_MAX_CONSTANT_BUFFERS 32
-#define PIPE_MAX_SAMPLERS 16
-#define PIPE_MAX_VERTEX_SAMPLERS 16
+#define PIPE_MAX_SAMPLERS 1 /* original value was 16 */
+#define PIPE_MAX_VERTEX_SAMPLERS 1 /* original value was 16 */
#define PIPE_MAX_SHADER_INPUTS 16
#define PIPE_MAX_SHADER_OUTPUTS 16
#define PIPE_MAX_TEXTURE_LEVELS 16

View File

@ -1,226 +0,0 @@
/*
* \brief Handler for ioctl operations on DRM device
* \author Norman Feske
* \date 2010-07-13
*/
/*
* Copyright (C) 2010-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* Genode includes */
#include <util/string.h>
#include <base/env.h>
#include <base/log.h>
/* libc includes */
#include <sys/ioccom.h>
/* libc plugin interface */
#include <libc-plugin/plugin.h>
#include <libc-plugin/fd_alloc.h>
/* libdrm includes */
extern "C" {
#define virtual _virtual
#include <drm.h>
#include <i915_drm.h>
#undef virtual
}
/* GPU driver interface */
#include <gpu/driver.h>
enum { verbose_ioctl = false };
long drm_command(long request) { return (request & 0xff) - DRM_COMMAND_BASE; }
/**
* Return name of DRM command
*/
const char *command_name(long request)
{
if (IOCGROUP(request) != DRM_IOCTL_BASE)
return "<non-DRM>";
switch (drm_command(request)) {
case DRM_I915_INIT: return "DRM_I915_INIT";
case DRM_I915_FLUSH: return "DRM_I915_FLUSH";
case DRM_I915_FLIP: return "DRM_I915_FLIP";
case DRM_I915_BATCHBUFFER: return "DRM_I915_BATCHBUFFER";
case DRM_I915_IRQ_EMIT: return "DRM_I915_IRQ_EMIT";
case DRM_I915_IRQ_WAIT: return "DRM_I915_IRQ_WAIT";
case DRM_I915_GETPARAM: return "DRM_I915_GETPARAM";
case DRM_I915_SETPARAM: return "DRM_I915_SETPARAM";
case DRM_I915_ALLOC: return "DRM_I915_ALLOC";
case DRM_I915_FREE: return "DRM_I915_FREE";
case DRM_I915_INIT_HEAP: return "DRM_I915_INIT_HEAP";
case DRM_I915_CMDBUFFER: return "DRM_I915_CMDBUFFER";
case DRM_I915_DESTROY_HEAP: return "DRM_I915_DESTROY_HEAP";
case DRM_I915_SET_VBLANK_PIPE: return "DRM_I915_SET_VBLANK_PIPE";
case DRM_I915_GET_VBLANK_PIPE: return "DRM_I915_GET_VBLANK_PIPE";
case DRM_I915_VBLANK_SWAP: return "DRM_I915_VBLANK_SWAP";
case DRM_I915_HWS_ADDR: return "DRM_I915_HWS_ADDR";
case DRM_I915_GEM_INIT: return "DRM_I915_GEM_INIT";
case DRM_I915_GEM_EXECBUFFER: return "DRM_I915_GEM_EXECBUFFER";
case DRM_I915_GEM_PIN: return "DRM_I915_GEM_PIN";
case DRM_I915_GEM_UNPIN: return "DRM_I915_GEM_UNPIN";
case DRM_I915_GEM_BUSY: return "DRM_I915_GEM_BUSY";
case DRM_I915_GEM_THROTTLE: return "DRM_I915_GEM_THROTTLE";
case DRM_I915_GEM_ENTERVT: return "DRM_I915_GEM_ENTERVT";
case DRM_I915_GEM_LEAVEVT: return "DRM_I915_GEM_LEAVEVT";
case DRM_I915_GEM_CREATE: return "DRM_I915_GEM_CREATE";
case DRM_I915_GEM_PREAD: return "DRM_I915_GEM_PREAD";
case DRM_I915_GEM_PWRITE: return "DRM_I915_GEM_PWRITE";
case DRM_I915_GEM_MMAP: return "DRM_I915_GEM_MMAP";
case DRM_I915_GEM_SET_DOMAIN: return "DRM_I915_GEM_SET_DOMAIN";
case DRM_I915_GEM_SW_FINISH: return "DRM_I915_GEM_SW_FINISH";
case DRM_I915_GEM_SET_TILING: return "DRM_I915_GEM_SET_TILING";
case DRM_I915_GEM_GET_TILING: return "DRM_I915_GEM_GET_TILING";
case DRM_I915_GEM_GET_APERTURE: return "DRM_I915_GEM_GET_APERTURE";
case DRM_I915_GEM_MMAP_GTT: return "DRM_I915_GEM_MMAP_GTT";
case DRM_I915_GET_PIPE_FROM_CRTC_ID: return "DRM_I915_GET_PIPE_FROM_CRTC_ID";
case DRM_I915_GEM_MADVISE: return "DRM_I915_GEM_MADVISE";
case DRM_I915_OVERLAY_PUT_IMAGE: return "DRM_I915_OVERLAY_PUT_IMAGE";
case DRM_I915_OVERLAY_ATTRS: return "DRM_I915_OVERLAY_ATTRS";
case DRM_I915_GEM_EXECBUFFER2: return "DRM_I915_GEM_EXECBUFFER2";
default: return "<unknown>";
}
}
static void dump_ioctl(long request)
{
Genode::log("ioctl(request=", Genode::Hex(request), ", ",
(request & 0xe0000000) == IOC_OUT ? "out" :
(request & 0xe0000000) == IOC_IN ? "in" :
(request & 0xe0000000) == IOC_INOUT ? "inout" : "void", ", "
"len=", IOCPARM_LEN(request), ", "
"cmd=", command_name(request), ")");
}
namespace {
struct Plugin_context : Libc::Plugin_context { };
class Plugin : public Libc::Plugin
{
private:
Gpu_driver *_driver;
Gpu_driver::Client *_client;
/*
* Assign a priority of 1 to override libc_vfs.
*/
enum { PLUGIN_PRIORITY = 1 };
public:
Plugin(Gpu_driver *driver)
:
Libc::Plugin(PLUGIN_PRIORITY), _driver(driver), _client(0)
{
if (!_driver) {
Genode::error("could not initialize GPU driver");
return;
}
_client = _driver->create_client();
}
bool supports_open(const char *pathname, int flags)
{
return !Genode::strcmp(pathname, "/dev/drm");
}
Libc::File_descriptor *open(const char *pathname, int flags)
{
Plugin_context *context = new (Genode::env()->heap()) Plugin_context();
return Libc::file_descriptor_allocator()->alloc(this, context);
}
bool supports_stat(const char *path)
{
return (Genode::strcmp(path, "/dev") == 0 ||
Genode::strcmp(path, "/dev/drm") == 0);
}
int stat(const char *path, struct stat *buf)
{
if (buf)
buf->st_mode = S_IFDIR;
return 0;
}
int ioctl(Libc::File_descriptor *fd, int request, char *argp)
{
if (verbose_ioctl)
dump_ioctl(request);
if (drm_command(request) == DRM_I915_GEM_MMAP_GTT) {
drm_i915_gem_mmap_gtt *arg = (drm_i915_gem_mmap_gtt *)(argp);
arg->offset = (__u64)_driver->map_buffer_object(_client, arg->handle);
return arg->offset ? 0 : -1;
}
return _driver->ioctl(_client, drm_command(request), argp);
}
bool supports_mmap() { return true; }
/**
* Pseudo mmap specific for DRM device
*
* The original protocol between the Gallium driver and the kernel
* DRM driver is based on the interplay of the GEM_MMAP_GTT ioctl and
* mmap. First, GEM_MMAP_GTT is called with a buffer object as
* argument. The DRM driver returns a global ID called "fake offset"
* representing the buffer object. The fake offset actually refers
* to a region within the virtual 'dev->mm_private' memory map.
* The Gallium driver then passes this fake offset back to the DRM
* driver as 'offset' argument to 'mmap'. The DRM driver uses this
* argument to look up the GEM offset and set up a vm_area specific
* for the buffer object - paged by the DRM driver.
*
* We avoid this round-trip of a global ID. Instead of calling the
* 'GEM_MMAP_GTT' ioctl, we use a dedicated driver function called
* 'map_buffer_object', which simply returns the local address of
* the already mapped buffer object via the 'offset' return value.
* Hence, all 'mmap' has to do is passing back the 'offset' argument
* as return value.
*/
void *mmap(void *addr, ::size_t length, int prot, int flags,
Libc::File_descriptor *fd, ::off_t offset)
{
using namespace Genode;
log(__func__, ": "
"addr=", addr, ", "
"length=", length, ", "
"prot=", Hex(prot), ", "
"flags=", Hex(flags), ", "
"offset=", Hex(offset));
return (void *)offset;
}
int close(Libc::File_descriptor *fd)
{
Genode::destroy(Genode::env()->heap(),
static_cast<Plugin_context *>(fd->context));
Libc::file_descriptor_allocator()->free(fd);
return 0;
}
};
}
void __attribute__((constructor)) init_drm_device_plugin()
{
static Plugin plugin(gpu_driver());
}

View File

@ -0,0 +1,37 @@
/**
* \brief Genode C bindings for EGL back end
* \author Sebastian Sumpf
* \date 2017-08-17
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* needed since there exists a 'util/list.h' in mesa */
#include <../include/util/list.h>
#include <blit/blit.h>
#include <window.h>
#include <base/log.h>
extern "C" {
#include <platform.h>
}
void genode_framebuffer_refresh(Genode_egl_window *win, int x, int y, int w, int h)
{
Window *window = static_cast<Window *>(win);
window->framebuffer->refresh(x, y, w, h);
}
void genode_blit(void const *src, unsigned src_w, void *dst, unsigned dst_w, int w, int h)
{
blit(src, src_w, dst, dst_w, w, h);
}

View File

@ -0,0 +1,188 @@
/**
* \brief Generic EGL-DRI2 back end
* \author Sebastian Sumpf
* \date 2017-08-17
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/*
* Mesa
*/
#include <egl_dri2.h>
#include <egl_dri2_fallbacks.h>
#include <drivers/dri/common/utils.h>
/*
* Libc
*/
#include <string.h>
#include <dlfcn.h>
#include <unistd.h>
/*
* Local
*/
#include <platform.h>
EGLBoolean dri2_genode_swap_interval(_EGLDriver *drv, _EGLDisplay *disp,
_EGLSurface *surf, EGLint interval)
{
if (interval > surf->Config->MaxSwapInterval)
interval = surf->Config->MaxSwapInterval;
else if (interval < surf->Config->MinSwapInterval)
interval = surf->Config->MinSwapInterval;
surf->SwapInterval = interval;
return EGL_TRUE;
}
static _EGLSurface *
_create_surface(_EGLDriver *drv, _EGLDisplay *disp,
_EGLConfig *conf, void *native_window,
const EGLint *attrib_list,
enum Surface_type type)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_config *dri2_conf = dri2_egl_config(conf);
struct Genode_egl_window *window = native_window;
struct Genode_egl_window *window_dynamic;
struct dri2_egl_surface *dri2_surf;
const __DRIconfig *config;
window->type = type;
dri2_surf = calloc(1, sizeof *dri2_surf);
if (type == PIXMAP) {
window_dynamic = calloc(1, sizeof(struct Genode_egl_window));
*window_dynamic = *window;
window = window_dynamic;
}
if (!dri2_surf)
{
_eglError(EGL_BAD_ALLOC, "dri2_create_surface");
return NULL;
}
if (!_eglInitSurface(&dri2_surf->base, disp, EGL_WINDOW_BIT, conf, attrib_list))
goto cleanup_surf;
dri2_surf->g_win = window;
dri2_surf->base.Width = window->width;;
dri2_surf->base.Height = window->height;
config = dri2_get_dri_config(dri2_conf, EGL_WINDOW_BIT,
dri2_surf->base.GLColorspace);
if (dri2_dpy->dri2) {
dri2_surf->dri_drawable = (*dri2_dpy->dri2->createNewDrawable)(dri2_dpy->dri_screen, config,
dri2_surf);
/* create back buffer image */
dri2_surf->back_image = dri2_dpy->image->createImage(dri2_dpy->dri_screen,
dri2_surf->base.Width,
dri2_surf->base.Height,
__DRI_IMAGE_FORMAT_RGB565,
dri2_dpy->is_different_gpu ?
0 : __DRI_IMAGE_USE_SHARE,
NULL);
} else {
assert(dri2_dpy->swrast);
dri2_surf->dri_drawable =
(*dri2_dpy->swrast->createNewDrawable)(dri2_dpy->dri_screen,
config, dri2_surf);
}
if (dri2_surf->dri_drawable == NULL)
{
_eglError(EGL_BAD_ALLOC, "swrast->createNewDrawable");
goto cleanup_dri_drawable;
}
dri2_genode_swap_interval(drv, disp, &dri2_surf->base,
dri2_dpy->default_swap_interval);
return &dri2_surf->base;
cleanup_dri_drawable:
dri2_dpy->core->destroyDrawable(dri2_surf->dri_drawable);
cleanup_surf:
if (type == PIXMAP)
free(window_dynamic);
free(dri2_surf);
return NULL;
}
_EGLSurface *
dri2_genode_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
_EGLConfig *conf, void *native_window,
const EGLint *attrib_list)
{
return _create_surface(drv, disp, conf, native_window, attrib_list, WINDOW);
}
_EGLSurface*
dri2_genode_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLConfig *conf, void *native_pixmap,
const EGLint *attrib_list)
{
return _create_surface(drv, dpy, conf, native_pixmap, attrib_list, PIXMAP);
}
EGLBoolean
dri2_genode_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
{
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct Genode_egl_window *window = dri2_surf->g_win;
if (!_eglPutSurface(surf)) {
return EGL_TRUE;
}
dri2_dpy->core->destroyDrawable(dri2_surf->dri_drawable);
if (dri2_surf->back_image)
dri2_dpy->image->destroyImage(dri2_surf->back_image);
if (window->type == PIXMAP)
free(window);
free(dri2_surf);
return EGL_TRUE;
}
EGLBoolean dri2_initialize_genode(_EGLDriver *drv, _EGLDisplay *disp)
{
void *handle;
if (!(handle = dlopen("egl_drv.lib.so", 0))) {
printf("Error: could not open EGL back end driver ('egl_drv.lib.so')\n");
return EGL_FALSE;
}
typedef EGLBoolean (*genode_backend)(_EGLDriver *, _EGLDisplay *);
genode_backend init = (genode_backend)dlsym(handle, "dri2_initialize_genode_backend");
if (!init) {
printf("Error: could not find 'dri2_initialize_genode_backend'\n");
return EGL_FALSE;
}
return init(drv, disp);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
/**
* \brief DRM bindings
* \author Sebastian Sumpf
* \date 2017-08-17
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#include <drivers/dri/i965/intel_image.h>
void *genode_map_image(__DRIimage *image)
{
/* map read only */
drm_intel_bo_map(image->bo, false);
return image->bo->virtual;
}
void genode_unmap_image(__DRIimage *image)
{
drm_intel_bo_unmap(image->bo);
}

View File

@ -0,0 +1,26 @@
/**
* \brief Initialize DRM libraries session interface
* \author Sebastian Sumpf
* \date 2017-08-17
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#include <../include/util/list.h>
#include <base/env.h>
extern "C" {
#include <platform.h>
}
extern void drm_init(Genode::Env &env);
void genode_drm_init()
{
drm_init(*genode_env);
}

View File

@ -0,0 +1,257 @@
/**
* \brief Intel GPU EGL-DRI2 back end
* \author Sebastian Sumpf
* \date 2017-08-17
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/*
* Mesa
*/
#include <egl_dri2.h>
#include <egl_dri2_fallbacks.h>
#include <drivers/dri/common/utils.h>
/*
* Libc
*/
#include <dlfcn.h>
/*
* Local
*/
#include <bo_map.h>
#include <platform.h>
static int stride(int value)
{
/* RGB556 */
return value * 2;
}
typedef void *(*mem_copy_fn)(void *dest, const void *src, size_t n);
extern void
tiled_to_linear(uint32_t xt1, uint32_t xt2,
uint32_t yt1, uint32_t yt2,
char *dst, const char *src,
int32_t dst_pitch, uint32_t src_pitch,
bool has_swizzling,
uint32_t tiling,
mem_copy_fn mem_copy);
static void
dri2_genode_put_image(__DRIdrawable * draw, int op,
int x, int y, int w, int h,
char *data, void *loaderPrivate)
{
struct dri2_egl_surface *dri2_surf = loaderPrivate;
struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display);
struct Genode_egl_window *window = dri2_surf->g_win;
unsigned char *dst = window->addr;
int src_stride;
int dst_stride = stride(dri2_surf->base.Width);
dri2_dpy->image->queryImage(dri2_surf->back_image, __DRI_IMAGE_ATTRIB_STRIDE, &src_stride);
/* copy to frame buffer and refresh */
tiled_to_linear(0, dst_stride,
0, h,
(char *)dst, data,
dst_stride, src_stride,
false, 1, memcpy);
genode_framebuffer_refresh(window, x, y, w, h);
}
static EGLBoolean
dri2_genode_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
{
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
void *data = genode_map_image(dri2_surf->back_image);
dri2_genode_put_image(dri2_surf->dri_drawable, 0, 0, 0,
dri2_surf->base.Width, dri2_surf->base.Height,
(char *)data, (void *)dri2_surf);
genode_unmap_image(dri2_surf->back_image);
return EGL_TRUE;
}
/*
* platform functions
*/
static struct dri2_egl_display_vtbl dri2_genode_display_vtbl = {
.authenticate = NULL,
.create_window_surface = dri2_genode_create_window_surface,
.create_pixmap_surface = dri2_genode_create_pixmap_surface,
.create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
.destroy_surface = dri2_genode_destroy_surface,
.create_image = dri2_fallback_create_image_khr,
.swap_interval = dri2_genode_swap_interval,
.swap_buffers = dri2_genode_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
.swap_buffers_region = dri2_fallback_swap_buffers_region,
.post_sub_buffer = dri2_fallback_post_sub_buffer,
.copy_buffers = dri2_fallback_copy_buffers,
.query_buffer_age = dri2_fallback_query_buffer_age,
.get_sync_values = dri2_fallback_get_sync_values,
.get_dri_drawable = dri2_surface_get_dri_drawable,
};
static __DRIbuffer *
dri2_genode_get_buffers(__DRIdrawable * driDrawable,
int *width, int *height,
unsigned int *attachments, int count,
int *out_count, void *loaderPrivate)
{
_eglError(EGL_BAD_PARAMETER, "dri2_genode_get_buffers not implemented");
return NULL;
}
static void
dri2_genode_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
{
_eglError(EGL_BAD_PARAMETER, "dri2_genode_flush_front_buffer not implemented");
}
static void
back_bo_to_dri_buffer(struct dri2_egl_surface *dri2_surf, __DRIbuffer *buffer)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display);
__DRIimage *image;
int name, pitch;
image = dri2_surf->back_image;
dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_NAME, &name);
dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_STRIDE, &pitch);
buffer->attachment = __DRI_BUFFER_BACK_LEFT;
buffer->name = name;
buffer->pitch = pitch;
buffer->cpp = 4;
buffer->flags = 0;
}
static __DRIbuffer *
dri2_genode_get_buffers_with_format(__DRIdrawable * driDrawable,
int *width, int *height,
unsigned int *attachments, int count,
int *out_count, void *loaderPrivate)
{
struct dri2_egl_surface *dri2_surf = loaderPrivate;
int i, j;
for (i = 0, j = 0; i < 2 * count; i += 2, j++) {
switch (attachments[i]) {
case __DRI_BUFFER_BACK_LEFT:
back_bo_to_dri_buffer(dri2_surf, &dri2_surf->buffers[j]);
break;
default:
// if (get_aux_bo(dri2_surf, attachments[i], attachments[i + 1],
// &dri2_surf->buffers[j]) < 0) {
// _eglError(EGL_BAD_ALLOC, "failed to allocate aux buffer");
// return NULL;
// }
printf("ERROR: not implemented\n");
while (1);
break;
}
}
*out_count = j;
if (j == 0)
return NULL;
*width = dri2_surf->base.Width;
*height = dri2_surf->base.Height;
return dri2_surf->buffers;
}
EGLBoolean
dri2_initialize_genode_backend(_EGLDriver *drv, _EGLDisplay *disp)
{
struct dri2_egl_display *dri2_dpy;
static unsigned rgb565_masks[4] = { 0xf800, 0x07e0, 0x001f, 0 };
int i;
/* initialize DRM back end */
genode_drm_init();
dri2_dpy = calloc(1, sizeof *dri2_dpy);
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
dri2_dpy->fd = -1;
dri2_dpy->driver_name = strdup("i965");
disp->DriverData = (void *)dri2_dpy;
dri2_dpy->vtbl = &dri2_genode_display_vtbl;
if (!dri2_load_driver(disp))
goto cleanup_dpy;
dri2_dpy->dri2_major = 2;
dri2_dpy->dri2_minor = __DRI_DRI2_VERSION;
dri2_dpy->dri2_loader_extension.base.name = __DRI_DRI2_LOADER;
dri2_dpy->dri2_loader_extension.base.version = 3;
dri2_dpy->dri2_loader_extension.getBuffers = dri2_genode_get_buffers;
dri2_dpy->dri2_loader_extension.flushFrontBuffer = dri2_genode_flush_front_buffer;
dri2_dpy->dri2_loader_extension.getBuffersWithFormat = dri2_genode_get_buffers_with_format;
dri2_dpy->extensions[0] = &dri2_dpy->dri2_loader_extension.base;
dri2_dpy->extensions[1] = &image_lookup_extension.base;
dri2_dpy->extensions[2] = NULL;
dri2_dpy->swap_available = (dri2_dpy->dri2_minor >= 2);
dri2_dpy->invalidate_available = (dri2_dpy->dri2_minor >= 3);
if (!dri2_create_screen(disp))
goto close_screen;
/* add RGB565 only */
EGLint attrs[] = {
EGL_DEPTH_SIZE, 0, /* set in loop below (from DRI config) */
EGL_NATIVE_VISUAL_TYPE, 0,
EGL_NATIVE_VISUAL_ID, 0,
EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_BLUE_SIZE, 5,
EGL_NONE };
for (i = 1; dri2_dpy->driver_configs[i]; i++) {
/* set depth size in attrs */
attrs[1] = dri2_dpy->driver_configs[i]->modes.depthBits;
dri2_add_config(disp, dri2_dpy->driver_configs[i], i, EGL_WINDOW_BIT, attrs, rgb565_masks);
}
return EGL_TRUE;
close_screen:
dlclose(dri2_dpy->driver);
cleanup_dpy:
free(dri2_dpy);
return EGL_FALSE;
}

View File

@ -0,0 +1,2 @@
TARGET = dummy-egl_i965
LIBS = egl_i965

View File

@ -0,0 +1,20 @@
/**
* \brief DRM bindings
* \author Sebastian Sumpf
* \date 2017-08-17
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _BO_MAP_H_
#define _BO_MAP_H_
void *genode_map_image(__DRIimage *image);
void genode_unmap_image(__DRIimage *image);
#endif /* _BO_MAP_H_ */

View File

@ -0,0 +1,20 @@
/**
* \brief FreeBSD definitions for mesa
* \author Sebastian Sumpf
* \date 2017-08-17
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _INCLUDE__OSRELDATE_H_
#define _INCLUDE__OSRELDATE_H_
#undef __FreeBSD_version
#define __FreeBSD_version 802000
#endif /* _INCLUDE__OSRELDATE_H_ */

View File

@ -0,0 +1,49 @@
/**
* \brief Platform C/C++ inteface
* \author Sebastian Sumpf
* \date 2017-08-17
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _PLATFORM_H_
#define _PLATFORM_H_
#ifdef __cplusplus
extern Genode::Env *genode_env;
#endif
#include <EGL/egl.h>
struct Genode_egl_window;
void genode_framebuffer_refresh(struct Genode_egl_window *win, int x, int y, int w, int h);
void genode_blit(void const *src, unsigned src_w, void *dst, unsigned dst_w, int w, int h);
void genode_drm_init();
struct _EGLSurface;
struct _EGLDriver;
struct _EGLConfig;
struct _EGLDisplay;
_EGLSurface *
dri2_genode_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
_EGLConfig *conf, void *native_window,
const EGLint *attrib_list);
EGLBoolean
dri2_genode_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf);
_EGLSurface *
dri2_genode_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp,
_EGLConfig *conf, void *native_window,
const EGLint *attrib_list);
EGLBoolean
dri2_genode_swap_interval(_EGLDriver *drv, _EGLDisplay *disp,
_EGLSurface *surf, EGLint interval);
#endif

View File

@ -0,0 +1,59 @@
/**
* \brief EGL window with framebuffer connection
* \author Sebastian Sumpf
* \date 2017-08-17
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _WINDOW_H_
#define _WINDOW_H_
#include <base/debug.h>
#include <base/env.h>
#include <framebuffer_session/connection.h>
#include <util/reconstructible.h>
#include <EGL/eglplatform.h>
struct Window : Genode_egl_window
{
Genode::Constructible<Framebuffer::Connection> framebuffer;
Genode::Io_signal_handler<Window> sync_dispatcher;
Genode::Io_signal_handler<Window> mode_dispatcher;
Genode::Env &env;
Window(Genode::Env &env, int w, int h)
:
sync_dispatcher(env.ep(), *this, &Window::sync_handler),
mode_dispatcher(env.ep(), *this, &Window::mode_handler),
env(env)
{
width = w;
height = h;
framebuffer.construct(env, Framebuffer::Mode(width, height, Framebuffer::Mode::RGB565));
addr = env.rm().attach(framebuffer->dataspace());
framebuffer->sync_sigh(sync_dispatcher);
framebuffer->mode_sigh(mode_dispatcher);
mode_handler();
}
void sync_handler();
void mode_handler();
void update()
{
env.rm().detach(addr);
addr = env.rm().attach(framebuffer->dataspace());
}
};
#endif /* _WINDOW_H_ */

View File

@ -0,0 +1,99 @@
diff --git a/src/lib/mesa/src/egl/drivers/dri2/egl_dri2.c b/src/lib/mesa/src/egl/drivers/dri2/egl_dri2.c
index 8f50f0c..b4a7bc1 100644
--- a/src/lib/mesa/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/lib/mesa/src/egl/drivers/dri2/egl_dri2.c
@@ -450,7 +450,7 @@ dri2_open_driver(_EGLDisplay *disp)
#endif
if (dri2_dpy->driver == NULL) {
snprintf(path, sizeof path,
- "%.*s/%s_dri.so", len, p, dri2_dpy->driver_name);
+ "egl_%s.lib.so",dri2_dpy->driver_name);
dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
if (dri2_dpy->driver == NULL)
_eglLog(_EGL_DEBUG, "failed to open %s: %s\n", path, dlerror());
@@ -791,6 +791,12 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
return EGL_TRUE;
return dri2_initialize_android(drv, disp);
#endif
+#ifdef HAVE_GENODE_PLATFORM
+ case _EGL_PLATFORM_GENODE:
+ if (disp->Options.TestOnly)
+ return EGL_TRUE;
+ return dri2_initialize_genode(drv, disp);
+#endif
default:
_eglLog(_EGL_WARNING, "No EGL platform enabled.");
@@ -2530,6 +2536,8 @@ dri2_load(_EGLDriver *drv)
const char *libname = "libglapi.so";
#elif defined(__APPLE__)
const char *libname = "libglapi.0.dylib";
+#elif defined(HAVE_GENODE_PLATFORM)
+ const char *libname = "glapi.lib.so";
#else
const char *libname = "libglapi.so.0";
#endif
diff --git a/src/lib/mesa/src/egl/drivers/dri2/egl_dri2.h b/src/lib/mesa/src/egl/drivers/dri2/egl_dri2.h
index 52ad92b..bb4a1c1 100644
--- a/src/lib/mesa/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/lib/mesa/src/egl/drivers/dri2/egl_dri2.h
@@ -258,6 +258,12 @@ struct dri2_egl_surface
int format;
#endif
+#ifdef HAVE_GENODE_PLATFORM
+ struct Genode_egl_window *g_win;
+ __DRIbuffer *dri_buffers[__DRI_BUFFER_COUNT];
+ __DRIimage *back_image;
+#endif
+
#ifdef HAVE_DRM_PLATFORM
struct gbm_dri_surface *gbm_surf;
#endif
@@ -372,6 +378,9 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp);
EGLBoolean
dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp);
+EGLBoolean
+dri2_initialize_genode(_EGLDriver *drv, _EGLDisplay *disp);
+
void
dri2_flush_drawable_for_swapbuffers(_EGLDisplay *disp, _EGLSurface *draw);
diff --git a/src/lib/mesa/src/egl/main/egldisplay.c b/src/lib/mesa/src/egl/main/egldisplay.c
index f6db03a..36bfad4 100644
--- a/src/lib/mesa/src/egl/main/egldisplay.c
+++ b/src/lib/mesa/src/egl/main/egldisplay.c
@@ -71,6 +71,7 @@ static const struct {
{ _EGL_PLATFORM_ANDROID, "android" },
{ _EGL_PLATFORM_HAIKU, "haiku" },
{ _EGL_PLATFORM_SURFACELESS, "surfaceless" },
+ { _EGL_PLATFORM_GENODE, "genode" },
};
diff --git a/src/lib/mesa/src/egl/main/egldisplay.h b/src/lib/mesa/src/egl/main/egldisplay.h
index 008c467..dbdbf4e 100644
--- a/src/lib/mesa/src/egl/main/egldisplay.h
+++ b/src/lib/mesa/src/egl/main/egldisplay.h
@@ -50,6 +50,7 @@ enum _egl_platform_type {
_EGL_PLATFORM_ANDROID,
_EGL_PLATFORM_HAIKU,
_EGL_PLATFORM_SURFACELESS,
+ _EGL_PLATFORM_GENODE,
_EGL_NUM_PLATFORMS,
_EGL_INVALID_PLATFORM = -1
diff --git a/src/lib/mesa/src/egl/main/egllog.c b/src/lib/mesa/src/egl/main/egllog.c
index 9569465..be0bdbb 100644
--- a/src/lib/mesa/src/egl/main/egllog.c
+++ b/src/lib/mesa/src/egl/main/egllog.c
@@ -45,7 +45,7 @@
#include "egllog.h"
#define MAXSTRING 1000
-#define FALLBACK_LOG_LEVEL _EGL_WARNING
+#define FALLBACK_LOG_LEVEL _EGL_DEBUG
static struct {

View File

@ -0,0 +1,212 @@
/**
* \brief Software EGL-DRI2 back end
* \author Sebastian Sumpf
* \date 2017-08-17
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/*
* Mesa
*/
#include <egl_dri2.h>
#include <egl_dri2_fallbacks.h>
#include <drivers/dri/common/utils.h>
/*
* Libc
*/
#include <string.h>
#include <dlfcn.h>
/*
* Local
*/
#include <platform.h>
static int stride(int value)
{
/* RGB556 */
return value * 2;
}
static EGLBoolean
dri2_genode_swrast_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
dri2_dpy->core->swapBuffers(dri2_surf->dri_drawable);
return EGL_TRUE;
}
static struct dri2_egl_display_vtbl dri2_genode_display_vtbl = {
.authenticate = NULL,
.create_window_surface = dri2_genode_create_window_surface,
.create_pixmap_surface = dri2_genode_create_pixmap_surface,
.create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
.destroy_surface = dri2_genode_destroy_surface,
.create_image = dri2_fallback_create_image_khr,
.swap_interval = dri2_genode_swap_interval,
.swap_buffers = dri2_genode_swrast_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
.swap_buffers_region = dri2_fallback_swap_buffers_region,
.post_sub_buffer = dri2_fallback_post_sub_buffer,
.copy_buffers = dri2_fallback_copy_buffers,
.query_buffer_age = dri2_fallback_query_buffer_age,
.get_sync_values = dri2_fallback_get_sync_values,
.get_dri_drawable = dri2_surface_get_dri_drawable,
};
static void
dri2_genode_swrast_get_image(__DRIdrawable * read,
int x, int y, int w, int h,
char *data, void *loaderPrivate)
{
struct dri2_egl_surface *dri2_surf = loaderPrivate;
struct Genode_egl_window *window = dri2_surf->g_win;
unsigned char * src = window->addr;
int src_stride = stride(dri2_surf->base.Width);
int copy_width = stride(w);
int x_offset = stride(x);
int dst_stride = copy_width;
assert(data != (char *)src);
src += x_offset;
src += y * src_stride;
/* copy width over stride boundary */
if (copy_width > src_stride - x_offset)
copy_width = src_stride - x_offset;
/* limit height */
if (h > dri2_surf->base.Height - y)
h = dri2_surf->base.Height - y;
/* copy to surface */
genode_blit(src, src_stride, data, dst_stride, copy_width, h);
}
static void
dri2_genode_swrast_put_image(__DRIdrawable * draw, int op,
int x, int y, int w, int h,
char *data, void *loaderPrivate)
{
struct dri2_egl_surface *dri2_surf = loaderPrivate;
struct Genode_egl_window *window = dri2_surf->g_win;
unsigned char * dst = window->addr;
int dst_stride = stride(dri2_surf->base.Width);
int copy_width = stride(w);
int x_offset = stride(x);
int src_stride = copy_width;
dst += x_offset;
dst += y * dst_stride;
/* copy width over stride boundary */
if (copy_width >dst_stride - x_offset)
copy_width = dst_stride - x_offset;
/* limit height */
if (h > dri2_surf->base.Height - y)
h = dri2_surf->base.Height - y;
/* copy to frame buffer and refresh */
genode_blit(data, src_stride, dst, dst_stride, copy_width, h);
if (window->type == WINDOW)
genode_framebuffer_refresh(window, x, y, w, h);
}
static void
dri2_genode_swrast_get_drawable_info(__DRIdrawable * draw,
int *x, int *y, int *w, int *h,
void *loaderPrivate)
{
struct dri2_egl_surface *dri2_surf = loaderPrivate;
//XXX: (void) swrast_update_buffers(dri2_surf);
*x = 0;
*y = 0;
*w = dri2_surf->base.Width;
*h = dri2_surf->base.Height;
}
static EGLBoolean
dri2_initialize_genode_swrast(_EGLDriver *drv, _EGLDisplay *disp)
{
struct dri2_egl_display *dri2_dpy;
static unsigned rgb565_masks[4] = { 0xf800, 0x07e0, 0x001f, 0 };
int i;
dri2_dpy = calloc(1, sizeof *dri2_dpy);
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
disp->DriverData = (void *)dri2_dpy;
dri2_dpy->vtbl = &dri2_genode_display_vtbl;
dri2_dpy->fd = -1;
dri2_dpy->driver_name = strdup("swrast");
if (!dri2_load_driver_swrast(disp))
goto close_driver;
dri2_dpy->swrast_loader_extension.base.name = __DRI_SWRAST_LOADER;
dri2_dpy->swrast_loader_extension.base.version = 2;
dri2_dpy->swrast_loader_extension.getDrawableInfo = dri2_genode_swrast_get_drawable_info;
dri2_dpy->swrast_loader_extension.putImage = dri2_genode_swrast_put_image;
dri2_dpy->swrast_loader_extension.getImage = dri2_genode_swrast_get_image;
dri2_dpy->extensions[0] = &dri2_dpy->swrast_loader_extension.base;
dri2_dpy->extensions[1] = NULL;
if (!dri2_create_screen(disp))
goto close_screen;
/* add RGB565 only */
EGLint attrs[] = {
EGL_DEPTH_SIZE, 0, /* set in loop below (from DRI config) */
EGL_NATIVE_VISUAL_TYPE, 0,
EGL_NATIVE_VISUAL_ID, 0,
EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_BLUE_SIZE, 5,
EGL_NONE };
for (i = 1; dri2_dpy->driver_configs[i]; i++) {
/* set depth size in attrs */
attrs[1] = dri2_dpy->driver_configs[i]->modes.depthBits;
dri2_add_config(disp, dri2_dpy->driver_configs[i], i,
EGL_WINDOW_BIT | EGL_PBUFFER_BIT, attrs,
rgb565_masks);
}
return EGL_TRUE;
close_screen:
dlclose(dri2_dpy->driver);
close_driver:
free(dri2_dpy);
return EGL_FALSE;
}
EGLBoolean dri2_initialize_genode_backend(_EGLDriver *drv, _EGLDisplay *disp)
{
return dri2_initialize_genode_swrast(drv, disp);
}

View File

@ -0,0 +1,2 @@
TARGET = dummy-egl_swrast
LIBS = egl_swrast

View File

@ -1,67 +0,0 @@
/*
* \brief GPU driver interface
* \author Norman Feske
* \date 2010-07-28
*
* This interface is implemented by the GPU driver and used by the back-end
* of 'libdrm'. With the forthcoming work on the GPU infrastructure, it will
* change. It is an intermediate step - please do not use it.
*/
/*
* Copyright (C) 2010-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _GPU__DRIVER_H_
#define _GPU__DRIVER_H_
#include <base/stdint.h>
class Gpu_driver
{
public:
class Client;
/**
* Create client context
*/
virtual Client *create_client() = 0;
/**
* Return PCI device ID of GPU
*/
virtual uint16_t device_id() = 0;
/**
* Perform operation of GPU device
*
* \param request ioctl opcode relative to 'DRM_COMMAND_BASE'
*/
virtual int ioctl(Client *client, int request, void *arg) = 0;
/**
* Map buffer object to local address space
*
* \param handle client-local buffer-object handle
* \return base address of mapped buffer object
*/
virtual void *map_buffer_object(Client *client, long handle) = 0;
/**
* Remove buffer object from local address space
*
* \param handle client-local buffer-object handle
*/
virtual void unmap_buffer_object(Client *client, long handle) = 0;
};
/**
* Obtain GPU driver interface
*/
Gpu_driver *gpu_driver();
#endif /* _GPU__DRIVER_H_ */