MCPcopy Create free account
hub / github.com/google/gapid / NewEnv

Method NewEnv

gapil/executor/env.go:132–165  ·  view source on GitHub ↗

NewEnv creates a new execution environment for the given capture.

(ctx context.Context, capture *capture.GraphicsCapture)

Source from the content-addressed store, hash-verified

130
131// NewEnv creates a new execution environment for the given capture.
132func (e *Executor) NewEnv(ctx context.Context, capture *capture.GraphicsCapture) *Env {
133 var id envID
134 var env *Env
135
136 func() {
137 envMutex.Lock()
138 defer envMutex.Unlock()
139
140 id = nextEnvID
141 nextEnvID++
142
143 env = &Env{
144 Executor: e,
145 id: envID(id),
146 }
147 envs[id] = env
148 }()
149
150 // Create the context and initialize the globals.
151 env.Arena = arena.New()
152 env.goCtx = ctx
153 env.cCtx = C.create_context((*C.TCreateContext)(e.createContext), (*C.arena)(env.Arena.Pointer))
154 env.cCtx.id = (C.uint32_t)(id)
155 env.goCtx = nil
156
157 // Allocate buffers for all the observed memory ranges.
158 for _, r := range capture.Observed {
159 ptr := env.Arena.Allocate((int)(r.Count), 16)
160 rng := memory.Range{Base: r.First, Size: r.Count}
161 env.buffers.add(rng, ptr)
162 }
163
164 return env
165}
166
167// Execute executes the command cmd.
168func (e *Env) Execute(ctx context.Context, cmd api.Cmd, id api.CmdID) error {

Callers 13

TestEmptyEnvFunction · 0.80
TestEnvSetFunction · 0.80
TestEnvGetFunction · 0.80
TestEnvExistsFunction · 0.80
TestEnvAddPathStartFunction · 0.80
TestEnvAddPathEndFunction · 0.80
TestCommandEnvironmentFunction · 0.80
GetEnvMethod · 0.80
GetConnectedDeviceFunction · 0.80
runMethod · 0.80
runMethod · 0.80
SetupTraceMethod · 0.80

Calls 6

envIDTypeAlias · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
NewMethod · 0.65
addMethod · 0.65
AllocateMethod · 0.45

Tested by 9

TestEmptyEnvFunction · 0.64
TestEnvSetFunction · 0.64
TestEnvGetFunction · 0.64
TestEnvExistsFunction · 0.64
TestEnvAddPathStartFunction · 0.64
TestEnvAddPathEndFunction · 0.64
TestCommandEnvironmentFunction · 0.64
runMethod · 0.64
runMethod · 0.64