Skip to content

Commit

Permalink
Trying to add OpenGL runtime to emscripten'ed web runtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
phisiart committed Dec 27, 2017
1 parent 1473e52 commit 57bda69
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ UNAME_S := $(shell uname -s)
# The flags
LLVM_CFLAGS= -fno-rtti -DDMLC_ENABLE_RTTI=0 -DDMLC_USE_FOPEN64=0
LDFLAGS = -pthread -lm -ldl
INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include -IHalideIR/src -Itopi/include
INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include -IHalideIR/src -Itopi/include -Iglad/include
CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC
FRAMEWORKS =
OBJCFLAGS = -fno-objc-arc
Expand All @@ -52,6 +52,8 @@ METAL_SRC = $(wildcard src/runtime/metal/*.mm)
CUDA_SRC = $(wildcard src/runtime/cuda/*.cc)
ROCM_SRC = $(wildcard src/runtime/rocm/*.cc)
OPENCL_SRC = $(wildcard src/runtime/opencl/*.cc)
OPENGL_SRC = $(wildcard src/runtime/opengl/*.cc)
GLAD_SRC = glad/src/glad.c
RPC_SRC = $(wildcard src/runtime/rpc/*.cc)
GRAPH_SRC = $(wildcard src/runtime/graph/*.cc)
RUNTIME_SRC = $(wildcard src/runtime/*.cc)
Expand All @@ -63,6 +65,8 @@ METAL_OBJ = $(patsubst src/%.mm, build/%.o, $(METAL_SRC))
CUDA_OBJ = $(patsubst src/%.cc, build/%.o, $(CUDA_SRC))
ROCM_OBJ = $(patsubst src/%.cc, build/%.o, $(ROCM_SRC))
OPENCL_OBJ = $(patsubst src/%.cc, build/%.o, $(OPENCL_SRC))
OPENGL_OBJ = $(patsubst src/%.cc, build/%.o, $(OPENGL_SRC))
GLAD_OBJ = $(patsubst glad/src/%.c, build/%.o, $(GLAD_SRC))
RPC_OBJ = $(patsubst src/%.cc, build/%.o, $(RPC_SRC))
GRAPH_OBJ = $(patsubst src/%.cc, build/%.o, $(GRAPH_SRC))
CC_OBJ = $(patsubst src/%.cc, build/%.o, $(CC_SRC)) $(LLVM_OBJ)
Expand Down Expand Up @@ -113,6 +117,19 @@ else
CFLAGS += -DTVM_OPENCL_RUNTIME=0
endif

ifeq ($(USE_OPENGL), 1)
CFLAGS += -DTVM_OPENGL_RUNTIME=1
ifeq ($(UNAME_S), Darwin)
FRAMEWORKS += -framework OpenGL
else
LDFLAGS += -lGL -lglfw
endif
RUNTIME_DEP += $(OPENGL_OBJ)
RUNTIME_DEP += $(GLAD_OBJ)
else
CFLAGS += -DTVM_OPENGL_RUNTIME=0
endif

ifeq ($(USE_METAL), 1)
CFLAGS += -DTVM_METAL_RUNTIME=1
LDFLAGS += -lobjc
Expand Down Expand Up @@ -194,6 +211,11 @@ build/runtime/metal/%.o: src/runtime/metal/%.mm
$(CXX) $(OBJCFLAGS) $(CFLAGS) -MM -MT build/runtime/metal/$*.o $< >build/runtime/metal/$*.d
$(CXX) $(OBJCFLAGS) -c $(CFLAGS) -c $< -o $@

build/glad.o: glad/src/glad.c
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -MM -MT build/glad.o $< >build/glad.d
$(CXX) -c $(CFLAGS) -c glad/src/glad.c -o build/glad.o

build/%.o: src/%.cc
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -MM -MT build/$*.o $< >build/$*.d
Expand Down
3 changes: 3 additions & 0 deletions web/web_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include "../src/runtime/rpc/rpc_event_impl.cc"
#include "../src/runtime/rpc/rpc_server_env.cc"
#include "../src/runtime/graph/graph_runtime.cc"
#include "../src/runtime/opengl/opengl_device_api.cc"
#include "../src/runtime/opengl/opengl_module.cc"
#include "../glad/src/glad.c"

namespace tvm {
namespace contrib {
Expand Down

0 comments on commit 57bda69

Please sign in to comment.