summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorFox Caminiti <fox@foxcam.net>2022-07-27 11:00:45 -0400
committerFox Caminiti <fox@foxcam.net>2022-07-27 11:00:45 -0400
commit83ce428d8bb5f4a762abf879adec076bc34cf36a (patch)
treec1500f027d9eec514ba1a2912e7a4763e7be26b2 /main.cpp
parentc6bd84c356b6aaa029b9708d7b99a4aba1673b6b (diff)
full support for odd-dimension bitmaps and comps
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp75
1 files changed, 35 insertions, 40 deletions
diff --git a/main.cpp b/main.cpp
index 59d0e3a..3a517be 100644
--- a/main.cpp
+++ b/main.cpp
@@ -105,7 +105,9 @@ global_variable uint32 volatile CompletedJobs;
global_variable uint32 volatile NextEntryToDo;
global_variable uint32 volatile EntryCount;
global_variable bool32 IsRendering = false;
-global_variable bool32 AVXEnabled = true;
+global_variable bool32 D = true;
+global_variable instruction_mode InstructionMode = scalar_only;
+
render_entry Entries[256];
@@ -122,6 +124,7 @@ SDL_sem *Semaphore;
#endif
#include "prenderer.cpp"
#include "video.cpp"
+#include "bitmap_calls.cpp"
#include "createcalls.cpp"
#include "my_imgui_widgets.cpp"
@@ -132,7 +135,8 @@ MainFunction(main_sdl *Main, memory *Memory,
project_state *State, project_data *File,
cache_pool *Cache, pixel_buffer *CompBuffer)
{
- SSE_ClearBuffer(CompBuffer);
+ ClearBuffer(CompBuffer, CompBuffer->OriginalBuffer);
+ ClearBuffer(CompBuffer, CompBuffer->EffectBuffer);
for (int i = 0; i < File->NumberOfLayers; i++) {
project_layer *Layer = File->Layer[i];
if (Layer->RenderInfo) {
@@ -301,14 +305,16 @@ int main(int argc, char *argv[]) {
InitMemoryTable(&GlobalMemory, &Memory, 10 * 1024 * 1024, F_Strings, "Strings");
InitMemoryTable(&GlobalMemory, &Memory, 1024 * 1024 * 1024, B_Scratch, "Scratch buffer");
- if (!SDL_HasAVX2()) {
- AVXEnabled = false;
- printf("CPU does not have AVX2!");
- return -1;
- }
+ project_state State = {};
+ if (SDL_HasSSE2()) {
+ InstructionMode = sse_enabled;
+ }
+ if (SDL_HasAVX2()) {
+ InstructionMode = avx_enabled;
+ }
- project_state State = {};
+ InstructionMode = scalar_only;
project_data File = {};
File.Width = 1280;
@@ -339,7 +345,6 @@ int main(int argc, char *argv[]) {
// CreateLayerFromSource(&File, &State, &Memory, File.Source[0]);
// CreateLayerFromSource(&File, &State, &Memory, File.Source[1]);
-#if 1
// shm_unlink("/testl");
// int fd = shm_open("/testl", O_CREAT | O_EXCL | O_RDWR,
// S_IRUSR | S_IWUSR);
@@ -362,17 +367,18 @@ int main(int argc, char *argv[]) {
// if (sem_init(&shmp->sem2, 1, 0) == -1)
// Assert(0);
- // CreateLayer(&File, &Memory);
- // CreateRenderInfo(File.Layer[1], &Memory, File, video, "./asset/24.mp4");
- // File.Layer[1]->Name = "yuyu";
- // File.Layer[1]->StartFrame = 0;
- // File.Layer[1]->EndFrame = 65;
-#else
- CreateDebugLayer(&File, &Memory, 12, 8);
- File.Layer[0]->Name = "debug";
- File.Layer[0]->StartFrame = 0;
- File.Layer[0]->EndFrame = 65;
-#endif
+ // CreateLayerFromSource(&File, &State, &Memory, "../asset/24.mp4");
+ // project_layer *Layer1 = CreateDebugLayer(&File, &Memory, 9, 14);
+ // project_layer *Layer1 = CreateSolidLayer(&File, &Memory, 9, 13, V4(1.0, 1.0, 1.0, 1.0));
+ // Layer1->x.CurrentValue.f = 7;
+ // Layer1->y.CurrentValue.f = 4;
+ // Layer1->StartFrame = 0;
+ // Layer1->EndFrame = File.EndFrame;
+
+ // CreateDebugLayer(&File, &Memory, 12, 8);
+ // File.Layer[0]->Name = "debug";
+ // File.Layer[0]->StartFrame = 0;
+ // File.Layer[0]->EndFrame = 65;
// CreateLayer(&File, &Memory);
@@ -418,7 +424,7 @@ int main(int argc, char *argv[]) {
// AddEffect(File.Layer[0], &Memory, 0);
// AddEffect(File.Layer[0], &Memory, 0);
- for (int i = 0; i < 3; i++)
+ // for (int i = 0; i < 3; i++)
// CreateLayer(&File, &Memory);
// DebugPrintMemoryUsage(Memory);
@@ -472,8 +478,10 @@ int main(int argc, char *argv[]) {
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
+#if DEBUG
// uint32 ScreenSize[2] = {2560/1.2, 1600/1.2};
- // real32 ScreenSize[2] = {3840/1.2, 2160/1.2};
+ real32 ScreenSize[2] = {3840/1.2, 2160/1.2};
+#else
real32 ScreenSize[2];
SDL_DisplayMode current;
int windowtest = SDL_GetCurrentDisplayMode(0, &current);
@@ -484,6 +492,7 @@ int main(int argc, char *argv[]) {
ScreenSize[0] = 1920;
ScreenSize[1] = 1080;
}
+#endif
SDL_Window* window = SDL_CreateWindow("Event Tester", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, ScreenSize[0], ScreenSize[1], window_flags);
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
SDL_GL_MakeCurrent(window, gl_context);
@@ -513,8 +522,8 @@ int main(int argc, char *argv[]) {
GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // This is required on WebGL for non power-of-two textures
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Same
#if defined(GL_UNPACK_ROW_LENGTH) && !defined(__EMSCRIPTEN__)
@@ -577,6 +586,7 @@ int main(int argc, char *argv[]) {
if (State.UpdateFrame && !IsRendering) {
MainFunction(0, &Memory, &State, &File, &Cache, &CompBuffer);
State.UpdateFrame = 0;
+ OutputToViewport(&CompBuffer, &State, textureID);
}
#if THREADED
@@ -585,12 +595,7 @@ int main(int argc, char *argv[]) {
CheckQueue(RenderInfo, 8);
}
if (CompletedJobs == 16) {
-#if PACKEDRGB
- Unpack4x4Chunk(&CompBuffer);
- // SSE_CopyToBuffer(CompBuffer);
-#else
- PackBitmapRGB(&CompBuffer);
-#endif
+ Convert4x4Chunk(&CompBuffer, 1);
EndRenderState(&State);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, CompBuffer.Width, CompBuffer.Height, GL_RGBA, GL_UNSIGNED_BYTE,
@@ -603,16 +608,6 @@ int main(int argc, char *argv[]) {
}
}
#else
-#if PACKEDRGB
- Unpack4x4Chunk(&CompBuffer);
- // SSE_CopyToBuffer(CompBuffer);
-#else
- PackBitmapRGB(&CompBuffer);
-#endif
- EndRenderState(&State);
- glBindTexture(GL_TEXTURE_2D, textureID);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, CompBuffer.Width, CompBuffer.Height, GL_RGBA, GL_UNSIGNED_BYTE,
- CompBuffer.EffectBuffer);
#endif
ImGui::Render();