diff options
-rw-r--r-- | createcalls.cpp | 16 | ||||
-rw-r--r-- | defines.h | 2 | ||||
-rw-r--r-- | main.cpp | 32 | ||||
-rw-r--r-- | main.h | 1 | ||||
-rw-r--r-- | my_imgui_widgets.cpp | 225 | ||||
-rw-r--r-- | stable_diffusion.h | 1 |
6 files changed, 232 insertions, 45 deletions
diff --git a/createcalls.cpp b/createcalls.cpp index 12fb2de..b6ce7e1 100644 --- a/createcalls.cpp +++ b/createcalls.cpp @@ -214,7 +214,8 @@ Bezier_EvaluateValue(project_state *State, bezier_point *PointAddress, v2 *Pos, if (PointAddress->IsSelected) { if (State->Interact_Active == interact_type_keyframe_move) { Pos[PointAddress->IsSelected - 1].x += (int32)State->Interact_Offset[0]; - Pos[PointAddress->IsSelected - 1].y -= (State->Interact_Offset[1] / GraphZoomHeight / Y_Increment); + if (State->Interact_Modifier != 1) + Pos[PointAddress->IsSelected - 1].y -= (State->Interact_Offset[1] / GraphZoomHeight / Y_Increment); } else if (State->Interact_Active == interact_type_keyframe_scale) { Pos[1].x += State->Interact_Offset[0]; Pos[2].x -= State->Interact_Offset[0]; @@ -901,8 +902,8 @@ void Source_UICreateButton(project_data *File, project_state *State, memory *Mem } block_layer *Layer = Layer_Init(File, Memory); Layer->Block_Source_Index = i; - Layer->x.CurrentValue = Source->Width / 2; - Layer->y.CurrentValue = Source->Height / 2; + Layer->x.CurrentValue = Comp->Width/2; + Layer->y.CurrentValue = Comp->Height/2; Layer->Vertical_Offset = TopOffset-1; Layer->Frame_Start = Comp->Frame_Start; Layer->Frame_End = Comp->Frame_End; @@ -1100,8 +1101,7 @@ void Bitmap_SwapData(uint8 *Address_0, uint8 *Address_1, uint64 Size, uint16 Byt #if NEON Assert(InstructionMode != instruction_mode_neon); -#endif - +#else if (BytesPerPixel == 4) { uint32 Temp = 0; while (i < Size) { @@ -1146,6 +1146,8 @@ void Bitmap_SwapData(uint8 *Address_0, uint8 *Address_1, uint64 Size, uint16 Byt } else { Assert(0); } +#endif + } @@ -1219,6 +1221,8 @@ PaintTest(brush_info B, void *Buffer, rectangle RenderRegion) } } +#if ARM +#else static void PaintTest_AVX2(brush_info B, void *Buffer, rectangle RenderRegion) { @@ -1300,7 +1304,7 @@ Brush_Render(project_state *State, ui *UI, layer_transforms T_Layer, block_compo PaintTest(B, BitmapAddress, B.LayerBounds); } } - +#endif #if 0 @@ -42,7 +42,7 @@ typedef uint64 ptrsize; // is there a compiler variable for 32 vs 64 bit like #define AmountOf(Array) sizeof((Array)) / sizeof((Array)[1]) #if ARM -#define GetCPUTime() Assert(0) +#define GetCPUTime() 0 #else #define GetCPUTime() __rdtsc() #endif @@ -329,8 +329,8 @@ Render_Comp(project_data *File, project_state *State, memory *Memory, ImGuiIO io int32 Offset = (State->Interact_Active == interact_type_keyframe_move) ? (int32)State->Interact_Offset[0] : 0; for (int h = 0; h < AmountOf(Layer->Property); h++) { property_channel *Property = &Layer->Property[h]; - sorted_property_info *InfoLocation = Property_GetSortedInfo(SortedPropertyInfo, i, h); - uint16 *ArrayLocation = Property_GetSortedArray(SortedPropertyArray, i, h); + sorted_property_info *InfoLocation = Property_GetSortedInfo(SortedPropertyInfo, Index_Physical, h); + uint16 *ArrayLocation = Property_GetSortedArray(SortedPropertyArray, Index_Physical, h); if (Property->Block_Bezier_Count) { real32 MinY, MaxY; Property_MinMax_Y(Memory, State, Property, InfoLocation, &MinY, &MaxY); @@ -380,14 +380,11 @@ Render_Comp(project_data *File, project_state *State, memory *Memory, ImGuiIO io uint64 ScratchActive = 0; if (!Layer->IsPrecomp) { block_source *Source; - if (State->PreviewSource == -1) { - Source = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, Layer->Block_Source_Index); - } else { + if ((State->PreviewSource != -1) && Layer->IsSelected) { Source = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, State->PreviewSource); + } else { + Source = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, Layer->Block_Source_Index); } - Width = Source->Width; - Height = Source->Height; - BytesPerPixel = Source->BytesPerPixel; if (Source->Type == source_type_principal || Source->Type == source_type_principal_temp) { if (State->Interact_Active == interact_type_brush && State->Brush.LayerToPaint_Index == Index_Physical) { Assert(Source->Type == source_type_principal); @@ -428,7 +425,9 @@ Render_Comp(project_data *File, project_state *State, memory *Memory, ImGuiIO io } BitmapAddress = Memory_Block_Bitmap_AddressAtIndex(Memory, Entry->Block_StartIndex); } - + Width = Source->Width; + Height = Source->Height; + BytesPerPixel = Source->BytesPerPixel; } else { block_composition *Precomp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, Layer->Block_Source_Index); BitmapAddress = Render_Comp(File, State, Memory, io, SortedCompArray, SortedLayerArray, @@ -453,6 +452,8 @@ Render_Comp(project_data *File, project_state *State, memory *Memory, ImGuiIO io } */ + Assert(Width); + Assert(Height); transform_info T = Transform_Calculate(State, Memory, File, Layer, Comp, Width, Height, BytesPerPixel); T.SourceBuffer = BitmapAddress; rectangle RenderRegion = {0, 0, Comp->Width, Comp->Height}; @@ -588,19 +589,24 @@ int main(int argc, char *argv[]) { #if 0 { - uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/t_a.png"); + uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/hand/a.png"); block_source *Source = (block_source *)Memory_Block_AddressAtIndex(&Memory, F_Sources, 0); Source->IsSelected = true; } { - uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/t_b.png"); + uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/hand/b.jpg"); block_source *Source = (block_source *)Memory_Block_AddressAtIndex(&Memory, F_Sources, 1); Source->IsSelected = true; } { - uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/t_c.png"); + uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/hand/c.png"); + block_source *Source = (block_source *)Memory_Block_AddressAtIndex(&Memory, F_Sources, 2); + Source->IsSelected = true; + } + { + uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/hand/d.png"); block_source *Source = (block_source *)Memory_Block_AddressAtIndex(&Memory, F_Sources, 2); Source->IsSelected = true; } @@ -711,7 +717,7 @@ int main(int argc, char *argv[]) { Brush_CalcBitmapAlphaFromSize(&Memory, &State->Brush, 4); State_BindBrushTexture(&Memory, &State->Brush, 4); - // File_Open(File, State, &Memory, "test"); + File_Open(File, State, &Memory, "test"); #if STABLE curl_global_init(CURL_GLOBAL_ALL); @@ -358,6 +358,7 @@ struct project_state // selection_type RecentSelectionType = selection_none; interact_type Interact_Active; + int32 Interact_Modifier; real32 Interact_Offset[12]; void *Interact_Address; diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp index cf33666..2ecdf9e 100644 --- a/my_imgui_widgets.cpp +++ b/my_imgui_widgets.cpp @@ -288,14 +288,6 @@ ImGui_SD_Thumbnail(project_data *File, project_state *State, ui *UI, memory *Mem draw_list->AddImage((void *)(intptr_t)Source->ThumbnailTex, ImgMin, ImgMax); if (ImGui::IsItemHovered()) { - int h = 0, c = 0, a = 0; - while (Block_Loop(Memory, F_Layers, File->Layer_Count, &h, &c, &a)) { - block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, a); - if (Layer->Block_Source_Index == SourceArray[i] && Layer->IsSelected) { - State->PreviewLayer = a; - break; - } - } State->PreviewSource = SourceArray[i]; State->UpdateFrame = true; Active = true; @@ -311,7 +303,6 @@ ImGui_SD_Thumbnail(project_data *File, project_state *State, ui *UI, memory *Mem } if (State->PreviewSource != -1 && !Active) { State->PreviewSource = -1; - State->PreviewLayer = -1; State->UpdateFrame = true; } if (ImGui::BeginPopup("temptosource")) { @@ -418,6 +409,7 @@ ImGui_SD_Prompt(project_data *File, project_state *State, ui *UI, memory *Memory if (SD->Mode) { ImGui::SliderFloat("Denoising strength", &SD->DenoisingStrength, 0, 1, "%.2f"); } + ImGui::SliderInt("Batch size", &SD->BatchSize, 1, 8, "%i"); ImGui::InputInt("Seed", &SD->Seed); ImGui::End(); } @@ -804,18 +796,35 @@ ImGui_TransformUI(project_data *File, project_state *State, memory *Memory, ui * // Second condition so you don't have to reach for Enter. if (ImGui::IsKeyPressed(ImGuiKey_Enter) || (ImGui::IsMouseClicked(ImGuiMouseButton_Left) && io.KeyCtrl)) { int h = 0, c = 0, i = 0; - History_Entry_Commit(Memory, "Transform layers"); + if (!io.KeyCtrl) + History_Entry_Commit(Memory, "Transform layers"); while (Block_Loop(Memory, F_Layers, File->Layer_Count, &h, &c, &i)) { block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, i); if (Layer->IsSelected) { - History_Action_Swap(Memory, F_File, sizeof(Layer->x.CurrentValue), &Layer->x.CurrentValue); - History_Action_Swap(Memory, F_File, sizeof(Layer->y.CurrentValue), &Layer->y.CurrentValue); - History_Action_Swap(Memory, F_File, sizeof(Layer->scale.CurrentValue), &Layer->scale.CurrentValue); - History_Action_Swap(Memory, F_File, sizeof(Layer->rotation.CurrentValue), &Layer->rotation.CurrentValue); - Transform_ApplyInteractive(*(interact_transform *)&State->Interact_Offset[0], &Layer->x.CurrentValue, &Layer->y.CurrentValue, &Layer->rotation.CurrentValue, &Layer->scale.CurrentValue); + if (io.KeyCtrl) { + layer_transforms T = Layer_GetTransforms(Layer); + Transform_ApplyInteractive(*(interact_transform *)&State->Interact_Offset[0], &T.x, &T.y, &T.rotation, &T.scale); + property_channel *Property[4] = { &Layer->x, &Layer->y, &Layer->rotation, &Layer->scale }; + real32 Val[4] = { T.x, T.y, T.rotation, T.scale }; + for (int a = 0; a < 4; a++) { + if (Property[a]->CurrentValue != Val[a]) { + History_Entry_Commit(Memory, "Add keyframe"); + bezier_point Point = { 1, {(real32)State->Frame_Current, Val[a], -1, 0, 1, 0}, interpolation_type_linear, 0, {0, 0, 0}, 0 }; + Bezier_Add(Memory, Property[a], Point); + History_Entry_End(Memory); + } + } + } else { + History_Action_Swap(Memory, F_File, sizeof(Layer->x.CurrentValue), &Layer->x.CurrentValue); + History_Action_Swap(Memory, F_File, sizeof(Layer->y.CurrentValue), &Layer->y.CurrentValue); + History_Action_Swap(Memory, F_File, sizeof(Layer->scale.CurrentValue), &Layer->scale.CurrentValue); + History_Action_Swap(Memory, F_File, sizeof(Layer->rotation.CurrentValue), &Layer->rotation.CurrentValue); + Transform_ApplyInteractive(*(interact_transform *)&State->Interact_Offset[0], &Layer->x.CurrentValue, &Layer->y.CurrentValue, &Layer->rotation.CurrentValue, &Layer->scale.CurrentValue); + } } } - History_Entry_End(Memory); + if (!io.KeyCtrl) + History_Entry_End(Memory); State->Interact_Active = interact_type_none; State->UpdateFrame = true; } @@ -2041,18 +2050,14 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, if (State->Interact_Active == interact_type_keyframe_move || State->Interact_Active == interact_type_keyframe_rotate || State->Interact_Active == interact_type_keyframe_scale) { - // bool32 CommitAction = 0; - // if (!CommitAction) { - // History_Entry_Commit(Memory, "Delete source"); - // CommitAction = 1; - History_Entry_Commit(Memory, "Add keyframe"); + History_Entry_Commit(Memory, "Move keyframe"); int h = 0, c = 0, i = 0; while (Block_Loop(Memory, F_Layers, File->Layer_Count, &h, &c, &i)) { block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, i); if (!Layer->IsSelected) continue; for (int h = 0; h < AmountOf(Layer->Property); h++) { - uint16 *ArrayLocation = SortedPropertyArray + (i * 7 * MAX_KEYFRAMES_PER_BLOCK) + (h * MAX_KEYFRAMES_PER_BLOCK); + uint16 *ArrayLocation = Property_GetSortedArray(SortedPropertyArray, i, h); property_channel *Property = &Layer->Property[h]; for (int p = 0; p < Property->Keyframe_Count; p++) { int k = ArrayLocation[p]; @@ -2074,6 +2079,7 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, State->Interact_Offset[2] = 0; State->Interact_Offset[3] = 0; State->Interact_Active = interact_type_none; + State->Interact_Modifier = 0; } UI->BoxSelect = true; } @@ -2127,9 +2133,16 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me } } if (ImGui::IsKeyPressed(ImGuiKey_X)) { - v4 Temp = UI->Color; - UI->Color = UI->AltColor; - UI->AltColor = Temp; + if (State->Interact_Active == interact_type_keyframe_move) { + if (State->Interact_Modifier != 1) + State->Interact_Modifier = 1; + else + State->Interact_Modifier = 0; + } else { + v4 Temp = UI->Color; + UI->Color = UI->AltColor; + UI->AltColor = Temp; + } } if (ImGui::IsKeyPressed(ImGuiKey_V)) { State->Tool = tool_default; @@ -3799,6 +3812,168 @@ static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]" "\n DockNode ID=0x00000008 Parent=0x00000006 SizeRef=502,256 Selected=0x812F222D" "\n DockNode ID=0x00000002 Parent=0x8B93E3BD SizeRef=3200,627 HiddenTabBar=1 Selected=0x0F18B61B"; +[Window][DockSpaceViewport_11111111] +Pos=0,0 +Size=3200,1800 +Collapsed=0 + +[Window][Debug##Default] +Pos=122,442 +Size=400,400 +Collapsed=0 + +[Window][Viewport] +Pos=596,34 +Size=2079,1149 +Collapsed=0 +DockId=0x00000010,0 + +[Window][###Properties] +Pos=0,34 +Size=594,452 +Collapsed=0 +DockId=0x0000000B,0 + +[Window][Timeline] +Pos=0,1185 +Size=3200,615 +Collapsed=0 +DockId=0x0000000A,0 + +[Window][Dear ImGui Demo] +Pos=2677,34 +Size=523,633 +Collapsed=0 +DockId=0x00000011,1 + +[Window][Files] +Pos=2677,669 +Size=523,514 +Collapsed=0 +DockId=0x00000012,0 + +[Window][Effects list] +Pos=2717,414 +Size=483,623 +Collapsed=0 +DockId=0x00000008,0 + +[Window][Graph editor] +Pos=0,949 +Size=3200,526 +Collapsed=0 +DockId=0x00000009,0 + +[Window][undotree] +Pos=2367,83 +Size=256,565 +Collapsed=0 + +[Window][memoryviewer] +Pos=50,273 +Size=800,200 +Collapsed=0 + +[Window][Example: Custom rendering] +Pos=758,789 +Size=485,414 +Collapsed=0 + +[Window][Memory viewer] +Pos=2677,669 +Size=523,514 +Collapsed=0 +DockId=0x00000012,1 + +[Window][Graph info] +Pos=1303,1142 +Size=235,353 +Collapsed=0 + +[Window][Properties] +Pos=0,34 +Size=495,1056 +Collapsed=0 +DockId=0x0000000F,0 + +[Window][Colors] +Pos=2677,34 +Size=523,633 +Collapsed=0 +DockId=0x00000011,0 + +[Window][Menu] +Pos=0,0 +Size=3200,32 +Collapsed=0 +DockId=0x0000000D,0 + +[Window][Stable Diffusion] +Pos=2206,684 +Size=421,462 +Collapsed=0 + +[Window][SD prompt input] +Pos=2677,669 +Size=523,514 +Collapsed=0 +DockId=0x00000012,2 + +[Window][Example: Console] +Pos=747,851 +Size=520,600 +Collapsed=0 + +[Window][SD gallery] +Pos=0,488 +Size=594,695 +Collapsed=0 +DockId=0x0000000C,0 + +[Table][0x861D378E,3] +Column 0 Weight=1.0000 +Column 1 Weight=1.0000 +Column 2 Weight=1.0000 + +[Table][0x1F146634,3] +RefScale=13 +Column 0 Width=63 +Column 1 Width=63 +Column 2 Width=63 + +[Table][0x64418101,3] +RefScale=13 +Column 0 Width=63 +Column 1 Width=63 +Column 2 Width=63 + +[Table][0xC9935533,3] +Column 0 Weight=1.0000 +Column 1 Weight=1.0000 +Column 2 Weight=1.0000 + +[Docking][Data] +DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,0 Size=3200,1800 Split=Y Selected=0x13926F0B + DockNode ID=0x0000000D Parent=0x8B93E3BD SizeRef=3200,32 HiddenTabBar=1 Selected=0xA57AB2C6 + DockNode ID=0x0000000E Parent=0x8B93E3BD SizeRef=3200,1766 Split=Y + DockNode ID=0x00000001 Parent=0x0000000E SizeRef=3200,1149 Split=X Selected=0x13926F0B + DockNode ID=0x00000003 Parent=0x00000001 SizeRef=594,1171 Split=Y Selected=0xDBB8CEFA + DockNode ID=0x0000000B Parent=0x00000003 SizeRef=521,452 Selected=0xDBB8CEFA + DockNode ID=0x0000000C Parent=0x00000003 SizeRef=521,695 Selected=0x56290987 + DockNode ID=0x00000004 Parent=0x00000001 SizeRef=2604,1171 Split=X Selected=0x13926F0B + DockNode ID=0x00000005 Parent=0x00000004 SizeRef=2079,1171 Split=X Selected=0x13926F0B + DockNode ID=0x0000000F Parent=0x00000005 SizeRef=495,856 Selected=0x199AB496 + DockNode ID=0x00000010 Parent=0x00000005 SizeRef=2199,856 CentralNode=1 Selected=0x13926F0B + DockNode ID=0x00000006 Parent=0x00000004 SizeRef=523,1171 Split=Y Selected=0x86FA2F90 + DockNode ID=0x00000007 Parent=0x00000006 SizeRef=502,412 Split=Y Selected=0x86FA2F90 + DockNode ID=0x00000011 Parent=0x00000007 SizeRef=483,633 Selected=0xBF7DFDC9 + DockNode ID=0x00000012 Parent=0x00000007 SizeRef=483,514 Selected=0x59A2A092 + DockNode ID=0x00000008 Parent=0x00000006 SizeRef=502,623 Selected=0x812F222D + DockNode ID=0x00000002 Parent=0x0000000E SizeRef=3200,615 Split=Y Selected=0x0F18B61B + DockNode ID=0x00000009 Parent=0x00000002 SizeRef=3250,526 Selected=0xA1F22F4D + DockNode ID=0x0000000A Parent=0x00000002 SizeRef=3250,323 HiddenTabBar=1 Selected=0x0F18B61B + + /* // Graph window diff --git a/stable_diffusion.h b/stable_diffusion.h index 19d0acf..b498a7c 100644 --- a/stable_diffusion.h +++ b/stable_diffusion.h @@ -26,6 +26,7 @@ struct sd_state int32 Height = 512; int32 SamplerIndex = 0; real32 CFG = 7; + int32 BatchSize = 4; real32 DenoisingStrength = 0.4; int32 Seed = -1; }; |