瀏覽代碼

Merge branch 'master' into windows-llvm-13.0.0

gingerBill 3 年之前
父節點
當前提交
3200e063ec

+ 1 - 0
core/sys/windows/winmm.odin

@@ -7,4 +7,5 @@ foreign import winmm "system:Winmm.lib"
 foreign winmm {
 	timeBeginPeriod :: proc(uPeriod: UINT) -> MMRESULT ---
 	timeEndPeriod   :: proc(uPeriod: UINT) -> MMRESULT ---
+	timeGetTime     :: proc() -> DWORD ---
 }

+ 10 - 4
src/llvm_backend_debug.cpp

@@ -980,8 +980,7 @@ void lb_add_debug_local_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, T
 	LLVMDIBuilderInsertDeclareAtEnd(m->debug_builder, storage, var_info, llvm_expr, llvm_debug_loc, block);
 }
 
-
-void lb_add_debug_param_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token, unsigned arg_number, lbBlock *block) {
+void lb_add_debug_param_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token, unsigned arg_number, lbBlock *block, lbArgKind arg_kind) {
 	if (p->debug_info == nullptr) {
 		return;
 	}
@@ -1042,8 +1041,15 @@ void lb_add_debug_param_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, T
 	// NOTE(bill, 2022-02-01): For parameter values, you must insert them at the end of the decl block
 	// The reason is that if the parameter is at index 0 and a pointer, there is not such things as an
 	// instruction "before" it.
-	LLVMDIBuilderInsertDeclareAtEnd(m->debug_builder, storage, var_info, llvm_expr, llvm_debug_loc, block->block);
-	// LLVMDIBuilderInsertDbgValueAtEnd(m->debug_builder, storage, var_info, llvm_expr, llvm_debug_loc, block->block);
+	switch (arg_kind) {
+	case lbArg_Direct:
+		LLVMDIBuilderInsertDbgValueAtEnd(m->debug_builder, storage, var_info, llvm_expr, llvm_debug_loc, block->block);
+		break;
+	case lbArg_Indirect:
+		LLVMDIBuilderInsertDeclareAtEnd(m->debug_builder, storage, var_info, llvm_expr, llvm_debug_loc, block->block);
+		break;
+	}
+
 }
 
 

+ 2 - 2
src/llvm_backend_proc.cpp

@@ -552,7 +552,7 @@ void lb_begin_procedure_body(lbProcedure *p) {
 						if (original_value != value && LLVMIsALoadInst(value)) {
 							debug_storage_value = LLVMGetOperand(value, 0);
 						}
-						lb_add_debug_param_variable(p, debug_storage_value, e->type, e->token, param_index+1, block);
+						lb_add_debug_param_variable(p, debug_storage_value, e->type, e->token, param_index+1, block, arg_type->kind);
 					}
 				} else if (arg_type->kind == lbArg_Indirect) {
 					if (e->token.string.len != 0 && !is_blank_ident(e->token.string)) {
@@ -560,7 +560,7 @@ void lb_begin_procedure_body(lbProcedure *p) {
 						ptr.value = LLVMGetParam(p->value, param_offset+param_index);
 						ptr.type = alloc_type_pointer(e->type);
 						lb_add_entity(p->module, e, ptr);
-						lb_add_debug_param_variable(p, ptr.value, e->type, e->token, param_index+1, p->decl_block);
+						lb_add_debug_param_variable(p, ptr.value, e->type, e->token, param_index+1, p->decl_block, arg_type->kind);
 					}
 				}
 			}

+ 23 - 0
tests/core/image/test_core_image.odin

@@ -16,6 +16,7 @@ import "core:image"
 import pbm "core:image/netpbm"
 import "core:image/png"
 import "core:image/qoi"
+import "core:image/tga"
 
 import "core:bytes"
 import "core:hash"
@@ -1530,6 +1531,28 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 						}
 					}
 
+					// Roundtrip through TGA to test the TGA encoder and decoder.
+					if img.depth == 8 && (img.channels == 3 || img.channels == 4) {
+						tga_buffer: bytes.Buffer
+						defer bytes.buffer_destroy(&tga_buffer)
+						tga_save_err := tga.save(&tga_buffer, img)
+
+						error  = fmt.tprintf("%v test %v TGA save failed with %v.", file.file, count, tga_save_err)
+						expect(t, tga_save_err == nil, error)
+
+						if tga_save_err == nil {
+							tga_img, tga_load_err := tga.load(tga_buffer.buf[:])
+							defer tga.destroy(tga_img)
+
+							error  = fmt.tprintf("%v test %v TGA load failed with %v.", file.file, count, tga_load_err)
+							expect(t, tga_load_err == nil, error)
+
+							tga_hash := hash.crc32(tga_img.pixels.buf[:])
+							error  = fmt.tprintf("%v test %v TGA load hash is %08x, expected it match PNG's %08x with %v.", file.file, count, tga_hash, png_hash, test.options)
+							expect(t, tga_hash == png_hash, error)
+						}
+					}
+
 					{
 						// Roundtrip through PBM to test the PBM encoders and decoders - prefer binary
 						pbm_buf, pbm_save_err := pbm.save_to_buffer(img)

+ 12 - 1
vendor/darwin/Foundation/NSWindow.odin

@@ -103,7 +103,18 @@ Window_alloc :: proc() -> ^Window {
 
 @(objc_type=Window, objc_name="initWithContentRect")
 Window_initWithContentRect :: proc (self: ^Window, contentRect: Rect, styleMask: WindowStyleMask, backing: BackingStoreType, doDefer: bool) -> ^Window {
-	return msgSend(^Window, self, "initWithContentRect:styleMask:backing:defer:", contentRect, styleMask, backing, doDefer)
+	self := self
+	// HACK: due to a compiler bug, the generated calling code does not
+	// currently work for this message. Has to do with passing a struct along
+	// with other parameters, so we don't send the rect here.
+	// Omiting the rect argument here actually works, because of how the C
+	// calling conventions are defined.
+	self = msgSend(^Window, self, "initWithContentRect:styleMask:backing:defer:", styleMask, backing, doDefer)
+
+	// apply the contentRect now, since we did not pass it to the init call
+	msgSend(nil, self, "setContentSize:", contentRect.size)
+	msgSend(nil, self, "setFrameOrigin:", contentRect.origin)
+	return self
 }
 @(objc_type=Window, objc_name="contentView")
 Window_contentView :: proc(self: ^Window) -> ^View {