git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@545 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
IoIxD
2025-11-01 04:32:06 +00:00
parent d1697ed46a
commit 0b5463e1d1
3 changed files with 69 additions and 12 deletions

View File

@@ -202,8 +202,20 @@ MwWidget MwColorPicker(MwWidget handle, const char* title) {
MwPoint p;
color_picker* wheel;
MwWidget window;
int ww = MwGetInteger(handle, MwNwidth);
int wh = MwGetInteger(handle, MwNheight);
// remove later
MwLLVec test_1 = MwLLVecU32x2(2, 5);
MwLLVec test_2 = MwLLVecU32x2(2, 12);
MwLLVec test_out = MwLLVecU32x2(0, 0);
MwLLMathAdd(&test_1, &test_2, &test_out);
printf("simd result:\n");
printf("%d + %d = %d\n", test_1.un.u32.a, test_2.un.u32.a, test_out.un.u32.a);
printf("%d + %d = %d\n", test_1.un.u32.b, test_2.un.u32.b, test_out.un.u32.b);
int ww = MwGetInteger(handle, MwNwidth);
int wh = MwGetInteger(handle, MwNheight);
p.x = p.y = 0;
window = MwVaCreateWidget(MwWindowClass, "main", handle, MwDEFAULT, MwDEFAULT,
@@ -214,7 +226,5 @@ MwWidget MwColorPicker(MwWidget handle, const char* title) {
MwLLDetach(window->lowlevel, &p);
MwLLMakePopup(window->lowlevel, handle->lowlevel);
MwLLVec v = MwLLVecU8x8(0, 0, 0, 0, 0, 0, 0, 0);
return window;
}

View File

@@ -38,25 +38,26 @@ switch(ty) {
return vec;
}
static MwBool hasMMX(void) {
MwU32 _eax = 1;
MwU32 _ebx, _edx;
#if defined(__WATCOMC__) || defined(__i386__) || defined(__amd64__)
static cpuFeatures getCPUFeatures(void) {
MwU32 _eax = 1;
cpuFeatures _edx;
#ifdef __WATCOMC__
__asm {
cpuid
mov _eax, eax
mov _ebx, ebx
mov _edx, edx
}
#else
__asm__ __volatile__(
"cpuid" : "=a"(_eax), "=b"(_ebx), "=d"(_edx)
"cpuid" : "=a"(_eax), "=d"(_edx)
: "a"(1));
#endif
return (_edx & (1 << 23)) == (1 << 23);
return _edx;
}
#endif
static MwLLMathVTable** mwLLMultiTable;
static MwLLMathVTable* multiTableSetupAndGet(int ty);
@@ -69,10 +70,20 @@ static MwLLMathVTable* getMultiTable(int ty) {
}
static MwLLMathVTable* multiTableSetupAndGet(int ty) {
#if defined(__WATCOMC__) || defined(__i386__) || defined(__amd64__)
cpuFeatures features;
#endif
mwLLMultiTable = default_multi_table();
#if defined(__i386__) || defined(__x86_64__)
if(hasMMX()) {
#if defined(__WATCOMC__) || defined(__i386__) || defined(__amd64__)
features = getCPUFeatures();
printf("Avaliable x86_64 Features:\n");
printf("\tMMX: %s\n", features.mmx ? "true" : "false");
printf("\tSSE: %s\n", features.sse ? "true" : "false");
printf("\tSSE2: %s\n", features.sse2 ? "true" : "false");
if(features.mmx) {
mmx_apply(mwLLMultiTable);
}
#endif

View File

@@ -3,8 +3,44 @@
#ifndef __MW_LOWLEVEL_INTERNAL_MATH_H__
#define __MW_LOWLEVEL_INTERNAL_MATH_H__
#include <Mw/BaseTypes.h>
#include <Mw/LowLevelMath.h>
/* Bitfield of cpu features we get from x86's CPUID */
#if defined(__WATCOMC__) || defined(__i386__) || defined(__amd64__)
typedef struct _cpuFeatures cpuFeatures;
struct _cpuFeatures {
MwBool fpu : 1; /* x87 FPU on chip */
MwBool vme : 1; /* Virtual-8086 Mode Enhancement */
MwBool de : 1; /* Debugging Extensions */
MwBool pse : 1; /* Page Size Extensions */
MwBool tsc : 1; /* Time Stamp Counter */
MwBool msr : 1; /* RDMSR and WRMSR Support */
MwBool pae : 1; /* Physical Address Extensions */
MwBool mce : 1; /* Machine Check Exception */
MwBool cx8 : 1; /* CMPXCHG8B instr */
MwBool apic : 1; /* APIC on Chip */
MwBool sep : 1; /* SYSENTER and SYSEXIT instrs */
MwBool mtrr : 1; /* Memory Type Range Registers */
MwBool pge : 1; /* Page Global Bit */
MwBool mca : 1; /* Machine Check Architecture */
MwBool cmov : 1; /* Conditional Move Instrs */
MwBool pat : 1; /* Page Attribute Table */
MwBool pse36 : 1; /* 36-Bit Page Size Extension */
MwBool psn : 1; /* Processor Serial Number */
MwBool clflush : 1; /* CLFLUSH instr */
MwBool ds : 1; /* Debug Store */
MwBool acpi : 1; /* Thermal Monitor and Software Controlled Clock Facilities */
MwBool mmx : 1; /* Intel MMX Technology */
MwBool fxsr : 1; /* XSAVE and FXRSTOR Instrs */
MwBool sse : 1; /* SSE */
MwBool sse2 : 1; /* SSE2 */
MwBool ss : 1; /* Self Snoop */
MwBool hit : 1; /* Max APIC IDs */
MwBool tm : 1; /* Thermal Monitor */
MwBool pbe : 1; /* Pending Break Enable */
};
#endif
#include "nbsd_math.h"
struct _MwLLMathVTable {