Browse Source

fixed a minor bug in the gl shader parser

jp9000 12 years ago
parent
commit
ab08c2c3f2
9 changed files with 19 additions and 260 deletions
  1. 0 51
      libobs-d3d11/makefile
  2. 16 9
      libobs-opengl/gl-shaderparser.c
  3. 0 48
      libobs-opengl/makefile
  4. 0 68
      libobs/makefile
  5. 1 1
      libobs/obs.c
  6. 0 13
      test/makefile
  7. 0 33
      test/test-input/makefile
  8. 0 35
      test/win/makefile
  9. 2 2
      test/win/test.cpp

+ 0 - 51
libobs-d3d11/makefile

@@ -1,51 +0,0 @@
-include ../config.mak
-
-all: default
-
-SRCFILES=GS_D3D11SubSystem.cpp \
-	 GS_D3D11IndexBuffer.cpp \
-	 GS_D3D11Shader.cpp \
-	 GS_D3D11ShaderProcessor.cpp \
-	 GS_D3D11StageSurf.cpp \
-	 GS_D3D11Texture2D.cpp \
-	 GS_D3D11VertexBuffer.cpp \
-	 GS_D3D11ZStencilBuffer.cpp
-
-SONAME=../build/libobs-d3d11.$(SOEXT)
-
-LD=g++ -o 
-
-CPPFLAGS += -iquote $(BASEINC) 
-CPPFLAGS += -iquote ../libobs-graphics/
-CPPFLAGS += -isystem ./mingw/
-
-LDFLAGS += -L../build/
-
-ifdef monolithic
-LDFLAGS += -lobs
-else
-LDFLAGS += -lobs-util -lobs-graphics
-endif
-
-.PHONY: all monolithic default clean
-
-OBJS += $(SRCFILES:%.cpp=%.$(OBJ))
-
-default: $(SONAME)
-
-$(SONAME): .depend $(OBJS)
-	$(LD)$@ $(LDFLAGS) $(OBJS)
-
-.depend:
-	@rm -f .depend
-	@$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCFILES)), $(CCDEP) \
-	       -std=c++11 $(CPPFLAGS) $(SRC) -I$(BASEINC) \
-	       -MT $(SRC:$(SRCPATH)/%.cpp=%.$(OBJ)) -MM 1>> .depend;)
-
-depend: .depend
-ifneq ($(wildcard .depend),)
-include .depend
-endif
-
-clean:
-	rm -f $(OBJS) $(SONAME) *.a *.lib *.exp *.pdb .depend

+ 16 - 9
libobs-opengl/gl-shaderparser.c

@@ -47,26 +47,33 @@ static inline size_t sp_getsampler(struct gl_shader_parser *glsp,
 	return -1;
 }
 
