Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force GPU to always render if on hud #22

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lua/entities/gmod_wire_gpu/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

-- Fetch all monitors
local count = um:ReadShort()
for i=1,count do

Check warning on line 35 in lua/entities/gmod_wire_gpu/cl_init.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
Monitors[gpuIdx][i] = um:ReadLong()
end

Expand Down Expand Up @@ -101,7 +101,7 @@

-- Draw outlines in chip mode
local tempDrawOutline = self.DrawEntityOutline
self.DrawEntityOutline = function(self) if self.ChipType ~= 0 then tempDrawOutline(self) end end

Check warning on line 104 in lua/entities/gmod_wire_gpu/cl_init.lua

View workflow job for this annotation

GitHub Actions / lint

"Shadowing"

Variable 'self' shadows existing binding, defined at line 67, column 10
end

-- Assert that sprite buffer exists and is available for any operations on it
Expand Down Expand Up @@ -133,8 +133,8 @@
self.VM.Memory[65527] = math.Clamp(self.VM.Memory[65527],1,1200000)

-- Calculate timing
Cycles = math.max(1,math.floor(self.VM.Memory[65527]*self.DeltaTime*0.5))

Check warning on line 136 in lua/entities/gmod_wire_gpu/cl_init.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 136 in lua/entities/gmod_wire_gpu/cl_init.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
self.VM.TimerDT = self.DeltaTime/Cycles

Check warning on line 137 in lua/entities/gmod_wire_gpu/cl_init.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
self.VM.TIMER = self.CurrentTime
self.VM.ASYNC = 1
else
Expand Down Expand Up @@ -194,7 +194,7 @@
if self.VM.VertexMode == 0 then self.VM.RenderEnable = 0 end
else
-- Remember screen RT if this is the first switch
local noRT = true

Check warning on line 197 in lua/entities/gmod_wire_gpu/cl_init.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: noRT
if not self.ScreenRTSet then
self.ScreenRT = render.GetRenderTarget()
self.ScreenRTWidth = ScrW()
Expand Down Expand Up @@ -287,11 +287,11 @@
local ply = LocalPlayer()
local trace = ply:GetEyeTraceNoCursor()
if (trace.Entity and trace.Entity:IsValid() and trace.Entity == self) then
local dist = trace.Normal:Dot(trace.HitNormal)*trace.Fraction*(-16384)

Check warning on line 290 in lua/entities/gmod_wire_gpu/cl_init.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace after ')'

Check warning on line 290 in lua/entities/gmod_wire_gpu/cl_init.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
dist = math.max(dist, trace.Fraction*16384-self:BoundingRadius())

Check warning on line 291 in lua/entities/gmod_wire_gpu/cl_init.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

if (dist < 256) then
local pos = WorldToLocal( trace.HitPos, Angle(), pos, ang )

Check warning on line 294 in lua/entities/gmod_wire_gpu/cl_init.lua

View workflow job for this annotation

GitHub Actions / lint

"Shadowing"

Variable 'pos' shadows existing binding, defined at line 285, column 25
local x = 0.5+pos.x/(monitor.RS*(1024/monitor.RatioX))
local y = 0.5-pos.y/(monitor.RS*1024)

Expand Down Expand Up @@ -440,6 +440,9 @@
local screenWidth = ScrW()
local screenHeight = ScrH()

if math.min(1/30,CurTime() - (videoGPU.PreviousTime or 0)) > 0 then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This equation looks wrong. Also why not just draw every frame instead of framerate limiting it?

Copy link
Member Author

@DerelictDrone DerelictDrone Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think it's safe to remove the framelimit check, I was paranoid about making sure I'm calling ent:draw when it will guarantee a rendered frame but hudpaint seems like a safe context(delta-wise) to call the gpu's draw function without a framelimit check.

So, my reasoning was that with the GPU's draw func, it checks the equation(I copied it from ent:draw) it doesn't check between last rendered frame and now, only between last draw call and now, so if this gets called quickly enough that it results in a deltatime of less than or equal to 0 it will stall GPU rendering entirely(until called less frequently) rather than stall until time between lastframe and now is within frame limit, this should be reworked soon.

videoGPU:Draw()
end
videoGPU:RenderVertex(screenWidth,screenHeight)
end
end
Expand Down
Loading