+static inline int cmp_type(const char *name, const size_t name_len,
+		const char *type, const size_t type_len)
+{
+	size_t min_len = (name_len < type_len) ? type_len : name_len;
+	return astrcmp_n(name, type, min_len);
+}
+
 static bool gl_write_type_n(struct gl_shader_parser *glsp,
 		const char *type, size_t len)
 {
-	if (astrcmp_n(type, "float2", len) == 0)
+	if (cmp_type(type, len, "float2", 6) == 0)
 		dstr_cat(&glsp->gl_string, "vec2");
-	else if (astrcmp_n(type, "float3", len) == 0)
+	else if (cmp_type(type, len, "float3", 6) == 0)
 		dstr_cat(&glsp->gl_string, "vec3");
-	else if (astrcmp_n(type, "float4", len) == 0)
+	else if (cmp_type(type, len, "float4", 6) == 0)
 		dstr_cat(&glsp->gl_string, "vec4");
-	else if (astrcmp_n(type, "float3x3", len) == 0)
+	else if (cmp_type(type, len, "float3x3", 8) == 0)
 		dstr_cat(&glsp->gl_string, "mat3x3");
-	else if (astrcmp_n(type, "float3x4", len) == 0)
+	else if (cmp_type(type, len, "float3x4", 8) == 0)
 		dstr_cat(&glsp->gl_string, "mat3x4");
-	else if (astrcmp_n(type, "float4x4", len) == 0)
+	else if (cmp_type(type, len, "float4x4", 8) == 0)
 		dstr_cat(&glsp->gl_string, "mat4x4");
-	else if (astrcmp_n(type, "texture2d", len) == 0)
+	else if (cmp_type(type, len, "texture2d", 9) == 0)
 		dstr_cat(&glsp->gl_string, "sampler2D");
-	else if (astrcmp_n(type, "texture3d", len) == 0)
+	else if (cmp_type(type, len, "texture3d", 9) == 0)
 		dstr_cat(&glsp->gl_string, "sampler3D");
-	else if (astrcmp_n(type, "texture_cube", len) == 0)
+	else if (cmp_type(type, len, "texture_cube", 12) == 0)
 		dstr_cat(&glsp->gl_string, "samplerCube");
 	else
 		return false;

+ 0 - 48
libobs-opengl/makefile

@@ -1,48 +0,0 @@
-include ../config.mak
-
-.PHONY: all default clean
-
-all: default
-
-SRCFILES=gl-subsystem.c \
-	 gl-windows.c \
-	 gl-vertexbuffer.c \
-	 gl-texturecube.c \
-	 gl-texture2d.c \
-	 gl-stagesurf.c \
-	 gl-shaderparser.c \
-	 gl-shader.c \
-	 gl-indexbuffer.c \
-	 gl-zstencil.c \
-	 gl-helpers.c
-
-SONAME=../build/libobs-opengl.$(SOEXT)
-
-OBJS += $(SRCFILES:%.c=%.$(OBJ))
-
-CPPFLAGS += -iquote../libobs -DGLEW_STATIC
-LDFLAGS += -Lglew/lib -Wl,-Bstatic -lglew32 -Wl,-Bdynamic -lopengl32 \
-	   -Wl,--subsystem,windows -mwindows -L../build -lobs -lpthread
-
-default: makeglew $(SONAME)
-
-makeglew: glew
-	make -C glew glew.lib
-
-.depend:
-	@rm -f .depend
-	@$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCFILES)), $(CCDEP) \
-	       $(CPPFLAGS) $(SRC) \
-	       -MT $(SRC:$(SRCPATH)/%.c=%.$(OBJ)) -MM 1>> .depend;)
-
-$(SONAME): .depend $(OBJS)
-	$(LD)$@ $(OBJS) $(LDFLAGS)
-
-depend: .depend
-ifneq ($(wildcard .depend),)
-include .depend
-endif
-
-clean:
-	rm -f $(OBJS) $(SONAME) *.a *.lib *.exp *.pdb .depend
-	make clean -C glew

+ 0 - 68
libobs/makefile

@@ -1,68 +0,0 @@
-include ../config.mak
-
-.PHONY: all default clean
-
-all: default
-
-SRCFILES=util/bmem.c \
-	 util/base.c \
-	 util/dstr.c \
-	 util/lexer.c \
-	 util/utf8.c \
-	 util/text-lookup.c \
-	 util/platform.c \
-	 util/platform-windows.c \
-	 util/config-file.c \
-	 util/cf-lexer.c \
-	 util/cf-parser.c \
-	 graphics/axisang.c \
-	 graphics/bounds.c \
-	 graphics/effect.c \
-	 graphics/effect-parser.c \
-	 graphics/graphics.c \
-	 graphics/graphics-imports.c \
-	 graphics/math-extra.c \
-	 graphics/matrix3.c \
-	 graphics/matrix4.c \
-	 graphics/plane.c \
-	 graphics/quat.c \
-	 graphics/shader-parser.c \
-	 graphics/texture-render.c \
-	 graphics/vec2.c \
-	 graphics/vec3.c \
-	 graphics/vec4.c \
-	 media-io/video-io.c \
-	 media-io/audio-io.c \
-	 media-io/media-io.c \
-	 media-io/format-conversion.c \
-	 obs-module.c \
-	 obs-output.c \
-	 obs-source.c \
-	 obs-scene.c \
-	 obs-display.c \
-	 obs-video.c \
-	 obs.c
-
-SONAME=../build/libobs.$(SOEXT)
-
-OBJS += $(SRCFILES:%.c=%.$(OBJ))
-LDFLAGS += -lpthread
-
-default: $(SONAME)
-
-.depend:
-	@rm -f .depend
-	@$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCFILES)), $(CCDEP) \
-	       $(CPPFLAGS) $(SRC) \
-	       -MT $(SRC:$(SRCPATH)/%.c=%.$(OBJ)) -MM 1>> .depend;)
-
-$(SONAME): .depend $(OBJS)
-	$(LD)$@ $(LDFLAGS) $(OBJS)
-
-depend: .depend
-ifneq ($(wildcard .depend),)
-include .depend
-endif
-
-clean:
-	rm -f $(OBJS) $(SONAME) *.a *.lib *.exp *.pdb .depend

+ 1 - 1
libobs/obs.c

@@ -47,7 +47,7 @@ static bool obs_init_graphics(const char *graphics_module,
 
 	if (success) {
 		obs->default_effect = gs_create_effect_from_file(
-				"build/data/default.effect", NULL);
+				"data/effects/default.effect", NULL);
 		if (!obs->default_effect)
 			success = false;
 	}

+ 0 - 13
test/makefile

@@ -1,13 +0,0 @@
-include ../config.mak
-
-all: default
-
-PROJECTS=test-input win
-
-.PHONY: all default clean
-
-default: $(PROJECTS)
-	@$(foreach PROJECT, $(PROJECTS), $(MAKE) -C $(PROJECT);)
-
-clean: $(PROJECTS)
-	@$(foreach PROJECT, $(PROJECTS), $(MAKE) clean -C $(PROJECT);)

+ 0 - 33
test/test-input/makefile

@@ -1,33 +0,0 @@
-include ../../config.mak
-
-.PHONY: all default clean
-
-all: default
-
-SRCFILES=test-filter.c test-input.c test-random.c
-
-SONAME=../../build/test-input.$(SOEXT)
-
-OBJS += $(SRCFILES:%.c=%.$(OBJ))
-
-CPPFLAGS += -iquote../../libobs
-LDFLAGS += -L../../build -lobs
-
-default: $(SONAME)
-
-.depend:
-	@rm -f .depend
-	@$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCFILES)), $(CCDEP) \
-	       $(CPPFLAGS) $(SRC) \
-	       -MT $(SRC:$(SRCPATH)/%.c=%.$(OBJ)) -MM 1>> .depend;)
-
-$(SONAME): .depend $(OBJS)
-	$(LD)$@ $(LDFLAGS) $(OBJS)
-
-depend: .depend
-ifneq ($(wildcard .depend),)
-include .depend
-endif
-
-clean:
-	rm -f $(OBJS) $(SONAME) *.a *.lib *.exp *.pdb .depend

+ 0 - 35
test/win/makefile

@@ -1,35 +0,0 @@
-include ../../config.mak
-
-.PHONY: all default clean
-
-all: default
-
-SRCFILES=test.cpp
-
-NAME=../../build/wintest$(EXT)
-
-OBJS += $(SRCFILES:%.cpp=%.$(OBJ))
-
-LD=g++ -o
-LDFLAGS=-L../../build -lobs -Wl,--subsystem,windows
-
-CPPFLAGS += -I../../libobs -DUNICODE -D_UNICODE
-
-default: $(NAME)
-
-.depend:
-	@rm -f .depend
-	@$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCFILES)), $(CCDEP) \
-	       $(CPPFLAGS) $(SRC) \
-	       -MT $(SRC:$(SRCPATH)/%.c=%.$(OBJ)) -MM 1>> .depend;)
-
-$(NAME): .depend $(OBJS)
-	$(LD)$@ $(LDFLAGS) $(OBJS)
-
-depend: .depend
-ifneq ($(wildcard .depend),)
-include .depend
-endif
-
-clean:
-	rm -f $(OBJS) $(NAME) *.a *.lib *.exp *.pdb .depend

+ 2 - 2
test/win/test.cpp

@@ -58,8 +58,8 @@ static void do_log(enum log_type type, const char *msg, va_list args)
 	OutputDebugStringA(bla);
 	OutputDebugStringA("\n");
 
-	/*if (type >= LOG_WARNING)
-		__debugbreak();*/
+	if (type >= LOG_WARNING)
+		__debugbreak();
 }
 
 static void CreateOBS(HWND hwnd)